Class: Blacksmith::Git
- Inherits:
-
Object
- Object
- Blacksmith::Git
- Defined in:
- lib/puppet_blacksmith/git.rb
Instance Attribute Summary collapse
-
#commit_message_pattern ⇒ Object
Pattern to use for tags, %s is replaced with the actual version.
-
#path ⇒ Object
Returns the value of attribute path.
-
#tag_message_pattern ⇒ Object
Returns the value of attribute tag_message_pattern.
- #tag_pattern ⇒ Object
-
#tag_sign ⇒ Object
Returns the value of attribute tag_sign.
Instance Method Summary collapse
- #commit_modulefile!(version) ⇒ Object
- #has_tag?(tag) ⇒ Boolean
- #has_version_tag?(version) ⇒ Boolean
-
#initialize(path = '.') ⇒ Git
constructor
A new instance of Git.
- #push! ⇒ Object
- #tag!(version) ⇒ Object
Constructor Details
#initialize(path = '.') ⇒ Git
Returns a new instance of Git.
17 18 19 |
# File 'lib/puppet_blacksmith/git.rb', line 17 def initialize(path = '.') @path = File.(path) end |
Instance Attribute Details
#commit_message_pattern ⇒ Object
Pattern to use for tags, %s is replaced with the actual version
9 10 11 |
# File 'lib/puppet_blacksmith/git.rb', line 9 def @commit_message_pattern || '[blacksmith] Bump version to %s' end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/puppet_blacksmith/git.rb', line 5 def path @path end |
#tag_message_pattern ⇒ Object
Returns the value of attribute tag_message_pattern.
5 6 7 |
# File 'lib/puppet_blacksmith/git.rb', line 5 def @tag_message_pattern end |
#tag_pattern ⇒ Object
13 14 15 |
# File 'lib/puppet_blacksmith/git.rb', line 13 def tag_pattern @tag_pattern || 'v%s' end |
#tag_sign ⇒ Object
Returns the value of attribute tag_sign.
5 6 7 |
# File 'lib/puppet_blacksmith/git.rb', line 5 def tag_sign @tag_sign end |
Instance Method Details
#commit_modulefile!(version) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/puppet_blacksmith/git.rb', line 45 def commit_modulefile!(version) files = Blacksmith::Modulefile::FILES.select { |f| File.exist?(File.join(@path, f)) } = % version s = exec_git ['add'] + files s += exec_git ['commit', '-m', ] s end |
#has_tag?(tag) ⇒ Boolean
21 22 23 |
# File 'lib/puppet_blacksmith/git.rb', line 21 def has_tag?(tag) exec_git(['tag', '--list', tag]).strip == tag end |
#has_version_tag?(version) ⇒ Boolean
25 26 27 28 |
# File 'lib/puppet_blacksmith/git.rb', line 25 def has_version_tag?(version) tag = tag_pattern % version has_tag? tag end |
#push! ⇒ Object
53 54 55 56 57 |
# File 'lib/puppet_blacksmith/git.rb', line 53 def push! s = exec_git ['push'] s += exec_git ['push', '--tags'] s end |
#tag!(version) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/puppet_blacksmith/git.rb', line 30 def tag!(version) tag = tag_pattern % version command = ['tag', tag] if = % version command += ['-m', ] end if tag_sign raise Blacksmith::Error, 'Signed tags require messages - set tag_message_pattern' unless command += ['-s'] end exec_git command end |