Class: Blacksmith::Git

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = ".") ⇒ Git

Returns a new instance of Git.



26
27
28
# File 'lib/puppet_blacksmith/git.rb', line 26

def initialize(path = ".")
  @path = File.expand_path(path)
end

Instance Attribute Details

#commit_message_patternObject

Pattern to use for tags, %s is replaced with the actual version



10
11
12
# File 'lib/puppet_blacksmith/git.rb', line 10

def commit_message_pattern
  @commit_message_pattern
end

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/puppet_blacksmith/git.rb', line 6

def path
  @path
end

#tag_message_patternObject

Returns the value of attribute tag_message_pattern.



6
7
8
# File 'lib/puppet_blacksmith/git.rb', line 6

def tag_message_pattern
  @tag_message_pattern
end

#tag_patternObject

Returns the value of attribute tag_pattern.



6
7
8
# File 'lib/puppet_blacksmith/git.rb', line 6

def tag_pattern
  @tag_pattern
end

#tag_signObject

Returns the value of attribute tag_sign.



6
7
8
# File 'lib/puppet_blacksmith/git.rb', line 6

def tag_sign
  @tag_sign
end

Instance Method Details

#commit_modulefile!(version) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/puppet_blacksmith/git.rb', line 53

def commit_modulefile!(version)
  files = Blacksmith::Modulefile::FILES.select {|f| File.exists?(File.join(@path,f))}
  message = commit_message_pattern % version
  s = exec_git ["add"] + files
  s += exec_git ["commit", "-m", message]
  s
end

#has_tag?(tag) ⇒ Boolean

Returns:

  • (Boolean)


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

def has_tag?(tag)
  exec_git(['tag', '--list', tag]).strip == tag
end

#has_version_tag?(version) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
37
# File 'lib/puppet_blacksmith/git.rb', line 34

def has_version_tag?(version)
  tag = tag_pattern % version
  has_tag? tag
end

#push!Object



61
62
63
64
65
# File 'lib/puppet_blacksmith/git.rb', line 61

def push!
  s = exec_git ["push"]
  s += exec_git ["push", "--tags"]
  s
end

#tag!(version) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/puppet_blacksmith/git.rb', line 39

def tag!(version)
  tag = tag_pattern % version
  command = ["tag", tag]
  if tag_message_pattern
    tag_message = tag_message_pattern % version
    command += ["-m", tag_message]
  end
  if tag_sign
    raise Blacksmith::Error, 'Signed tags require messages - set tag_message_pattern' unless tag_message_pattern
    command += ["-s"]
  end
  exec_git command
end