summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2020-02-16 04:50:47 +0000
committerbrian m. carlson <sandals@crustytoothpaste.net>2020-02-16 04:50:47 +0000
commit64d1e47c9772df68864ba0345e9511b87d1be8bc (patch)
tree747940414ff0e531f502e188b14af21bff3a8545
parentf1c8ec1fb79c3e4fdb86ba9c0e6c42e1a88ac135 (diff)
bin: add a script to format commit message bodies
When writing a commit message, it's good form to wrap one's lines at 72 characters. However, the GitHub web interface preserves newlines, so if a commit message is entered there, these newlines will be preserved, leading to ugly formatting. Add a script to wrap the output the body (but not the summary) of a given commit using format-text so it can be pasted nicely into the GitHub web interface. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
-rwxr-xr-xbin/git-format-text14
1 files changed, 14 insertions, 0 deletions
diff --git a/bin/git-format-text b/bin/git-format-text
new file mode 100755
index 0000000..e6f9ca0
--- /dev/null
+++ b/bin/git-format-text
@@ -0,0 +1,14 @@
+#!/bin/sh
+#
+#/ git-format-text COMMIT
+#/
+#/ Formats the body of the Git commit log message for the given commit, removing
+#/ newlines within a paragraph.
+
+if [ "$1" = "--help" ]
+then
+ grep "^#/" "$0" | cut -b4-
+ exit 0
+fi
+
+exec git log -1 --format="%b" | format-text