Open sdruskat opened 1 day ago
Action log:
Run # Cache current branch for PR close job
# Cache current branch for PR close job
git branch --show-current > .hermes/curate/target_branch
# Shorten the SHA for the PR title
SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c -8)
echo "SHORT_SHA=$SHORT_SHA" >> "$GITHUB_ENV"
# Create a curation branch
git branch -c "hermes/curate-$SHORT_SHA" <--- Fails!
git push origin "hermes/curate-$SHORT_SHA"
# Explicitly add to-be-curated metadata (which is ignored via .gitignore!)
git add -f .hermes/curate
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.10.15/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.10.15/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.15/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.15/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.15/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.10.15/x64/lib
fatal: cannot copy the current branch while not on any
Error: Process completed with exit code 128.
One workaround could be something like
# If HEAD is detached (e.g., when a tag has been checked out),
# switch to new temporary branch hermes/tmp/<current ref>,
# and push that to origin
if [ $(git branch --show-current | wc -l) -eq "0" ]; then
HERMES_TMP_BRANCH=hermes/tmp-$(git rev-parse --short HEAD)
git switch -c $HERMES_TMP_BRANCH
git push -u origin $HERMES_TMP_BRANCH
fi
Then, the branch should also be deleted in hermes-curate
and hermes-cleanup
:
for BRANCH in $(git ls-remote origin 'refs/heads/hermes/curate-*' | cut -f2 | cut -d'/' -f'3-'); do
git push origin --delete "$BRANCH"
done
for BRANCH in $(git ls-remote origin 'refs/heads/$HERMES_TMP_BRANCH' | cut -f2 | cut -d'/' -f'3-'); do <---
git push origin --delete "$BRANCH" <---
done <---
Copying the GitHub template and changing it to run on pushed tags leads to a failing workflow:
This is because the checkout actions (or rather, git) checks out into detached HEAD state.
In these cases, a new branch must be created from the detached HEAD before copying it, otherwise you run into
fatal: cannot copy the current branch while not on any
.We need to reflect this in the template and the docs website (docs.smp) as this is a very common case.