[macruby-changes] [1345] MacRuby/branches/experimental

source_changes at macosforge.org source_changes at macosforge.org
Sat Apr 4 08:25:01 PDT 2009


Revision: 1345
          http://trac.macosforge.org/projects/ruby/changeset/1345
Author:   eloy.de.enige at gmail.com
Date:     2009-04-04 08:25:00 -0700 (Sat, 04 Apr 2009)
Log Message:
-----------
Refactored rubyspec tasks into re-usable class and added the same tasks for mspec.

Modified Paths:
--------------
    MacRuby/branches/experimental/.gitignore

Added Paths:
-----------
    MacRuby/branches/experimental/rakelib/rubyspec_mspec.rake
    MacRuby/branches/experimental/rakelib/upstream_git_repo_tasks.rb

Removed Paths:
-------------
    MacRuby/branches/experimental/rakelib/rubyspec.rake

Modified: MacRuby/branches/experimental/.gitignore
===================================================================
--- MacRuby/branches/experimental/.gitignore	2009-04-04 15:24:53 UTC (rev 1344)
+++ MacRuby/branches/experimental/.gitignore	2009-04-04 15:25:00 UTC (rev 1345)
@@ -11,4 +11,6 @@
 y.tab.c
 include/ruby/config.h
 spec/ruby
-spec/frozen/upstream_patches
\ No newline at end of file
+spec/frozen/upstream_patches
+mspec_upstream
+mspec/upstream_patches
\ No newline at end of file

Deleted: MacRuby/branches/experimental/rakelib/rubyspec.rake
===================================================================
--- MacRuby/branches/experimental/rakelib/rubyspec.rake	2009-04-04 15:24:53 UTC (rev 1344)
+++ MacRuby/branches/experimental/rakelib/rubyspec.rake	2009-04-04 15:25:00 UTC (rev 1345)
@@ -1,136 +0,0 @@
-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
-
-  namespace :sync do
-    def upstream_rev
-      @upstream_rev ||= ENV['REV'] || File.read('spec/frozen/upstream')
-    end
-    
-    UPSTREAM_OPTIONS = {
-      :branch => "merge_upstream",
-      :exclude => %w{ upstream macruby.mspec tags/macruby },
-      :revert => %w{ ruby.1.9.mspec }
-    }
-
-    desc "Synchronize a checkout with spec/frozen (upstream)"
-    task :upstream do
-      puts "\nSwitching to a `#{UPSTREAM_OPTIONS[:branch]}' branch with current revision of spec/frozen: #{upstream_rev}"
-      Dir.chdir(spec_ruby) { git_checkout(upstream_rev, UPSTREAM_OPTIONS[:branch]) }
-
-      dir = ENV['DIR'] || spec_ruby
-      sh "rm -rf #{dir}/**"
-
-      rsync_options = Rsync_options.sub("--exclude 'tags'", '')
-      rsync_options += UPSTREAM_OPTIONS[:exclude].map { |f| "--exclude '#{f}'" }.join(' ')
-      rsync "spec/frozen/*", dir, rsync_options
-
-      Dir.chdir(spec_ruby) do
-        sh "git checkout #{UPSTREAM_OPTIONS[:revert].join(' ')}"
-        sh "git status"
-      end
-    end
-
-    namespace :upstream do
-      desc "Creates all individual patches in spec/frozen/upstream_patches since upstream revision of spec/frozen: #{upstream_rev}"
-      task :patches do
-        patch_dir = File.expand_path('spec/frozen/upstream_patches')
-        create_patches = "git format-patch --numbered --output-directory #{patch_dir} #{upstream_rev}"
-
-        Dir.chdir(spec_ruby) do
-          git_checkout('master')
-          sh create_patches
-        end
-      end
-
-      desc "Remove the `#{UPSTREAM_OPTIONS[:branch]}' branch and switch to the `master' branch (cleans all untracked files!)"
-      task :remove do
-        puts "\nRemoving the `#{UPSTREAM_OPTIONS[:branch]}' branch and all untracked files!"
-        Dir.chdir spec_ruby do
-          sh "git clean -f"
-          sh "git checkout ."
-          git_checkout('master')
-          sh "git branch -D #{UPSTREAM_OPTIONS[:branch]}"
-        end
-      end
-    end
-
-    desc "Synchronize spec/frozen with a current checkout (downstream)"
-    task :downstream => 'rubyspec: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
-  end
-
-  namespace :url do
-    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
-end
\ No newline at end of file

Added: MacRuby/branches/experimental/rakelib/rubyspec_mspec.rake
===================================================================
--- MacRuby/branches/experimental/rakelib/rubyspec_mspec.rake	                        (rev 0)
+++ MacRuby/branches/experimental/rakelib/rubyspec_mspec.rake	2009-04-04 15:25:00 UTC (rev 1345)
@@ -0,0 +1,18 @@
+require 'rakelib/upstream_git_repo_tasks'
+
+root = File.expand_path("../../", __FILE__)
+
+Rake::UpstreamGitRepoTasks.new :rubyspec do |r|
+  r.local_dir = File.join(root, 'spec/frozen')
+  r.upstream_dir = ENV['DIR'] || File.join(root, 'spec/ruby')
+  r.anon_url = 'git://github.com/rubyspec/rubyspec.git'
+  r.commit_url = 'git at github.com:rubyspec/rubyspec.git'
+  r.upstream_options[:exclude].concat %w{ macruby.mspec tags/macruby ruby.1.9.mspec }
+end
+
+Rake::UpstreamGitRepoTasks.new :mspec do |r|
+  r.local_dir = File.join(root, 'mspec')
+  r.upstream_dir = ENV['DIR'] || File.join(root, 'mspec_upstream')
+  r.anon_url = 'git://github.com/rubyspec/mspec.git'
+  r.commit_url = 'git at github.com:rubyspec/mspec.git'
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/rakelib/upstream_git_repo_tasks.rb
===================================================================
--- MacRuby/branches/experimental/rakelib/upstream_git_repo_tasks.rb	                        (rev 0)
+++ MacRuby/branches/experimental/rakelib/upstream_git_repo_tasks.rb	2009-04-04 15:25:00 UTC (rev 1345)
@@ -0,0 +1,140 @@
+require 'rakelib/git'
+
+class Rake::UpstreamGitRepoTasks
+  attr_accessor :name, :local_dir, :upstream_dir, :anon_url, :commit_url, :upstream_options
+  
+  def initialize(name)
+    @name = name
+    @upstream_options = {
+      :branch => 'merge_upstream',
+      :exclude => %w{ upstream }
+    }
+    yield self
+    define
+  end
+  
+  def upstream_rev
+    @upstream_rev ||= ENV['REV'] || File.read(File.join(@local_dir, 'upstream'))
+  end
+  
+  def define
+    namespace @name do
+      desc "Initialize #{@upstream_dir} with a #{@name} clone"
+      task :init do
+        if File.exists?(@upstream_dir)
+          unless is_git_project(@upstream_dir, "#{@name}.git")
+            raise "#{@upstream_dir} is not a #{@name} clone. Please remove before running this task."
+          end
+        else
+          sh "git clone #{@anon_url} #{@upstream_dir}"
+        end
+      end
+
+      desc "Update #{@name}"
+      task :update => :init do
+        puts "\nUpdating #{@name} repository..."
+        Dir.chdir @upstream_dir do
+          git_update
+        end
+      end
+
+      desc "Report changes to the #{@name} sources"
+      task :status do
+        Dir.chdir @upstream_dir do
+          system "git status"
+        end
+      end
+
+      desc "Commit changes to the #{@name} sources"
+      task :commit do
+        puts "\nCommitting changes to #{@name} sources..."
+        Dir.chdir @upstream_dir do
+          sh "git commit -a"
+        end
+      end
+
+      desc "Push changes to the #{@name} repository"
+      task :push => :update do
+        puts "\nPushing changes to the #{@name} repository..."
+        Dir.chdir @upstream_dir do
+          git_push
+        end
+      end
+
+      desc "Switch to the `master' branch"
+      task :master do
+        Dir.chdir @upstream_dir do
+          git_checkout('master')
+        end
+      end
+
+      namespace :url do
+        desc "Switch to the #{@name} commiter URL"
+        task :committer do
+          Dir.chdir @upstream_dir do
+            sh "git config remote.origin.url #{@commit_url}"
+          end
+          puts "\nYou're now accessing #{@name} via the committer URL."
+        end
+
+        desc "Switch to the #{@name} anonymous URL"
+        task :anon do
+          Dir.chdir @upstream_dir do
+            sh "git config remote.origin.url #{@anon_url}"
+          end
+          puts "\nYou're now accessing #{@name} via the anonymous URL."
+        end
+      end
+
+      namespace :sync do
+        desc "Synchronize a checkout with #{@local_dir} (upstream)"
+        task :upstream do
+          puts "\nSwitching to a `#{@upstream_options[:branch]}' branch with current revision of #{@local_dir}: #{upstream_rev}"
+          Dir.chdir(@upstream_dir) { git_checkout(upstream_rev, @upstream_options[:branch]) }
+          sh "rm -rf #{@upstream_dir}/**"
+
+          rsync_options = Rsync_options.sub("--exclude 'tags'", '')
+          rsync_options += @upstream_options[:exclude].map { |f| "--exclude '#{f}'" }.join(' ')
+          rsync "#{@local_dir}/*", @upstream_dir, rsync_options
+
+          Dir.chdir(@upstream_dir) { system "git status" }
+        end
+
+        namespace :upstream do
+          desc "Creates all individual patches in #{@local_dir}/upstream_patches since upstream revision: #{upstream_rev}"
+          task :patches do
+            create_patches = "git format-patch --numbered --output-directory #{File.join(@local_dir, 'upstream_patches')} #{upstream_rev}"
+            Dir.chdir(@upstream_dir) do
+              git_checkout('master')
+              sh create_patches
+            end
+          end
+
+          desc "Remove the `#{@upstream_options[:branch]}' branch and switch to the `master' branch (cleans all untracked files!)"
+          task :remove do
+            puts "\nRemoving the `#{@upstream_options[:branch]}' branch and all untracked files!"
+            Dir.chdir @upstream_dir do
+              sh "git clean -f"
+              sh "git checkout ."
+              git_checkout('master')
+              sh "git branch -D #{@upstream_options[:branch]}"
+            end
+          end
+        end
+
+        # desc "Synchronize spec/frozen with a current checkout (downstream)"
+        # task :downstream => 'rubyspec: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
+      end
+
+    end
+  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/1f38253c/attachment-0001.html>


More information about the macruby-changes mailing list