Class: AutoTagger::Git::RefSet

Inherits:
Object
  • Object
show all
Defined in:
lib/auto_tagger/git/ref_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ RefSet

Returns a new instance of RefSet.



5
6
7
# File 'lib/auto_tagger/git/ref_set.rb', line 5

def initialize(repo)
  @repo = repo
end

Instance Method Details

#allObject



9
10
11
12
13
14
# File 'lib/auto_tagger/git/ref_set.rb', line 9

def all
  @repo.read("show-ref").split(/\n/).map do |line|
    sha, name = line.split
    Ref.new(@repo, sha, name)
  end
end

#create(sha, name) ⇒ Object

name = refs/autotags/2009857463 returns a ref should un-cache the refs in refset, or never memoize



25
26
27
# File 'lib/auto_tagger/git/ref_set.rb', line 25

def create(sha, name)
  Ref.new(@repo, sha, name).save
end

#fetch(pattern, remote = "origin") ⇒ Object

pattern = refs/auto_tags/*



35
36
37
# File 'lib/auto_tagger/git/ref_set.rb', line 35

def fetch(pattern, remote = "origin")
  @repo.exec "fetch #{remote} #{pattern}:#{pattern}"
end

#find_by_sha(sha) ⇒ Object



16
17
18
19
20
# File 'lib/auto_tagger/git/ref_set.rb', line 16

def find_by_sha(sha)
  all.detect do |ref|
    ref.sha == sha
  end
end

#push(pattern, remote = "origin") ⇒ Object

pattern = refs/autotags/*



30
31
32
# File 'lib/auto_tagger/git/ref_set.rb', line 30

def push(pattern, remote = "origin")
  @repo.exec "push #{remote} #{pattern}:#{pattern}"
end