[macruby-changes] [1325] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Sat Apr 4 06:06:56 PDT 2009
Revision: 1325
http://trac.macosforge.org/projects/ruby/changeset/1325
Author: eloy.de.enige at gmail.com
Date: 2009-04-04 06:06:55 -0700 (Sat, 04 Apr 2009)
Log Message:
-----------
Imported rubyspec and git rake libs from rubinius and added a few MacRuby specific tasks for merging back upstream.
Modified Paths:
--------------
MacRuby/branches/experimental/.gitignore
Added Paths:
-----------
MacRuby/branches/experimental/rakelib/git.rb
MacRuby/branches/experimental/rakelib/rubyspec.rake
Modified: MacRuby/branches/experimental/.gitignore
===================================================================
--- MacRuby/branches/experimental/.gitignore 2009-04-04 11:56:38 UTC (rev 1324)
+++ MacRuby/branches/experimental/.gitignore 2009-04-04 13:06:55 UTC (rev 1325)
@@ -9,4 +9,5 @@
prelude.c
revision.h
y.tab.c
-include/ruby/config.h
\ No newline at end of file
+include/ruby/config.h
+spec/ruby
\ No newline at end of file
Added: MacRuby/branches/experimental/rakelib/git.rb
===================================================================
--- MacRuby/branches/experimental/rakelib/git.rb (rev 0)
+++ MacRuby/branches/experimental/rakelib/git.rb 2009-04-04 13:06:55 UTC (rev 1325)
@@ -0,0 +1,117 @@
+# Various convenience methods for working with Git
+# repositories in the rubyspec and mspec tasks.
+
+MINIMUM_GIT_VERSION = [1, 5, 3]
+
+def is_git_project(dir, project)
+ system "cd #{dir}; git config --get remote.origin.url '#{project}' >/dev/null"
+ $?.exitstatus == 0
+end
+
+def is_git_dir(dir)
+ File.directory?(dir) and File.directory?(File.join(dir, ".git"))
+end
+
+def git_branch
+ `git branch | grep "*"`.strip[2..-1]
+end
+
+def compare_git_ver
+ v = `git version`.scan(/version (\d+).(\d+).(\d+)/).flatten.map { |s| s.to_i }
+ m = [1, 5, 3]
+
+ (v <=> MINIMUM_GIT_VERSION) >= 0
+end
+
+def check_git_ver
+ raise "Invalid git version, use at least #{MINIMUM_GIT_VERSION.join(".")}" unless
+ compare_git_ver
+end
+
+def on_master
+ branch = git_branch()
+ switch = if branch != "master" then
+ `git checkout master`
+ puts "* Switching back to master..."
+ true
+ end
+
+ yield
+
+ if switch
+ puts "* Porting changes into #{branch}..."
+ `git checkout #{branch}`
+ sh "git rebase master"
+ end
+end
+
+def with_git_changes
+ `git diff-files --quiet`
+ if $?.exitstatus == 1 then
+ yield
+ true
+ end
+end
+
+def git_update
+ check_git_ver
+
+ clear = false
+ stash = with_git_changes do
+ clear = `git stash list`.scan("\n").size == 0
+ puts "* Saving changes..."
+ `git stash save`
+ true
+ end
+
+ on_master do
+ puts "* Pulling in new commits..."
+ sh "git fetch"
+ sh "git rebase origin"
+ end
+
+ if stash then
+ puts "* Applying changes..."
+ sh "git stash apply"
+ `git stash clear` if clear
+ end
+end
+
+def git_push
+ branch = git_branch
+
+ with_git_changes do
+ abort "You have outstanding changes. Please commit them first."
+ end if branch != "master"
+
+ on_master do
+ puts "* Merging topic '#{branch}' back into master..."
+ sh "git merge #{branch}"
+ puts "* Pushing changes..."
+ sh "git push"
+ end
+end
+
+def git_checkout(rev, branch = nil)
+ with_git_changes do
+ abort "You have outstanding changes. Please commit them first."
+ end
+ if branch
+ sh "git checkout -b #{branch} #{rev}"
+ else
+ sh "git checkout #{rev}"
+ end
+end
+
+def spec_ruby
+ "./spec/ruby"
+end
+
+# Don't use -a (--archive) as it includes -t, --times which can
+# cause .rbc files to not be regenerated when they should.
+Rsync_options = "-rlpgoDvP --delete --exclude '*svn*' --exclude '*swp' " \
+ "--exclude '*rbc' --exclude '*.rej' --exclude '*.orig' --exclude 'tags'"
+
+def rsync(left, right, options = nil)
+ sh "rsync #{options || Rsync_options} #{left} #{right}"
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/rakelib/rubyspec.rake
===================================================================
--- MacRuby/branches/experimental/rakelib/rubyspec.rake (rev 0)
+++ MacRuby/branches/experimental/rakelib/rubyspec.rake 2009-04-04 13:06:55 UTC (rev 1325)
@@ -0,0 +1,115 @@
+require 'rakelib/git'
+
+namespace :rubyspec do
+ desc "Initialize spec/ruby with a rubyspec clone"
+ task :init do
+ if File.exists? spec_ruby
+ unless is_git_project spec_ruby, "rubyspec.git"
+ raise "#{spec_ruby} is not a rubyspec clone. Please remove before running this task."
+ end
+ else
+ sh "git clone git://github.com/rubyspec/rubyspec.git #{spec_ruby}"
+ end
+ end
+
+ desc "Update rubyspec"
+ task :update => :init do
+ puts "\nUpdating rubyspec repository..."
+ Dir.chdir spec_ruby do
+ git_update
+ end
+ end
+
+ desc "Report changes to the rubyspec sources"
+ task :status do
+ Dir.chdir spec_ruby do
+ system "git status"
+ end
+ end
+
+ desc "Commit changes to the rubyspec sources"
+ task :commit do
+ puts "\nCommitting changes to rubyspec sources..."
+ Dir.chdir spec_ruby do
+ sh "git commit -a"
+ end
+ end
+
+ desc "Push changes to the rubyspec repository"
+ task :push => :update do
+ puts "\nPushing changes to the rubyspec repository..."
+ Dir.chdir spec_ruby do
+ git_push
+ end
+ end
+
+ desc "Switch to the `master' branch"
+ task :master do
+ Dir.chdir spec_ruby do
+ git_checkout('master')
+ end
+ end
+
+ MERGE_OPTIONS = {
+ :exclude => %w{ upstream macruby.mspec tags/macruby },
+ :revert => %w{ ruby.1.9.mspec }
+ }
+
+ desc "Synchronize a checkout with spec/frozen (upstream)"
+ task :merge do
+ rev = ENV['REV'] || File.read('spec/frozen/upstream')
+ puts "\nSwitching to a `merge' branch with current revision of spec/frozen: #{rev}"
+ Dir.chdir(spec_ruby) { git_checkout(rev, 'merge') }
+
+ dir = ENV['DIR'] || spec_ruby
+ sh "rm -rf #{dir}/**"
+
+ rsync_options = Rsync_options.sub("--exclude 'tags'", '')
+ rsync_options += MERGE_OPTIONS[:exclude].map { |f| "--exclude '#{f}'" }.join(' ')
+ rsync "spec/frozen/*", dir, rsync_options
+
+ Dir.chdir(spec_ruby) do
+ sh "git checkout #{MERGE_OPTIONS[:revert].join(' ')}"
+ sh "git status"
+ end
+ end
+
+ desc "Remove the `merge' branch and switch to the `master' branch (cleans all untracked files!)"
+ task :remove_merge do
+ puts "\nRemoving the `merge' branch and all untracked files!"
+ Dir.chdir spec_ruby do
+ sh "git clean -f"
+ sh "git checkout ."
+ git_checkout('master')
+ sh "git branch -D merge"
+ end
+ end
+
+ desc "Synchronize spec/frozen with a current checkout (downstream)"
+ task :sync => :update do
+ dir = ENV['DIR'] || spec_ruby
+
+ rm_rf "spec/frozen"
+ rsync dir + "/*", "spec/frozen"
+
+ version = Dir.chdir(dir) { `git log --pretty=oneline -1`[0..7] }
+ sh "git add spec/frozen/"
+ sh "git commit -m 'Updated CI frozen specs to RubySpec #{version}.' spec/frozen"
+ end
+
+ desc "Switch to the rubyspec commiter URL"
+ task :committer do
+ Dir.chdir spec_ruby do
+ sh "git config remote.origin.url git at github.com:rubyspec/rubyspec.git"
+ end
+ puts "\nYou're now accessing rubyspec via the committer URL."
+ end
+
+ desc "Switch to the rubyspec anonymous URL"
+ task :anon do
+ Dir.chdir spec_ruby do
+ sh "git config remote.origin.url git://github.com/rubyspec/rubyspec.git"
+ end
+ puts "\nYou're now accessing rubyspec via the anonymous URL."
+ end
+end
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090404/c3de79ed/attachment-0001.html>
More information about the macruby-changes
mailing list