-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11585 from keymanapp/change/common/git-commit-hooks
change(common): add extra commit message hints
- Loading branch information
Showing
3 changed files
with
76 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# This commit-msg hook validates commit messages | ||
|
@@ -49,15 +49,18 @@ fi | |
# Test the repository upstream/origin: ignore if not keymanapp/keyman | ||
# | ||
|
||
if ! (git remote -v | grep -E "origin|upstream" | grep -q "keymanapp/"); then | ||
GIT_ORIGIN="$(git remote get-url origin)" | ||
|
||
if [[ ! "$GIT_ORIGIN" =~ github\.com/keymanapp ]]; then | ||
# Not a Keyman repository. We have no opinion. | ||
# echo "Not a Keyman repository. We don't care" | ||
# echo "DEBUG: Not a Keyman repository. We don't care" | ||
exit 0 | ||
fi | ||
|
||
if (git remote -v | grep -E "origin|upstream" | grep -Eq "keyboards|lexical-models"); then | ||
|
||
if [[ "$GIT_ORIGIN" =~ keyboards|lexical-models ]]; then | ||
# We don't enforce commit messages on keyboards or lexical-models repositories | ||
# echo "Keyboards or Lexical-Models. We still don't care." | ||
# echo "DEBUG: Keyboards or Lexical-Models. We still don't care." | ||
exit 0 | ||
fi | ||
|
||
|
@@ -106,11 +109,18 @@ function print_error() { | |
echo -e "Valid scopes: ${t_grn}${scopes[@]}${t_end}" | ||
echo -e "Max length (first line): ${t_grn}$max_length${t_end}" | ||
echo -e "Min length (first line): ${t_grn}$min_length${t_end}" | ||
echo -e "Optionally, append ${t_grn}Fixes #1234${t_end}\n" | ||
echo -e "${t_cyn}Example:${t_end} fix(windows): Re-attaches the widget plug which had fallen out. Fixes #1111" | ||
echo -e "If possible, append git trailers:" | ||
echo -e " * ${t_grn}Fixes: #1234${t_end}" | ||
echo -e " * ${t_grn}Fixes: KEYMAN-MODULE-XYZ${t_end}" | ||
echo -e " * ${t_grn}Cherry-pick-of: #2468${t_end}" | ||
echo -e " * ${t_grn}Co-authored-by: Firstname Lastname <[email protected]>${t_end}" | ||
echo -e "${t_cyn}Example:${t_end} fix(windows): Re-attach the widget plug which had fallen out" | ||
echo -e "${t_cyn}Reference${t_end}: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes" | ||
echo -e "" | ||
echo -e "Tips: Don't include a period at the end of the first line; best to put 'Fixes #1111' on a line of its own." | ||
echo -e "Tips: " | ||
echo -e " * Don't include a period at the end of the title" | ||
echo -e " * Always include a blank line before trailers" | ||
echo -e " * Use imperative, present tense ('attach' instead of 'attaches', 'attached' etc)" | ||
echo -e "" | ||
echo -e "This script: $0" | ||
} | ||
|
This file contains 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 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