Skip to content

Commit 8af9efb

Browse files
authoredApr 9, 2022
Merge pull request #245 from abitmore/fix-fetch
Add --fetch-branches and --fetch-tags options
2 parents 0d1b9b3 + 52c3602 commit 8af9efb

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed
 

‎bin/gbuild

+18-5
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ OptionParser.new do |opts|
223223
opts.on("--skip-fetch", "skip fetching the latest git objects and refs from the remote source") do |v|
224224
@options[:skip_fetch] = v
225225
end
226+
opts.on("--fetch-branches", "fetch branches from the remote source") do |v|
227+
@options[:fetch_branches] = v
228+
end
229+
opts.on("--fetch-tags", "fetch tags from the remote source") do |v|
230+
@options[:fetch_tags] = v
231+
end
226232
opts.on("--skip-cleanup", "skip cleaning up the target VM. this may be useful for copying additional files from the target after the build") do |v|
227233
@options[:skip_cleanup] = v
228234
end
@@ -320,12 +326,19 @@ build_desc["remotes"].each do |remote|
320326
system!("git init inputs/#{dir}")
321327
end
322328
if !@options[:skip_fetch]
323-
system!("cd inputs/#{dir} && git fetch -f --update-head-ok #{sanitize_path(remote["url"], remote["url"])} #{commit}:refs/tags/tobuild")
324-
system!("cd inputs/#{dir} && git checkout -q tobuild")
325-
system!("cd inputs/#{dir} && git submodule update --init --recursive --force")
329+
if @options[:fetch_branches]
330+
system!("cd inputs/#{dir} && git fetch -f --update-head-ok #{sanitize_path(remote["url"], remote["url"])} +refs/heads/*:refs/heads/*")
331+
end
332+
if @options[:fetch_tags]
333+
system!("cd inputs/#{dir} && git fetch -f --update-head-ok #{sanitize_path(remote["url"], remote["url"])} +refs/tags/*:refs/tags/*")
334+
end
335+
system!("cd inputs/#{dir} && git fetch -f --update-head-ok #{sanitize_path(remote["url"], remote["url"])} #{commit}")
336+
system!("cd inputs/#{dir} && git checkout -q FETCH_HEAD")
337+
else
338+
system!("cd inputs/#{dir} && git checkout -q #{commit}")
326339
end
327-
commit = `cd inputs/#{dir} && git log --format=%H -1 tobuild`.strip
328-
raise "error looking up commit for tag #{remote["commit"]}" unless $?.exitstatus == 0
340+
system!("cd inputs/#{dir} && git submodule update --init --recursive --force")
341+
commit = `cd inputs/#{dir} && git log --format=%H -1`.strip
329342
in_sums << "git:#{commit} #{dir}"
330343
end
331344

0 commit comments

Comments
 (0)
Please sign in to comment.