Skip to content

Commit

Permalink
inital structure to add a git tag
Browse files Browse the repository at this point in the history
  • Loading branch information
chazzly committed Apr 23, 2015
1 parent b18860b commit e93357d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/chef/knife/spork-bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ class SporkBump < Chef::Knife
:long => '--bump_comment',
:description => 'Bump will prompt for a Change comment, which will be appended to CHANGELOG.md along with the new version # and username',
:default => nil

option :bump_commit,
:long => '--bump_commit',
:description => 'Bump will create a git commit once version has been bumped',
:default => false

option :bump_tag,
:long => '--bump_tag',
:description => 'Bump will create a git tag using the new version #',
:default => false

if defined?(::Berkshelf)
option :berksfile,
Expand All @@ -47,7 +57,7 @@ class SporkBump < Chef::Knife
:default => true
end

banner 'knife spork bump COOKBOOK [major|minor|patch|manual] [--bump_comment]'
banner 'knife spork bump COOKBOOK [major|minor|patch|manual] [--bump_comment] [--bump_tag]'

def run
self.class.send(:include, KnifeSpork::Runner)
Expand Down Expand Up @@ -110,14 +120,14 @@ def bump
if config[:bump_comment]
changelog_file = "#{@cookbook.root_dir}/CHANGELOG.md"
ui.info "Enter Change Log comment, then press Ctrl-D: "
change_comment = $stdin.read
@change_comment = $stdin.read
File.open(changelog_file, 'a') { |cl|
cl.write("\n#{new_version}\n")
cl.write("---------\n")
cl.write("#{ENV['USER']} - #{change_comment}\n")
cl.write("#{ENV['USER']} - #{@change_comment}\n")
}
end

ui.info "Successfully bumped #{@cookbook.name} to v#{new_version}!"
end

Expand Down
8 changes: 8 additions & 0 deletions lib/knife-spork/plugins/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ def bump_tag
config.bump_tag || false
end

def bump_commit
config.bump_commit || false
end

def bump_tag
config.bump_tag || false
end

private
def git
safe_require 'git'
Expand Down

0 comments on commit e93357d

Please sign in to comment.