Skip to content

Commit 2f7cbd1

Browse files
committed
ci(common): Fix pre-commit manual run
1 parent 8e5a27f commit 2f7cbd1

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

.github/workflows/pre_commit_check.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v3
16+
with:
17+
ref: ${{ github.base_ref }}
1618
- name: Fetch head and base refs
17-
# This is necessary for pre-commit to check the changes in the PR branch
19+
# This is necessary for pre-commit to check the changes in the PR branch (and to set origin/HEAD and HEAD refs)
1820
run: |
19-
git fetch origin ${{ github.base_ref }}:base_ref
20-
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_ref
21+
git fetch origin ${{ github.event.pull_request.head.sha }}:pr_ref
22+
git checkout pr_ref
23+
git remote set-head origin --auto
2124
- name: Set up Python environment
2225
uses: actions/setup-python@master
2326
with:
@@ -26,13 +29,12 @@ jobs:
2629
run: |
2730
pip install pre-commit
2831
pre-commit install-hooks
29-
pre-commit install --hook-type commit-msg --hook-type pre-push
3032
- name: Run pre-commit and check for any changes
3133
run: |
3234
echo "Commits being checked:"
33-
git log --oneline --no-decorate base_ref..pr_ref
35+
git log --oneline --no-decorate origin/HEAD..HEAD
3436
echo ""
35-
if ! pre-commit run --from-ref base_ref --to-ref pr_ref --show-diff-on-failure ; then
37+
if ! pre-commit run --from-ref origin/HEAD --to-ref HEAD --hook-stage manual --show-diff-on-failure ; then
3638
echo ""
3739
echo "::notice::It looks like the commits in this PR have been made without having pre-commit hooks installed."
3840
echo "::notice::Please see https://github.com/espressif/esp-protocols/CONTRIBUTING.md for instructions."

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ repos:
5757
hooks:
5858
- id: commitizen
5959
- id: commitizen-branch
60-
stages: [push]
60+
stages: [push, manual]
6161
- repo: local
6262
hooks:
6363
- id: commit message scopes

0 commit comments

Comments
 (0)