Class: GitMQ::Storage

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Storage

Returns a new instance of Storage.



10
11
12
13
# File 'lib/storage.rb', line 10

def initialize(path)
  @path = path
  @repo = read_or_create_repo
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/storage.rb', line 8

def path
  @path
end

#repoObject (readonly)

Returns the value of attribute repo.



8
9
10
# File 'lib/storage.rb', line 8

def repo
  @repo
end

Instance Method Details

#branch(name) ⇒ Object



19
20
21
# File 'lib/storage.rb', line 19

def branch(name)
  branches[name]
end

#branchesObject



15
16
17
# File 'lib/storage.rb', line 15

def branches
  repo.branches
end

#commits(branch, tag) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/storage.rb', line 27

def commits(branch, tag)
  walker = Rugged::Walker.new(repo)
  walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
  walker.push(branch(branch).target)

  tag = repo.tags[tag]
  walker.hide(tag.target) if tag
  walker
end

#tag(label, commit) ⇒ Object



37
38
39
# File 'lib/storage.rb', line 37

def tag(label, commit)
  repo.tags.create(label, commit, true)
end

#treeObject



23
24
25
# File 'lib/storage.rb', line 23

def tree
  Rugged::Tree::Builder.new(repo).write
end