Add a script to create standard commit messages in my book tracker
- ID
6149bb5- date
2024-01-09 20:51:38+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
a80f027- message
Add a script to create standard commit messages in my book tracker- changed files
2 files, 34 additions, 1 deletion
Changed files
textexpander/README.md (3269) → textexpander/README.md (3719)
diff --git a/textexpander/README.md b/textexpander/README.md
index faec927..f59df1f 100644
--- a/textexpander/README.md
+++ b/textexpander/README.md
@@ -24,6 +24,12 @@ scripts = [
"""
},
{
+ "name": "create_books_commit_message",
+ "description": """
+ create a commit message for when I'm adding new books to my book tracker.
+ """
+ },
+ {
"name": "get_mastodon_text.py",
"description": """
print a Markdown-formatted blockquote of a Mastodon I've got open in Safari, suitable for saving in Obsidian
@@ -68,6 +74,15 @@ cog_helpers.create_description_table(
</dd>
<dt>
+ <a href="https://github.com/alexwlchan/scripts/blob/main/textexpander/create_books_commit_message">
+ <code>create_books_commit_message</code>
+ </a>
+ </dt>
+ <dd>
+ create a commit message for when I'm adding new books to my book tracker.
+ </dd>
+
+ <dt>
<a href="https://github.com/alexwlchan/scripts/blob/main/textexpander/get_mastodon_text.py">
<code>get_mastodon_text.py</code>
</a>
@@ -104,4 +119,4 @@ cog_helpers.create_description_table(
get URL and first paragraph of a Wikipedia entry I have open in Safari, suitable for saving in Obsidian.
</dd>
</dl>
-<!-- [[[end]]] (checksum: 24db92a20bd6747bf2e7768f276dc414) -->
+<!-- [[[end]]] (checksum: ad35004c0b69b4421e1d303061102eb9) -->
textexpander/create_books_commit_message (0) → textexpander/create_books_commit_message (622)
diff --git a/textexpander/create_books_commit_message b/textexpander/create_books_commit_message
new file mode 100755
index 0000000..ca8f0fe
--- /dev/null
+++ b/textexpander/create_books_commit_message
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+# When I add an entry to my book tracker, I typically commit two files:
+#
+# - the Markdown file containing my review
+# - the image of the book's cover
+#
+# This script looks at the currently staged files, works out the title
+# of the book I just reviewed, and creates a commit message for my
+# Git commit.
+
+set -o errexit
+set -o nounset
+
+pushd ~/repos/books.alexwlchan.net >/dev/null
+ markdown_file=$(git diff --cached --name-only | grep ".md$" | head -n 1)
+ title=$(grep 'title:' "$markdown_file" | head -n 1 | sed 's/^ *title: *//')
+ echo -n "Create entry for \"$title\""
+popd >/dev/null