Module: Git
Class Method Summary
collapse
bar, cmd, error, green, pastel, prompt, red, success, table, yellow
Class Method Details
.checkout(branch, options = :with_fetch) ⇒ Object
5
6
7
8
9
10
|
# File 'lib/Git/git.rb', line 5
def self.checkout(branch, options = :with_fetch)
fetch(branch) if options == :with_fetch
execute {"git checkout #{branch}"}
self.pull branch if options == :with_fetch
end
|
.delete_branch(branch) ⇒ Object
48
49
50
51
52
|
# File 'lib/Git/git.rb', line 48
def self.delete_branch branch
execute {("git checkout develop && git branch -D #{branch}") }
end
|
.exist_branch?(branch) ⇒ Boolean
97
98
99
|
# File 'lib/Git/git.rb', line 97
def self.exist_branch? branch
execute {"git fetch origin #{branch}"}
end
|
.fetch(branch) ⇒ Object
84
85
86
87
88
|
# File 'lib/Git/git.rb', line 84
def self.fetch branch
execute { "git fetch origin #{branch}" }
end
|
.log_last_changes(branch) ⇒ Object
74
75
76
|
# File 'lib/Git/git.rb', line 74
def self.log_last_changes branch
execute {%{git log origin/#{branch}..HEAD --oneline --format="%ad - %B}}
end
|
.merge(from, to) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/Git/git.rb', line 12
def self.merge from, to
checkout(to, :local)
result = cmd.run!("git pull origin #{from}")
if result.success?
return result.out
else
print "Conflicts on merge!".yellow.bg_red
print "\n\nResolve conflicts and commit. \n"
print "After type '1' for to continue or '0' for abort\n".yellow
choice = STDIN.gets.chomp
print "\n#{choice}, "
print "ok!\n".green
case choice
when '1'
print "Continuing...\n\n"
else
print "Aborting merge...\n\n"
execute { ('git merge --abort') }
raise 'Aborting...'
end
end
end
|
.new_branch(branch) ⇒ Object
90
91
92
93
94
|
# File 'lib/Git/git.rb', line 90
def self.new_branch branch
execute { "git checkout -b #{branch}" }
end
|
.pull(branch) ⇒ Object
78
79
80
81
82
|
# File 'lib/Git/git.rb', line 78
def self.pull branch
execute { "git pull origin #{branch}" }
end
|
.push(branch) ⇒ Object
62
63
64
65
66
|
# File 'lib/Git/git.rb', line 62
def self.push branch
execute {"git push origin #{branch}"}
end
|
.push_force(branch) ⇒ Object
68
69
70
71
72
|
# File 'lib/Git/git.rb', line 68
def self.push_force branch
execute {"git push origin #{branch} -f"}
end
|
.reset_hard(from, to) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/Git/git.rb', line 54
def self.reset_hard from, to
self.fetch from
self.checkout(to)
execute { "git reset --hard origin/#{from}\n\n" }
end
|