mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #2086 from bovi/checksum_hash
Implement :checksum_hash mrbgem option
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ MRuby::Build.new do |conf|
|
||||
# g.cc.flags << '-g' # append cflags in this gem
|
||||
# end
|
||||
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
|
||||
# conf.gem :github => 'masuidrive/mrbgems-example', :branch => 'master'
|
||||
# conf.gem :github => 'masuidrive/mrbgems-example', :checksum_hash => '76518e8aecd131d047378448ac8055fa29d974a9'
|
||||
# conf.gem :git => 'git@github.com:masuidrive/mrbgems-example.git', :branch => 'master', :options => '-v'
|
||||
|
||||
# include the default GEMs
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user