I want to print the shortlog for a specific directory (part of my repository) in my GitHub-Workflow.
I use the git command git shortlog -e -n -s -- myFolder
I use the checkout@v3
action to check out my repo/pull-request as following:
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
My job runs on ubuntu-latest.
The problem is, the shortlog is always empty.
git log
works fine (GitHub-Action)
Local it works fine (macOS).
Do I miss anything?
CodePudding user response:
git shortlog
has a "feature" (misfeature, in my opinion, but it is documented so it's not technically a bug ):
If no revisions are passed on the command line and either standard input is not a terminal or there is no current branch,
git shortlog
will output a summary of the log read from standard input, without reference to the current repository.
When run as part of a GitHub action, standard input is not a terminal, which suffices to invoke this mode. (It's also true that, at least sometimes, there is no current branch, which would also trigger this behavior.)
As such, you must run git log
yourself and feed the git log
output to git shortlog
as its standard input (e.g., git log | git shortlog
) so that git shortlog
can summarize it.
Side note:
fetch-depth: 0
Good work: you successfully avoided the other trap with GitHub actions.