Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F97153684
D30158.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D30158.diff
View Options
diff --git a/.hooks/prepare-commit-msg b/.hooks/prepare-commit-msg
--- a/.hooks/prepare-commit-msg
+++ b/.hooks/prepare-commit-msg
@@ -3,7 +3,8 @@
# prepare-commit-msg: Prepare a commit message upon `git commit` for the
# user to edit. A script (rather than a static template) is used, so
# that we can insert our template text other than at the top of the
-# message.
+# message. Aims to automatically detect which ports were affected
+# and suggests a commit title.
#
# Install by either setting the configuration of the repository to:
# git config --add core.hooksPath .hooks
@@ -27,6 +28,42 @@
outfile=$(mktemp /tmp/freebsd-git-commit.XXXXXXXX)
+if git rev-parse --verify HEAD >/dev/null 2>&1
+then
+ against=HEAD
+else
+ # Initial commit: diff against an empty tree object
+ against=$(git hash-object -t tree /dev/null)
+fi
+
+PORTS=""
+
+# only determine changed ports if we're not called for amend
+if [ -z "$3" ]; then
+ FILES=$(git diff-index --name-only --cached \
+ --diff-filter=ACMR $against -- )
+ for f in $FILES; do
+ port=$(dirname $f | egrep "^[a-z]+/[^[:space:]]+$" \
+ | awk -F/ '{ print $1"/"$2 }')
+ if [ -n "$port" ]; then
+ PORTS="${PORTS} $port"
+ fi
+ done
+fi
+
+if [ -n "$PORTS" ]; then
+ portslist=$(echo $PORTS | tr " " "\n" | sort | uniq)
+ portsnum=$(echo "$portslist" | wc -l)
+ affected_ports=$(echo $(echo "$portslist" | head -n2) \
+ | sed "s/ /, /g")
+ if [ "$portsnum" -gt 2 ]; then
+ affected_ports="$affected_ports, and $(($portsnum - 2)) more"
+ fi
+ firstline="# Uncomment and add a short description of what changed:
+# $(echo $affected_ports):$(echo " ")
+"
+fi
+
# Create a commit message template from three parts:
#
# 1. The beginning of the git-provided template (up to the first comment-only
@@ -39,7 +76,7 @@
# not staged, and untracked files.
cat >"$outfile" <<EOF
-$(awk '1;/^#$/{exit}' "$1")
+$firstline$(awk '1;/^#$/{exit}' "$1")
# category/port: Subject goes here, max 50 cols -|
# <then a blank line>
# 72 columns --|
diff --git a/.arcconfig b/.arcconfig
--- a/.arcconfig
+++ b/.arcconfig
@@ -1,4 +1,5 @@
{
- "repository.callsign" : "P",
- "phabricator.uri" : "https://reviews.freebsd.org/"
+ "phabricator.uri" : "https://reviews.freebsd.org/",
+ "arc.land.onto.default": "main",
+ "arc.land.onto": ["main"]
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Sep 28, 11:21 PM (21 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
13077720
Default Alt Text
D30158.diff (2 KB)
Attached To
Mode
D30158: Suggest commit title in prepare-commit-msg hook
Attached
Detach File
Event Timeline
Log In to Comment