<commit_before>require 'chef/mixin/shell_out'
include Chef::Mixin::ShellOut
include Helpers::Docker

class CommandTimeout < RuntimeError; end

def load_current_resource
  @current_resource = Chef::Resource::DockerContainer.new(new_resource)
  dps = docker_cmd('ps -a -notrunc')
  dps.stdout.each_line do |dps_line|
    next unless dps_line.include?(new_resource.image)
    next if new_resource.command && !dps_line.include?(new_resource.command)
    Chef::Log.debug('Matched docker container: ' + dps_line.squeeze(' '))
    ps = dps_line.split(/\s\s+/)
    name = ps[6] || ps[5]
    @current_resource.container_name(name)
    @current_resource.id(ps[0])
    @current_resource.running(true) if ps[4].include?('Up')
    break
  end
  @current_resource
end

action :commit do
  if exists?
    commit
    new_resource.updated_by_last_action(true)
  end
end<commit_msg>current_resource attributes should only be set if new_resource.container_name is not provided or does not match previously launched container<commit_after>require 'chef/mixin/shell_out'
include Chef::Mixin::ShellOut
include Helpers::Docker

class CommandTimeout < RuntimeError; end

def load_current_resource
  @current_resource = Chef::Resource::DockerContainer.new(new_resource)
  dps = docker_cmd('ps -a -notrunc')
  dps.stdout.each_line do |dps_line|
    next unless dps_line.include?(new_resource.image)
    next if new_resource.command && !dps_line.include?(new_resource.command)
    Chef::Log.debug('Matched docker container: ' + dps_line.squeeze(' '))
    ps = dps_line.split(/\s\s+/)
    name = ps[6] || ps[5]
    next if new_resource.container_name && new_resource.container_name != name
    @current_resource.container_name(name)
    @current_resource.id(ps[0])
    @current_resource.running(true) if ps[4].include?('Up')
    break
  end
  @current_resource
end

action :commit do
  if exists?
    commit
    new_resource.updated_by_last_action(true)
  end
end
{'fraction_non_alphanumeric': 0.11421188630490955, 'fraction_numerical': 0.004134366925064599, 'mean_word_length': 4.866666666666666, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2605670', 'n_tokens_mistral': 661, 'n_tokens_neox': 650, 'n_words': 131}