Class: Jets::Git::Local
- Inherits:
-
Object
show all
- Extended by:
- Memoist
- Includes:
- GitCli
- Defined in:
- lib/jets/git/local.rb
Instance Method Summary
collapse
Methods included from GitCli
#git, #git?, #git_folder?, #git_installed?
Instance Method Details
#git_branch ⇒ Object
24
25
26
|
# File 'lib/jets/git/local.rb', line 24
def git_branch
git "rev-parse --abbrev-ref HEAD"
end
|
#git_dirty? ⇒ Boolean
37
38
39
|
# File 'lib/jets/git/local.rb', line 37
def git_dirty?
!git("status --porcelain").empty?
end
|
#git_message ⇒ Object
20
21
22
|
# File 'lib/jets/git/local.rb', line 20
def git_message
git "log -1 --pretty=%B"
end
|
#git_remote ⇒ Object
discover git remote name. in case it’s not origin
46
47
48
49
50
51
52
|
# File 'lib/jets/git/local.rb', line 46
def git_remote
`git remote 2>&1`
return unless $?.success?
`git remote`.strip end
|
#git_sha ⇒ Object
28
29
30
|
# File 'lib/jets/git/local.rb', line 28
def git_sha
git "rev-parse HEAD"
end
|
#git_url ⇒ Object
32
33
34
35
|
# File 'lib/jets/git/local.rb', line 32
def git_url
git "config --get remote.#{git_remote}.url"
end
|
#git_version ⇒ Object
41
42
43
|
# File 'lib/jets/git/local.rb', line 41
def git_version
git "--version", on_error: :raise
end
|
#params ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/jets/git/local.rb', line 6
def params
return {} unless git? && git_branch
params = {
git_system: 'local',
git_branch: git_branch,
git_sha: git_sha,
git_dirty: git_dirty?,
git_message: git_message,
git_version: git_version,
}
params[:git_url] = git_url if git_url
params
end
|