Class: Geordi::Git
- Inherits:
-
Object
- Object
- Geordi::Git
- Defined in:
- lib/geordi/git.rb
Class Method Summary collapse
- .commits_between(source, target) ⇒ Object
- .current_branch ⇒ Object
- .default_branch ⇒ Object
- .local_branch_names ⇒ Object
- .staged_changes? ⇒ Boolean
Class Method Details
.commits_between(source, target) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/geordi/git.rb', line 44 def commits_between(source, target) return [ENV['GEORDI_TESTING_GIT_COMMIT']] if Util.testing? commits = `git --no-pager log --pretty=format:%s #{source}..#{target}` commits&.split("\n") end |
.current_branch ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/geordi/git.rb', line 16 def current_branch if Util.testing? default_branch else `git rev-parse --abbrev-ref HEAD`.strip end end |
.default_branch ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/geordi/git.rb', line 33 def default_branch default_branch = if Util.testing? ENV['GEORDI_TESTING_DEFAULT_BRANCH'] else head_symref = `git ls-remote --symref origin HEAD` head_symref[%r{\Aref: refs/heads/(\S+)\sHEAD}, 1] end default_branch || 'master' end |
.local_branch_names ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/geordi/git.rb', line 4 def local_branch_names @local_branch_names ||= begin branch_list_string = if Util.testing? ENV['GEORDI_TESTING_GIT_BRANCHES'].to_s else `git branch --format="%(refname:short)"` end branch_list_string.strip.split("\n") end end |