Closed johnboiles closed 5 months ago
I was able to replace EndBug/add-and-commit with the following (which is working fine 🤷)
- name: "Commit changes if necessary"
if: github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if git diff --exit-code 'src/*/*.hpp' 'src/*/*.h' 'src/*/*.cpp' 'src/*/*.c' > /dev/null; then
echo "No changes to commit"
else
git config --global user.name "Clang Robot"
git config --global user.email "robot@sindarin.com"
git add 'src/*/*.hpp' 'src/*/*.h' 'src/*/*.cpp' 'src/*/*.c'
git commit -m "Committing clang-format/clang-tidy changes"
git push origin HEAD:${{ github.head_ref }}
fi
Ok I think i'm getting somewhere. If I add this to my script, it fails in a similar unhelpful way:
git fetch origin
if [ "$(git rev-parse HEAD)" != "$(git rev-parse @{u})" ]; then
echo "Newer changes detected on branch. Skipping commit."
exit 0
fi
But at least now I get
fatal: remote error: upload-pack: not our ref b226b5856bc8cf842cb65bec7d8adf44e5ae3595
fatal: the remote end hung up unexpectedly
...
Errors during submodule fetch:
components/esp-nimble-cpp
I'm unable to repro this locally, even with a fresh clone. It doesn't seem to be the obvious culprits (like an un-pushed submodule commit)
The culprit seems to be related to using submodules: "recursive"
. If I add the same thing to checkout on another action, it fails in a similar way.
Ok making my git fetch
more specific seemed to solve it:
- name: "Commit changes if necessary"
if: github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch origin ${{ github.head_ref }}
echo "HEAD: $(git rev-parse HEAD)"
echo "UPSTREAM: $(git rev-parse @{u})"
if [ "$(git rev-parse HEAD)" != "$(git rev-parse @{u})" ]; then
echo "Newer changes detected on branch. Skipping commit."
exit 0
fi
if git diff --exit-code 'src/*/*.hpp' 'src/*/*.h' 'src/*/*.cpp' 'src/*/*.c' > /dev/null; then
echo "No changes to commit"
else
git config --global user.name "Clang Robot"
git config --global user.email "robot@sindarin.com"
git add 'src/*/*.hpp' 'src/*/*.h' 'src/*/*.cpp' 'src/*/*.c'
git commit -m "Committing clang-format/clang-tidy changes"
git push origin HEAD:${{ github.head_ref }}
fi
I have no idea where this bad ref is coming from. I can't repro the same issue with local clones 🤷. Seems like this is mostly something funky with one of my submodules and not exactly an add-and-commit issue.
For add-and-commit I have two remaining questions:
fatal: remote error: upload-pack: not our ref
part or the Errors during submodule fetch:
part when using add-and-commit
git fetch origin ${{ github.head_ref }}
instead of fetching all of origin?This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Describe the bug Not sure why, but for some reason recently EndBug/add-and-commit has started to fail when trying to make the commit. It had been working fine for me for 1-2 years up until a month or two ago. It fails without a useful error message:
Workflow used
Seems like there's a good chance it's something related to running inside the Docker container possibly, but like I said it stopped working in the last month or so (and we had not changed the workflow since November '23). How do I debug this?