summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2016-06-17 17:01:50 -0700
committerJohn Keiser <john@johnkeiser.com>2016-06-17 17:01:50 -0700
commitdbbad3f639afdf94fe542c77de6e42d3a97a4444 (patch)
treebd84e4a7bfc8e10d241e1a9df2768dd2accab29a
parentbab900b86a66edefcce9c84fffd868994468e5cf (diff)
downloadchef-dbbad3f639afdf94fe542c77de6e42d3a97a4444.tar.gz
Do not use bundle install to update Gemfile.lock after version bumpjk/crazy-version-bump
-rw-r--r--Rakefile5
-rw-r--r--chef-config/Rakefile2
-rw-r--r--chef-config/lib/chef-config/package_task.rb56
3 files changed, 45 insertions, 18 deletions
diff --git a/Rakefile b/Rakefile
index 7a9ff83cb9..74a30d45b0 100644
--- a/Rakefile
+++ b/Rakefile
@@ -29,12 +29,13 @@ require_relative "tasks/cbgb"
require_relative "tasks/dependencies"
require_relative "tasks/changelog"
-ChefConfig::PackageTask.new(File.expand_path("..", __FILE__), "Chef") do |package|
+ChefConfig::PackageTask.new(File.expand_path("..", __FILE__), "Chef", "chef") do |package|
package.component_paths = ["chef-config"]
package.generate_version_class = true
end
# Add a conservative dependency update to version:bump (which was created by PackageTask)
-task "version:bump" => %w{version:bump_patch version:update bundle:install}
+task "version:bump" => %w{version:bump_patch version:update}
+task "version:bump" => %w{version:bump_patch version:update}
task :pedant, :chef_zero_spec
diff --git a/chef-config/Rakefile b/chef-config/Rakefile
index 46f87c96c9..fd6497a287 100644
--- a/chef-config/Rakefile
+++ b/chef-config/Rakefile
@@ -1,6 +1,6 @@
require "chef-config/package_task"
-ChefConfig::PackageTask.new(File.expand_path("..", __FILE__), "ChefConfig") do |package|
+ChefConfig::PackageTask.new(File.expand_path("..", __FILE__), "ChefConfig", "chef-config") do |package|
package.module_path = "chef-config"
end
diff --git a/chef-config/lib/chef-config/package_task.rb b/chef-config/lib/chef-config/package_task.rb
index b984f60f9f..eb257ff4b5 100644
--- a/chef-config/lib/chef-config/package_task.rb
+++ b/chef-config/lib/chef-config/package_task.rb
@@ -31,6 +31,10 @@ module ChefConfig
# the top level module which contains VERSION and MODULE_ROOT.
attr_accessor :module_name
+ # Name of the gem being built. This is used to find the lines to fix in
+ # Gemfile.lock.
+ attr_accessor :gem_name
+
# Should the generated version.rb be in a class or module? Default is false (module).
attr_accessor :generate_version_class
@@ -55,15 +59,16 @@ module ChefConfig
# Name of git remote used to push tags during a release. Default is origin.
attr_accessor :git_remote
- def initialize(root_path = nil, module_name = nil)
- init(root_path, module_name)
+ def initialize(root_path = nil, module_name = nil, gem_name = nil)
+ init(root_path, module_name, gem_name)
yield self if block_given?
define unless root_path.nil? || module_name.nil?
end
- def init(root_path, module_name)
+ def init(root_path, module_name, gem_name)
@root_path = root_path
@module_name = module_name
+ @gem_name = gem_name
@component_paths = []
@module_path = nil
@package_dir = "pkg"
@@ -87,6 +92,10 @@ module ChefConfig
File.join(chef_root_path, "VERSION")
end
+ def gemfile_lock_path
+ File.join(root_path, "Gemfile.lock")
+ end
+
def version
IO.read(version_file_path).strip
end
@@ -155,6 +164,26 @@ module ChefConfig
namespace :version do
desc 'Regenerate lib/#{@module_path}/version.rb from VERSION file'
task :update => :update_components_versions do
+ update_version_rb
+ update_gemfile_lock
+ end
+
+ task :bump => %w{version:bump_patch version:update}
+
+ task :show do
+ puts version
+ end
+
+ # Add 1 to the current patch version in the VERSION file, and write it back out.
+ task :bump_patch do
+ current_version = version
+ new_version = current_version.sub(/^(\d+\.\d+\.)(\d+)/) { "#{$1}#{$2.to_i + 1}" }
+ puts "Updating version in #{version_rb_path} from #{current_version.chomp} to #{new_version.chomp}"
+ IO.write(version_file_path, new_version)
+ end
+
+ def update_version_rb
+ puts "Updating #{version_rb_path} to include version #{version} ..."
contents = <<-VERSION_RB
# Copyright:: Copyright 2010-2016, Chef Software, Inc.
# License:: Apache License, Version 2.0
@@ -194,18 +223,15 @@ end
IO.write(version_rb_path, contents)
end
- task :bump => %w{version:bump_patch version:update}
-
- task :show do
- puts version
- end
-
- # Add 1 to the current patch version in the VERSION file, and write it back out.
- task :bump_patch do
- current_version = version
- new_version = current_version.sub(/^(\d+\.\d+\.)(\d+)/) { "#{$1}#{$2.to_i + 1}" }
- puts "Updating version in #{version_rb_path} from #{current_version.chomp} to #{new_version.chomp}"
- IO.write(version_file_path, new_version)
+ def update_gemfile_lock
+ if File.exist?(gemfile_lock_path)
+ puts "Updating #{gemfile_lock_path} to include version #{version} ..."
+ contents = IO.read(gemfile_lock_path)
+ contents.gsub!(/^\s*(chef|chef-config)\s*\((= )?\S+\)\s*$/) do |line|
+ line.gsub(/\((= )?\d+(\.\d+)+/) { "(#{$1}#{version}" }
+ end
+ IO.write(gemfile_lock_path, contents)
+ end
end
end