Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/internals/contributing/committing-code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ The ``scripts/prepare_commit_msg.py`` Python script can be installed as a
``prepare-commit-msg`` git hook. It automatically adds the ``[A.B.x]`` prefix
to the subject line, appends ``Backport of <sha> from main.`` to the commit
body, and ensures the subject line ends with a period, even when the
cherry-pick produces conflicts. To install it, create an executable file
``.git/hooks/prepare-commit-msg`` containing:
cherry-pick produces conflicts. Copy the script from the main branch, and
install it as the hook:

.. code-block:: sh

#!/bin/sh
exec python scripts/prepare_commit_msg.py "$@"
cp scripts/prepare_commit_msg.py .git/hooks/prepare-commit-msg
chmod +x .git/hooks/prepare-commit-msg

Once installed, a plain ``git cherry-pick <sha>`` on a stable branch is
sufficient; the hook handles the message formatting in all cases.
Expand Down
10 changes: 6 additions & 4 deletions scripts/prepare_commit_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
- Adds "Backport of <sha> from main." when cherry-picking.
To install:
1. Ensure the folder `.git/hooks` exists.
2. Create an executable file `.git/hooks/prepare-commit-msg` with content:
1. Check out a trusted branch (main).
2. Copy this script into the hooks directory:
#!/bin/sh
exec python scripts/prepare_commit_msg.py "$@"
cp scripts/prepare_commit_msg.py .git/hooks/prepare-commit-msg
chmod +x .git/hooks/prepare-commit-msg
Repeat the installation from main to update the hook.
"""

Expand Down
Loading