-
Notifications
You must be signed in to change notification settings - Fork 8
chore(beads): stop the repo hooks failing on clones without lefthook or git-lfs #178
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,32 @@ | ||
| #!/bin/sh | ||
| # Strip Co-Authored-By lines from commit messages | ||
| sed -i.bak '/Co-Authored-By/Id' "$1" | ||
| # Remove trailing blank lines left behind | ||
| sed -i.bak -e :a -e '/^\n*$/{$d;N;ba' -e '}' "$1" | ||
| rm -f "$1.bak" | ||
| #!/usr/bin/env sh | ||
| # Every commit in this repository has one author. Clones that point | ||
| # core.hooksPath at .beads/hooks skip the machine-wide git hooks, so this | ||
| # hook does the one job those had here: it removes Co-Authored-By trailer | ||
| # lines from the commit message. A mention inside a sentence is kept. | ||
| # | ||
| # A message without such a line is never touched. Otherwise the cleaned | ||
| # text goes to a fresh file from mktemp, is compared with a second run, | ||
| # and is renamed over the message only when every step worked; on any | ||
| # failure the message stays as it was and the commit stops. | ||
| msg="$1" | ||
| [ -f "$msg" ] || exit 0 | ||
| case $msg in -*) msg="./$msg" ;; esac | ||
| found=0 | ||
| LC_ALL=C grep -q -i '^[[:space:]]*co-authored-by:' "$msg" || found=$? | ||
| case $found in | ||
| 0) ;; | ||
| 1) exit 0 ;; | ||
| *) echo "commit-msg: cannot read $msg" >&2; exit 1 ;; | ||
| esac | ||
| clean() { | ||
| LC_ALL=C awk 'tolower($0) !~ /^[ \t\r\f\v]*co-authored-by:/ { line[++n] = $0 } | ||
| END { while (n > 0 && line[n] ~ /^[ \t\r\f\v]*$/) n-- | ||
| for (i = 1; i <= n; i++) print line[i] }' < "$msg" | ||
| } | ||
| tmp=$(mktemp "$msg.XXXXXX") || { echo "commit-msg: cannot create a temporary file beside $msg" >&2; exit 1; } | ||
| trap 'rm -f "$tmp"' EXIT | ||
| trap 'exit 1' HUP INT TERM | ||
| clean > "$tmp" && clean | cmp -s - "$tmp" || { echo "commit-msg: cannot rewrite $msg" >&2; exit 1; } | ||
| trap '' HUP INT TERM | ||
| mv -f "$tmp" "$msg" || { echo "commit-msg: cannot replace $msg" >&2; exit 1; } | ||
| exit 0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.