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

set stages for destroyed-symlinks #1085

Merged
merged 1 commit into from
Oct 5, 2024

Conversation

AdrianDC
Copy link
Contributor

The 'destroyed-symlinks' hook runs upon 'commit-msg' hook, however when used in 'git submodules', repository scope breaks

pre_commit_hooks.util.CalledProcessError: (('git', 'status',
'--porcelain=v2', '-z', '--', '.../COMMIT_EDITMSG'), 0, 128, '',
b"fatal: .../COMMIT_EDITMSG: '...' is outside repository at '...'\n")



Related issues : Similar to #777


Test case using docker run --entrypoint sh --rm -it python:3.12 container for example (+ 4.6.0 workaround) :

# Configurations
if ! git config --global --get user.email; then
  git config --global user.email 'you@example.com'
  git config --global user.name 'Your Name'
fi

# Prepare main
mkdir ./main/
cd ./main/
git init
echo '# Main' >./README.md
git add -v ./README.md
git commit -m 'docs(readme): initial commit'
cd ../

# Create submodule1
mkdir ./submodule1/
cd ./submodule1/
git init
echo '# Submodule 1' >./README.md
git add ./README.md
git commit -m 'docs(readme): initial commit'
cd ../

# Create submodule2
mkdir ./submodule2
cd ./submodule2
git init
echo '# Submodule 2' >./README.md
git add ./README.md
git commit -m 'docs(readme): initial commit'
cd ../

# Add submodules
cd ./main/
mkdir ./sources/
git -c protocol.file.allow=always submodule add file://$(pwd)/../submodule1 ./sources/submodule1
git -c protocol.file.allow=always submodule add file://$(pwd)/../submodule2 ./sources/submodule2
git add -v ./sources/submodule1 ./sources/submodule2
git commit -m 'test(sources): add submodule1 and submodule2'
git status
git submodule

# Configure pre-commit in submodule1
cd ./sources/submodule1/
cat >./.pre-commit-config.yaml <<EOF
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: destroyed-symlinks
  - repo: https://github.com/commitizen-tools/commitizen
    rev: v3.29.0
    hooks:
      - id: commitizen
EOF
ls -la
pwd

# Install pre-commit
pip install pre-commit==3.8.0 # latest

# Enable pre-commit
pre-commit install -t commit-msg -t post-checkout -t post-commit -t post-merge -t post-rewrite -t pre-commit -t pre-merge-commit -t pre-push -t pre-rebase -t prepare-commit-msg

# Create commit
git add -v ./.pre-commit-config.yaml
git commit -m 'test(pre-commit): initial configuration'

# Run pre-commit (FAILURE)
pre-commit run -a -v

# Workaround destroyed-symlinks stages
cat >./.pre-commit-config.yaml <<EOF
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: destroyed-symlinks
        stages: [commit, push, manual]
  - repo: https://github.com/commitizen-tools/commitizen
    rev: v3.29.0
    hooks:
      - id: commitizen
EOF

# Run pre-commit (SUCCESS)
pre-commit run -a -v

@asottile
Copy link
Member

we don't do conventional commits here

@AdrianDC AdrianDC force-pushed the destroyed-symlinks branch from 351b6f7 to e13e512 Compare August 22, 2024 20:57
@AdrianDC
Copy link
Contributor Author

we don't do conventional commits here

Thanks for your feedback.

Commit title changed 👍.

@asottile
Copy link
Member

your commit message still doesn't make sense. look at the thing you linked to for inspiration maybe?

@AdrianDC AdrianDC force-pushed the destroyed-symlinks branch from e13e512 to 8100c6c Compare August 22, 2024 21:03
@asottile asottile changed the title fix(pre-commit-hooks): set stages for destroyed-symlinks set stages for destroyed-symlinks Oct 5, 2024
The 'destroyed-symlinks' hook runs upon 'commit-msg' hook,
however when used in 'git submodules', repository scope breaks

> pre_commit_hooks.util.CalledProcessError: (('git', 'status',
> '--porcelain=v2', '-z', '--', '.../COMMIT_EDITMSG'), 0, 128, '',
> b"fatal: .../COMMIT_EDITMSG: '...' is outside repository at '...'\n")
---

Signed-off-by: Adrian DC <radian.dc@gmail.com>
@asottile asottile force-pushed the destroyed-symlinks branch from 8100c6c to c7d1e85 Compare October 5, 2024 18:02
Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile asottile enabled auto-merge October 5, 2024 18:02
@asottile asottile merged commit 515e8b3 into pre-commit:main Oct 5, 2024
6 checks passed
apricote pushed a commit to hetznercloud/fleeting-plugin-hetzner that referenced this pull request Oct 9, 2024
… (hetznercloud/fleeting-plugin-hetzner!125)

This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [pre-commit/pre-commit-hooks](https://github.com/pre-commit/pre-commit-hooks) | repository | major | `v4.6.0` -> `v5.0.0` |

Note: The `pre-commit` manager in Renovate is not supported by the `pre-commit` maintainers or community. Please do not report any problems there, instead [create a Discussion in the Renovate repository](https://github.com/renovatebot/renovate/discussions/new) if you have any questions.

---

### Release Notes

<details>
<summary>pre-commit/pre-commit-hooks (pre-commit/pre-commit-hooks)</summary>

### [`v5.0.0`](https://github.com/pre-commit/pre-commit-hooks/releases/tag/v5.0.0): pre-commit-hooks v5.0.0

[Compare Source](pre-commit/pre-commit-hooks@v4.6.0...v5.0.0)

##### Features

-   `requirements-txt-fixer`: also remove `pkg_resources==...`.
    -   [#&#8203;850](pre-commit/pre-commit-hooks#850) MR by [@&#8203;ericfrederich](https://github.com/ericfrederich).
    -   [#&#8203;1030](pre-commit/pre-commit-hooks#1030) issue by [@&#8203;ericfrederich](https://github.com/ericfrederich).
-   `check-illegal-windows-names`: new hook!
    -   [#&#8203;1044](pre-commit/pre-commit-hooks#1044) MR by [@&#8203;ericfrederich](https://github.com/ericfrederich).
    -   [#&#8203;589](pre-commit/pre-commit-hooks#589) issue by [@&#8203;ericfrederich](https://github.com/ericfrederich).
    -   [#&#8203;1049](pre-commit/pre-commit-hooks#1049) MR by [@&#8203;Jeffrey-Lim](https://github.com/Jeffrey-Lim).
-   `pretty-format-json`: continue processing even if a file has a json error.
    -   [#&#8203;1039](pre-commit/pre-commit-hooks#1039) MR by [@&#8203;amarvin](https://github.com/amarvin).
    -   [#&#8203;1038](pre-commit/pre-commit-hooks#1038) issue by [@&#8203;amarvin](https://github.com/amarvin).

##### Fixes

-   `destroyed-symlinks`: set `stages` to `[pre-commit, pre-push, manual]`
    -   MR [#&#8203;1085](pre-commit/pre-commit-hooks#1085) by [@&#8203;AdrianDC](https://github.com/AdrianDC).

##### Migrating

-   pre-commit-hooks now requires `pre-commit>=3.2.0`.
-   use non-deprecated names for `stages`.
    -   [#&#8203;1093](pre-commit/pre-commit-hooks#1093) MR by [@&#8203;asottile](https://github.com/asottile).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xMTAuMiIsInVwZGF0ZWRJblZlciI6IjM4LjExMC41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants