File tree 3 files changed +25
-4
lines changed
3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 16
16
# g.cc.flags << '-g' # append cflags in this gem
17
17
# end
18
18
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
19
- # conf.gem :github => 'masuidrive/mrbgems-example', :branch => 'master '
19
+ # conf.gem :github => 'masuidrive/mrbgems-example', :checksum_hash => '76518e8aecd131d047378448ac8055fa29d974a9 '
20
20
# conf.gem :git => '[email protected] :masuidrive/mrbgems-example.git', :branch => 'master', :options => '-v'
21
21
22
22
# include the default GEMs
Original file line number Diff line number Diff line change @@ -228,14 +228,15 @@ module MRuby
228
228
229
229
class Command ::Git < Command
230
230
attr_accessor :flags
231
- attr_accessor :clone_options , :pull_options
231
+ attr_accessor :clone_options , :pull_options , :checkout_options
232
232
233
233
def initialize ( build )
234
234
super
235
235
@command = 'git'
236
- @flags = %w[ --depth 1 ]
236
+ @flags = %w[ ]
237
237
@clone_options = "clone %{flags} %{url} %{dir}"
238
238
@pull_options = "pull"
239
+ @checkout_options = "checkout %{checksum_hash}"
239
240
end
240
241
241
242
def run_clone ( dir , url , _flags = [ ] )
@@ -250,6 +251,14 @@ module MRuby
250
251
_run pull_options
251
252
Dir . chdir root
252
253
end
254
+
255
+ def run_checkout ( dir , checksum_hash )
256
+ root = Dir . pwd
257
+ Dir . chdir dir
258
+ _pp "GIT CHECKOUT" , checksum_hash
259
+ _run checkout_options , { :checksum_hash => checksum_hash }
260
+ Dir . chdir root
261
+ end
253
262
end
254
263
255
264
class Command ::Mrbc < Command
Original file line number Diff line number Diff line change @@ -59,6 +59,9 @@ module MRuby
59
59
url = params [ :git ]
60
60
gemdir = "#{ gem_clone_dir } /#{ url . match ( /([-\w ]+)(\. [-\w ]+|)$/ ) . to_a [ 1 ] } "
61
61
62
+ # by default the 'master' branch is used
63
+ branch = params [ :branch ] ? params [ :branch ] : 'master'
64
+
62
65
if File . exist? ( gemdir )
63
66
if $pull_gems
64
67
git . run_pull gemdir , url
@@ -67,10 +70,19 @@ module MRuby
67
70
end
68
71
else
69
72
options = [ params [ :options ] ] || [ ]
70
- options << "--branch \" #{ params [ :branch ] } \" " if params [ :branch ]
73
+ options << "--branch \" #{ branch } \" "
74
+ options << "--depth 1" unless params [ :checksum_hash ]
71
75
FileUtils . mkdir_p "#{ gem_clone_dir } "
72
76
git . run_clone gemdir , url , options
73
77
end
78
+
79
+ if params [ :checksum_hash ]
80
+ # Jump to the specified commit
81
+ git . run_checkout gemdir , params [ :checksum_hash ]
82
+ else
83
+ # Jump to the top of the branch
84
+ git . run_checkout gemdir , branch
85
+ end
74
86
else
75
87
fail "unknown gem option #{ params } "
76
88
end
You can’t perform that action at this time.
0 commit comments