Class: Tag

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

Overview

git –no-pager log –pretty=oneline -1 git tag -a -m ‘Successful continuous integration build on #timestamp’ #tag_name“

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository) ⇒ Tag

Returns a new instance of Tag.



7
8
9
# File 'lib/auto_tagger/tag.rb', line 7

def initialize(repository)
  @repository = repository
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



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

def repository
  @repository
end

Instance Method Details

#create(stage, commit = nil) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/auto_tagger/tag.rb', line 27

def create(stage, commit = nil)
  tag_name = name_for(stage)
  cmd = "git tag #{tag_name}"
  cmd += " #{commit}" if commit
  repository.run! cmd
  tag_name
end

#fetchObject



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

def fetch
  repository.run! "git fetch origin --tags"
end

#find_allObject



11
12
13
# File 'lib/auto_tagger/tag.rb', line 11

def find_all
  repository.run("git tag").split("\n")
end

#latest_from(stage) ⇒ Object



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

def latest_from(stage)
  find_all.select{|tag| tag =~ /^#{stage}/}.sort.last
end

#pushObject



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

def push
  repository.run! "git push origin --tags"
end