Class: ActiveRepo
- Inherits:
-
Repo
show all
- Defined in:
- lib/sfb_scripts/repositories/active_repo.rb
Instance Attribute Summary
Attributes inherited from Repo
#shell
Instance Method Summary
collapse
Methods inherited from Repo
#changed?, #current_branch, #find_files, #grep, #initialize, root_dir, #status_files
Constructor Details
This class inherits a constructor from Repo
Instance Method Details
#alter!(git_command) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/sfb_scripts/repositories/active_repo.rb', line 3
def alter!(git_command)
shell.notify "\nUpdating repo state:"
up do
begin
shell.run "git #{git_command}"
rescue ShellRunner::CommandFailureError
puts "Unable to rebase. Maybe you need to stash local changes, or there are rebase conflicts"
exit
end
end
end
|
#compare_with_reflog ⇒ Object
44
45
46
47
|
# File 'lib/sfb_scripts/repositories/active_repo.rb', line 44
def compare_with_reflog
old_sha = shell.run "git rev-parse HEAD@{2}"
set_files_changed(old_sha)
end
|
#fetch_origin ⇒ Object
49
50
51
|
# File 'lib/sfb_scripts/repositories/active_repo.rb', line 49
def fetch_origin
shell.run 'git fetch origin'
end
|
#files_changed ⇒ Object
33
34
35
|
# File 'lib/sfb_scripts/repositories/active_repo.rb', line 33
def files_changed
@files_changed
end
|
#move_to_master! ⇒ Object
57
58
59
|
# File 'lib/sfb_scripts/repositories/active_repo.rb', line 57
def move_to_master!
shell.run "git checkout master"
end
|
#pull_origin_master! ⇒ Object
37
38
39
40
41
42
|
# File 'lib/sfb_scripts/repositories/active_repo.rb', line 37
def pull_origin_master!
up do
fetch_origin
reset_hard_origin_master!
end
end
|
#reset_hard_origin_master! ⇒ Object
53
54
55
|
# File 'lib/sfb_scripts/repositories/active_repo.rb', line 53
def reset_hard_origin_master!
shell.run "git reset --hard origin/master"
end
|
#set_files_changed(old_sha) ⇒ Object
28
29
30
31
|
# File 'lib/sfb_scripts/repositories/active_repo.rb', line 28
def set_files_changed(old_sha)
shell.notify "\nIdentifying changed files:"
@files_changed = (shell.run "git diff --name-only #{old_sha}").split("\n")
end
|
#up ⇒ Object
21
22
23
24
25
26
|
# File 'lib/sfb_scripts/repositories/active_repo.rb', line 21
def up
old_sha = current_sha
yield
set_files_changed(old_sha)
end
|
#up_master! ⇒ Object
16
17
18
19
|
# File 'lib/sfb_scripts/repositories/active_repo.rb', line 16
def up_master!
move_to_master!
rebase_on_master!
end
|