Class: FlashFlow::ShadowGit

Inherits:
Git
  • Object
show all
Defined in:
lib/flash_flow/shadow_repo.rb

Constant Summary collapse

FLASH_FLOW_BASE =
'.flash_flow'

Constants inherited from Git

Git::ATTRIBUTES, Git::UNMERGED_STATUSES

Instance Attribute Summary

Attributes inherited from Git

#working_branch

Instance Method Summary collapse

Methods inherited from Git

#add_and_commit, #commit_rerere, #conflicted_files, #copy_temp_to_branch, #current_branch, #delete_temp_merge_branch, #fetch, #fetch_remote_for_url, #in_branch, #in_dir, #in_merge_branch, #in_original_merge_branch, #in_temp_merge_branch, #initialize_rerere, #last_command, #last_stdout, #last_success?, #master_branch_contains?, #merge, #most_recent_commit, #push, #read_file_from_merge_branch, #remotes, #remotes_hash, #rerere_resolve!, #reset_temp_merge_branch, #resolution_candidates, #resolutions, #run, #split_diff_lines, #staged_and_working_dir_files, #unresolved_conflicts

Constructor Details

#initialize(config, logger = nil) ⇒ ShadowGit

Returns a new instance of ShadowGit.



8
9
10
11
12
13
14
15
16
17
# File 'lib/flash_flow/shadow_repo.rb', line 8

def initialize(config, logger=nil)
  super

  create_shadow_repo
  @cmd_runner.dir = flash_flow_dir

  run("clean -x -f")
  fetch(merge_remote)
  run("reset --hard HEAD")
end

Instance Method Details

#create_shadow_repoObject



19
20
21
22
23
24
# File 'lib/flash_flow/shadow_repo.rb', line 19

def create_shadow_repo
  unless Dir.exists?(flash_flow_dir)
    @cmd_runner.run("mkdir -p #{flash_flow_dir}")
    @cmd_runner.run("cp -R #{current_dir} #{flash_flow_base_dir}")
  end
end

#current_dirObject



35
36
37
# File 'lib/flash_flow/shadow_repo.rb', line 35

def current_dir
  Dir.getwd
end

#flash_flow_base_dirObject



27
28
29
30
31
32
33
# File 'lib/flash_flow/shadow_repo.rb', line 27

def flash_flow_base_dir
  if current_dir =~ /\.flash_flow/
    "#{current_dir.split(FLASH_FLOW_BASE).first}#{FLASH_FLOW_BASE}"
  else
    "#{current_dir}/../#{FLASH_FLOW_BASE}"
  end
end

#flash_flow_dirObject



39
40
41
# File 'lib/flash_flow/shadow_repo.rb', line 39

def flash_flow_dir
  @flash_flow_dir ||= flash_flow_base_dir + "/#{File.basename(current_dir)}"
end