Class: Cucumber::Pro::Scm::Repo

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

Constant Summary collapse

NoGitRepoFound =
Class.new(StandardError)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Repo

Returns a new instance of Repo.



19
20
21
# File 'lib/cucumber/pro/scm.rb', line 19

def initialize(path)
  @path = path
end

Class Method Details

.find(path = Dir.pwd) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/cucumber/pro/scm.rb', line 10

def self.find(path = Dir.pwd)
  if Dir.entries(path).include? '.git'
    new(path)
  else
    raise NoGitRepoFound if path == '/'
    find File.expand_path(path + '/..')
  end
end

Instance Method Details

#branchObject



27
28
29
# File 'lib/cucumber/pro/scm.rb', line 27

def branch
  cmd("git branch --contains #{rev}")
end

#remoteObject



23
24
25
# File 'lib/cucumber/pro/scm.rb', line 23

def remote
  cmd('git config --get remote.origin.url')
end

#revObject



31
32
33
# File 'lib/cucumber/pro/scm.rb', line 31

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