Class: Cucumber::Pro::Scm::GitWorkingCopy

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/pro/scm/working_copy.rb

Instance Method Summary collapse

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

#branchObject

 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_cleanObject



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_urlObject



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

#revObject



51
52
53
# File 'lib/cucumber/pro/scm/working_copy.rb', line 51

def rev
  cmd("git rev-parse HEAD").last
end