Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Prototype of update_rubygems "smart" history playback.

  • Loading branch information...
commit 6d593d1a041034188efb5042c6ed26be0d273108 1 parent 968626d
Erik Hollensbe authored
View
1  bin/update_rubygems
@@ -31,6 +31,7 @@ if update_dir.nil?
else
update_dir = File.dirname(update_dir)
Dir.chdir update_dir
+ ENV["GEM_PREV_VER"] = Gem::VERSION
system(Gem.ruby, 'setup.rb', *ARGV)
end
View
36 lib/rubygems/commands/setup_command.rb
@@ -5,6 +5,8 @@
# RubyGems checkout or tarball.
class Gem::Commands::SetupCommand < Gem::Command
+ HISTORY_HEADER = /^===\s*[\d.]+\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/
+ VERSION_MATCHER = /^===\s*([\d.]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/
def initialize
require 'tmpdir'
@@ -12,8 +14,14 @@ def initialize
super 'setup', 'Install RubyGems',
:format_executable => true, :rdoc => true, :ri => true,
:site_or_vendor => :sitelibdir,
- :destdir => '', :prefix => ''
+ :destdir => '', :prefix => '', :previous_version => ''
+ add_option '--previous-version=VERSION',
+ 'Previous version of rubygems',
+ 'Used for changelog processing' do |version, options|
+ options[:previous_version] = version
+ end
+
add_option '--prefix=PREFIX',
'Prefix path for installing RubyGems',
'Will not affect gem repository location' do |prefix, options|
@@ -118,14 +126,30 @@ def execute
say
end
+ if options[:previous_version].empty?
+ options[:previous_version] = Gem::VERSION.sub(/[0-9]+$/, '0')
+ end
+
+ options[:previous_version] = Gem::Version.new(options[:previous_version])
+
release_notes = File.join Dir.pwd, 'History.txt'
- release_notes = if File.exist? release_notes then
- open release_notes do |io|
- text = io.gets '==='
- text << io.gets('===')
- text[0...-3]
+ release_notes = if File.exist? release_notes
+
+ history = File.read(release_notes)[3..-1]
+
+ text = history.split(HISTORY_HEADER)
+ text.shift # correct an off-by-one generated by split
+ version_lines = history.scan(HISTORY_HEADER)
+ versions = history.scan(VERSION_MATCHER).flatten.map { |x| Gem::Version.new(x) }
+
+ history_string = ""
+
+ until versions.length == 0 or versions.shift < options[:previous_version]
+ history_string += version_lines.shift + text.shift
end
+
+ history_string
else
"Oh-no! Unable to find release notes!"
end
View
4 setup.rb
@@ -31,7 +31,9 @@
Gem::CommandManager.instance.register_command :setup
args = ARGV.clone
-
+if ENV["GEM_PREV_VER"]
+ args = [ '--previous-version', ENV["GEM_PREV_VER"] ] + args
+end
args.unshift 'setup'
begin
Please sign in to comment.
Something went wrong with that request. Please try again.