Class: KStrano::GitHelper
- Inherits:
-
Object
- Object
- KStrano::GitHelper
- Defined in:
- lib/helpers/git_helper.rb
Class Method Summary collapse
- .branch_name(commit = "HEAD") ⇒ Object
- .commit_hash(commit = "HEAD") ⇒ Object
- .fetch ⇒ Object
- .merge_base(commit1, commit2 = "HEAD") ⇒ Object
- .origin_refspec ⇒ Object
- .origin_url ⇒ Object
Class Method Details
.branch_name(commit = "HEAD") ⇒ Object
20 21 22 23 |
# File 'lib/helpers/git_helper.rb', line 20 def self.branch_name(commit = "HEAD") name = %x(git name-rev --name-only #{commit}) name.strip end |
.commit_hash(commit = "HEAD") ⇒ Object
15 16 17 18 |
# File 'lib/helpers/git_helper.rb', line 15 def self.commit_hash(commit = "HEAD") hash = %x(git rev-parse #{commit}) hash.strip end |
.fetch ⇒ Object
6 7 8 |
# File 'lib/helpers/git_helper.rb', line 6 def self.fetch %x(git fetch) end |
.merge_base(commit1, commit2 = "HEAD") ⇒ Object
10 11 12 13 |
# File 'lib/helpers/git_helper.rb', line 10 def self.merge_base(commit1, commit2 = "HEAD") base = %x(git merge-base #{commit1} #{commit2}) base.strip end |
.origin_refspec ⇒ Object
25 26 27 28 |
# File 'lib/helpers/git_helper.rb', line 25 def self.origin_refspec refspec = %x(git config remote.origin.fetch) refspec.strip end |
.origin_url ⇒ Object
30 31 32 33 |
# File 'lib/helpers/git_helper.rb', line 30 def self.origin_url url = %x(git config remote.origin.url) url.strip end |