Class: Rugged::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/lyp/git_based_rugged.rb

Defined Under Namespace

Classes: Ref

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Repository

Returns a new instance of Repository.



18
19
20
21
# File 'lib/lyp/git_based_rugged.rb', line 18

def initialize(path)
  @path = path
  exec('status')
end

Class Method Details

.clone_at(url, path) ⇒ Object



13
14
15
16
# File 'lib/lyp/git_based_rugged.rb', line 13

def self.clone_at(url, path)
  `git clone -q \"#{url}\" \"#{path}\"`
  new(path)
end

Instance Method Details

#checkout(ref, opts) ⇒ Object



31
32
33
34
# File 'lib/lyp/git_based_rugged.rb', line 31

def checkout(ref, opts)
  # strategy: :force
  exec("checkout -qf #{ref}")
end

#exec(cmd) ⇒ Object



40
41
42
# File 'lib/lyp/git_based_rugged.rb', line 40

def exec(cmd)
  `cd #{@path} && git #{cmd}`
end

#headObject



25
26
27
28
# File 'lib/lyp/git_based_rugged.rb', line 25

def head
  h = exec("show-ref --head").lines.map {|r| r =~ /^(\S+)\sHEAD$/ && $1}[0]
  Ref.new(h)
end

#tagsObject



36
37
38
# File 'lib/lyp/git_based_rugged.rb', line 36

def tags
  exec("tag").lines.map {|l| Ref.new(l.chomp)}
end