Skip to content

Commit 94f66dc

Browse files
committed
Correct refspec to fetch Ruby source
`git fetch master:master` means synchronization of the remote `master` with the local `master`. If the local `master` is `HEAD`, Git will also try to update the file tree, but it is refused by default. Thus, we may see the errors like `fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository`. One of solutions is using `--update-head-ok` (`-u`) flag. It enforces to update the file tree on fetching `HEAD`. However, it seems not good to me because the Rake task uses `git checkout` after this `git fetch` so the file system updation on fetch is unnecessary. Another solution, by using this, is correcting refspec so that destination part becomes `origin`. Presumably, this is the canonical fix method. I'm not sure why the CI have been passed. Maybe GitHub returns a different (optimized) response on CI.
1 parent 87d57b3 commit 94f66dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/ruby_wasm/build_system/product/ruby_source.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ def fetch
3939
system "git init", chdir: src_dir
4040
system "git remote add origin #{repo_url}", chdir: src_dir
4141
system(
42-
"git fetch --depth 1 origin #{@params[:rev]}:#{@params[:rev]}",
42+
"git fetch --depth 1 origin #{@params[:rev]}:origin/#{@params[:rev]}",
4343
chdir: src_dir
4444
) or raise "failed to clone #{repo_url}"
45-
system("git checkout #{@params[:rev]}", chdir: src_dir) or
45+
system("git checkout origin/#{@params[:rev]}", chdir: src_dir) or
4646
raise "failed to checkout #{@params[:rev]}"
4747
when "local"
4848
FileUtils.mkdir_p File.dirname(src_dir)

0 commit comments

Comments
 (0)