I am trying to list commits that are differing between the main branch and my current branch in a script that’s also being utilized by a GitHub action:
$ git log --pretty="format:%h" --right-only $(git remote show)/main..$(git branch --show-current)
19edbd5
7c7aab7
d67a802
That doesn’t work in a GitHub action because the current branch is empty – so is HEAD. I suppose this is due to the detached head mode of PRs. Tried to git switch origin/$GITHUB_HEAD_REF
but to no avail.
I could use the gh
cli but that script should have as less dependencies as possible. Can you tell me what’s wrong with this approach?
2