summaryrefslogtreecommitdiffhomepage
path: root/tasks
diff options
context:
space:
mode:
authorDaniel Bovensiepen <[email protected]>2014-04-20 05:39:40 +0800
committerDaniel Bovensiepen <[email protected]>2014-04-20 05:39:40 +0800
commit874bec2af5800b0847d702999efbe796b1c20cfa (patch)
tree1caf87feca38136587e33c12e0564da5650e0031 /tasks
parent44cc51fef7b68f2b93a5c51d4da9778ca43fa80e (diff)
downloadmruby-874bec2af5800b0847d702999efbe796b1c20cfa.tar.gz
mruby-874bec2af5800b0847d702999efbe796b1c20cfa.zip
Implement :checksum_hash mrbgem option.
This allows to use a mgem with a specific checksum hash. The following modification were necessary to implement this function: - add run_checkout build command to use 'git checkout' - skip shallow copy in case checksum_hash is used - make 'master' the default branch if branch isn't defined
Diffstat (limited to 'tasks')
-rw-r--r--tasks/mruby_build_commands.rake13
-rw-r--r--tasks/mruby_build_gem.rake14
2 files changed, 24 insertions, 3 deletions
diff --git a/tasks/mruby_build_commands.rake b/tasks/mruby_build_commands.rake
index d64b20ff3..4beb7e743 100644
--- a/tasks/mruby_build_commands.rake
+++ b/tasks/mruby_build_commands.rake
@@ -228,14 +228,15 @@ module MRuby
class Command::Git < Command
attr_accessor :flags
- attr_accessor :clone_options, :pull_options
+ attr_accessor :clone_options, :pull_options, :checkout_options
def initialize(build)
super
@command = 'git'
- @flags = %w[--depth 1]
+ @flags = %w[]
@clone_options = "clone %{flags} %{url} %{dir}"
@pull_options = "pull"
+ @checkout_options = "checkout %{checksum_hash}"
end
def run_clone(dir, url, _flags = [])
@@ -250,6 +251,14 @@ module MRuby
_run pull_options
Dir.chdir root
end
+
+ def run_checkout(dir, checksum_hash)
+ root = Dir.pwd
+ Dir.chdir dir
+ _pp "GIT CHECKOUT", checksum_hash
+ _run checkout_options, { :checksum_hash => checksum_hash }
+ Dir.chdir root
+ end
end
class Command::Mrbc < Command
diff --git a/tasks/mruby_build_gem.rake b/tasks/mruby_build_gem.rake
index 42d0d6b89..766266680 100644
--- a/tasks/mruby_build_gem.rake
+++ b/tasks/mruby_build_gem.rake
@@ -59,6 +59,9 @@ module MRuby
url = params[:git]
gemdir = "#{gem_clone_dir}/#{url.match(/([-\w]+)(\.[-\w]+|)$/).to_a[1]}"
+ # by default the 'master' branch is used
+ branch = params[:branch] ? params[:branch] : 'master'
+
if File.exist?(gemdir)
if $pull_gems
git.run_pull gemdir, url
@@ -67,10 +70,19 @@ module MRuby
end
else
options = [params[:options]] || []
- options << "--branch \"#{params[:branch]}\"" if params[:branch]
+ options << "--branch \"#{branch}\""
+ options << "--depth 1" unless params[:checksum_hash]
FileUtils.mkdir_p "#{gem_clone_dir}"
git.run_clone gemdir, url, options
end
+
+ if params[:checksum_hash]
+ # Jump to the specified commit
+ git.run_checkout gemdir, params[:checksum_hash]
+ else
+ # Jump to the top of the branch
+ git.run_checkout gemdir, branch
+ end
else
fail "unknown gem option #{params}"
end