Module: Fuci::Git
- Defined in:
- lib/fuci/git.rb
Defined Under Namespace
Classes: NoPullError, NoResponseError
Constant Summary
collapse
- MASTER =
'master'
- CURRENT_BRANCH_COMMAND =
"git branch | sed -n '/\* /s///p'"
- REMOTE_REPO_COMMAND =
"git remote show -n origin | grep Push | cut -d/ -f4- | sed 's/\.git//g'"
- REMOTE_SHA_FROM_BRANCH_COMMAND =
lambda { |branch_name| "git rev-parse origin/#{branch_name}" }
- PULL_MERGE_SHA_FROM_NUMBER_COMMAND =
lambda { |pull_number| "git ls-remote origin | grep refs\\/pull\\/#{pull_number}\\/merge | awk '{ print $1 };'" }
- PULL_NUMBER_FROM_SHA_COMMAND =
lambda { |sha| "git ls-remote origin | grep #{sha} | grep pull | perl -n -e '/pull\\/(.*)\\/head/ && print $1'" }
Instance Method Summary
collapse
Instance Method Details
#current_branch_name ⇒ Object
14
15
16
|
# File 'lib/fuci/git.rb', line 14
def current_branch_name
with_popen current_branch_command
end
|
#pull_merge_sha_from(branch_name) ⇒ Object
30
31
32
33
|
# File 'lib/fuci/git.rb', line 30
def pull_merge_sha_from branch_name
pull_number = pull_number_from branch_name
with_popen pull_merge_sha_command(pull_number)
end
|
#pull_number_from(branch_name) ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/fuci/git.rb', line 35
def pull_number_from branch_name
remote_sha = remote_sha_from branch_name
begin
with_popen pull_number_from_sha_command(remote_sha)
rescue NoResponseError
raise NoPullError
end
end
|
#remote_master_sha ⇒ Object
22
23
24
|
# File 'lib/fuci/git.rb', line 22
def remote_master_sha
with_popen remote_sha_from_branch_command(MASTER)
end
|
#remote_repo_name ⇒ Object
18
19
20
|
# File 'lib/fuci/git.rb', line 18
def remote_repo_name
with_popen remote_repo_command
end
|
#remote_sha_from(branch_name) ⇒ Object
26
27
28
|
# File 'lib/fuci/git.rb', line 26
def remote_sha_from branch_name
with_popen remote_sha_from_branch_command(branch_name)
end
|