Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle cases when BASE SHA isn't known on push events :basecamp: #196

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jamacku
Copy link
Member

@jamacku jamacku commented Jan 27, 2023

If the first commit is pushed to a new branch, ${{ github.event.before }} has a default value of 0000000000000000000000000000000000000000.

When we detect such SHA, we should try to get older BASE SHA from the HEAD branch if possible.

Inspired by:

If the first commit is pushed to a new branch, `${{ github.event.before }}` has a default value of `0000000000000000000000000000000000000000`.

When we detect such SHA, we should try to get older `BASE` SHA from the `HEAD` branch if possible.

Inspired by:

* [How can I get the previous commit before a push or merge in GitHub Action workflow? - Answered by Peter Evans](https://stackoverflow.com/a/61861763/10221282)
* [tj-actions/changed-files GitHub Action](https://github.com/tj-actions/changed-files/blob/main/diff-sha.sh#L116-L118)
assert_success
assert_output \
"first commit on new branch detected
BASE:\"${TRUE_BASE}\" ; HEAD:\"${INPUT_PUSH_EVENT_HEAD}\""

Check warning

Code scanning / shellcheck

TRUE_BASE is referenced but not assigned.

TRUE_BASE is referenced but not assigned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant