Class: ActiveRepo

Inherits:
Repo
  • Object
show all
Defined in:
lib/active_repo.rb

Instance Attribute Summary

Attributes inherited from Repo

#shell

Instance Method Summary collapse

Methods inherited from Repo

#all_files, #changed?, #current_branch, #files_changed, #find_files, #grep, #initialize, root_dir, #status_files

Constructor Details

This class inherits a constructor from Repo

Instance Method Details

#fetch_originObject



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

def fetch_origin
  shell.run 'git fetch origin'
end

#move_to_master!Object



44
45
46
# File 'lib/active_repo.rb', line 44

def move_to_master!
  shell.run "git checkout master"
end

#pull_origin_master!Object



29
30
31
32
33
34
# File 'lib/active_repo.rb', line 29

def pull_origin_master!
  up do
    fetch_origin
    reset_hard_origin_master!
  end
end

#rebase_on_master!Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/active_repo.rb', line 5

def rebase_on_master!
  up do
    # will raise an error with merge conflicts
    begin
      shell.run "git pull --rebase origin master"
    rescue ShellRunner::CommandFailureError
      puts "Unable to rebase.  Maybe you need to stash local changes, or there are rebase conflicts"
      puts `git status`
      exit
    end
  end
end

#reset_hard_origin_master!Object



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

def reset_hard_origin_master!
  shell.run "git reset --hard origin/master"
end

#upObject



23
24
25
26
27
# File 'lib/active_repo.rb', line 23

def up
  @old_sha = current_sha
  yield
  @new_sha = current_sha
end

#up_master!Object



18
19
20
21
# File 'lib/active_repo.rb', line 18

def up_master!
  move_to_master!
  rebase_on_master!
end