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, #ahead_of_master?, #branch_contains?, #branch_exists?, #commit_rerere, #conflicted_files, #copy_temp_to_branch, #current_branch, #delete_temp_merge_branch, #get_sha, #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, #rerere_resolve!, #reset_temp_merge_branch, #resolution_candidates, #resolutions, #run, #split_diff_lines, #staged_and_working_dir_files, #temp_merge_branch, #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
18
# 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")
  run("fetch #{remote}")
  run("remote prune #{remote}")
  run("reset --hard HEAD")
end

Instance Method Details

#create_shadow_repoObject



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

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



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

def current_dir
  Dir.getwd
end

#flash_flow_base_dirObject



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

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



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

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