Silence the detachedHead warning when ref_type is a revision

The PR that added this #8622 didn't actually resolve the problem because you see the warning when the `@ref_type` you've specified is a `:revision` (not a `:branch` or `:tag`).

The output looks like this:
```
==> Checking out revision 3b3527f5050270cf1acd280691b09b5abe130e73
Note: switching to '3b3527f5050270cf1acd280691b09b5abe130e73'

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

   git switch -c <new-branch-name>

Or undo this operation with:

   git switch -

Turn off this advice by setting config variable advice.detachedHead to false
```
This commit is contained in:
Bob Lail 2021-12-02 11:07:39 -06:00
parent 073c4177b5
commit 68245e0f60

View File

@ -883,9 +883,9 @@ class GitDownloadStrategy < VCSDownloadStrategy
case @ref_type case @ref_type
when :branch, :tag when :branch, :tag
args << "--branch" << @ref args << "--branch" << @ref
args << "-c" << "advice.detachedHead=false" # silences detached head warning
end end
args << "-c" << "advice.detachedHead=false" # silences detached head warning
args << @url << cached_location args << @url << cached_location
end end
@ -915,6 +915,9 @@ class GitDownloadStrategy < VCSDownloadStrategy
command! "git", command! "git",
args: ["config", "remote.origin.tagOpt", "--no-tags"], args: ["config", "remote.origin.tagOpt", "--no-tags"],
chdir: cached_location chdir: cached_location
command! "git",
args: ["config", "advice.detachedHead", "false"],
chdir: cached_location
end end
sig { params(timeout: T.nilable(Time)).void } sig { params(timeout: T.nilable(Time)).void }