Class: Cucumber::Pro::Scm::GitWorkingCopy
- Inherits:
-
Object
- Object
- Cucumber::Pro::Scm::GitWorkingCopy
- Defined in:
- lib/cucumber/pro/scm/working_copy.rb
Instance Method Summary collapse
-
#branch ⇒ Object
tries to return the name of the origin branch that points to the current HEAD.
- #check_clean ⇒ Object
-
#initialize(path) ⇒ GitWorkingCopy
constructor
A new instance of GitWorkingCopy.
- #repo_url ⇒ Object
- #rev ⇒ Object
Constructor Details
#initialize(path) ⇒ GitWorkingCopy
Returns a new instance of GitWorkingCopy.
27 28 29 |
# File 'lib/cucumber/pro/scm/working_copy.rb', line 27 def initialize(path) @path = path end |
Instance Method Details
#branch ⇒ Object
tries to return the name of the origin branch that points to the current HEAD
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cucumber/pro/scm/working_copy.rb', line 40 def branch if remote_refs.empty? # just use local branch name return cmd("git name-rev --name-only HEAD")[0] end if remote_refs.length > 1 fail "Multiple remote branches point to this commit: #{remote_refs.join(',')}" end remote_refs.first.gsub(/refs\/remotes\/\w+\//, '') end |
#check_clean ⇒ Object
55 56 57 58 |
# File 'lib/cucumber/pro/scm/working_copy.rb', line 55 def check_clean check_no_modifications check_current_branch_pushed end |
#repo_url ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/cucumber/pro/scm/working_copy.rb', line 31 def repo_url cmd('git ls-remote --get-url').each do |remote| return remote if remote =~ /(github|bitbucket)/ end # Fallback if we didn't find one cmd('git config --get remote.origin.url').last end |
#rev ⇒ Object
51 52 53 |
# File 'lib/cucumber/pro/scm/working_copy.rb', line 51 def rev cmd("git rev-parse HEAD").last end |