Re: git remote set-head automatically
- From
Jeff King <peff@peff.net>
- Date
- Nov 19, 2024, 18:44 UTC
- Message-ID
- <20241119184404.GA15723@coredump.intra.peff.net>
- In-Reply-To
- <CAAHKNRF4AnvceiTDLdpNS94yRnoZYMSD0Wkg7V+4YBwSej7NSA@mail.gmail.com>
On Tue, Nov 19, 2024 at 12:06:21PM -0500, Caleb Cushing wrote:
Show 10 quoted lines
> A little more progress on what I'm going to have to do, github action,
> without set-head the ref/HEAD isn't present
>
> - uses: actions/checkout@v4
> with:
> ref: ${{ github.event.workflow_run.head_branch}}
> filter: "blob:none"
> fetch-depth: 0
> - run: git remote set-head origin --auto # fixes otherwise the cat
> will not find a fileWe do create the HEAD symref in clone by default, but IIRC actions/checkout does a more limited clone with --depth and --single-branch.
The separate set-head should work, but it is a shame that it will have to hit the server for a second request.
You might look for options in actions/checkout to change the way it invokes Git. Though I suspect there might not be a way to trigger git-clone to do a single-branch clone _and_ create the HEAD symref. So you may be stuck with the two calls.
> - run: cat .git/refs/remotes/origin/HEAD
Don't access the file directly; it will break if the ref storage format changes. Use "git symbolic-ref refs/remotes/origin/HEAD" instead.
(Not sure if this was just illustrative or what you are planning to do in a real CI job).
-Peff