]> Sergey Matveev's repositories - schwabrak.git/commitdiff
Convenient commenting
authorSergey Matveev <stargrave@stargrave.org>
Wed, 20 Mar 2024 18:16:41 +0000 (21:16 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 20 Mar 2024 18:16:41 +0000 (21:16 +0300)
README
comment [new file with mode: 0755]

diff --git a/README b/README
index 28f75762e3d6344f7851bc3653bf5caae74a6405e1e7c7b3bb3986e83566c4ab..c536bf82e172d7ef1800f863426d4c4b78ee205297f58e2ea9d78189b3497643 100644 (file)
--- a/README
+++ b/README
@@ -115,6 +115,7 @@ issue's set.
 "tag-add issue [tags/]tag" adds a tag, as was noticed before.
 "dep-add issue-dst issue-src" will link issue-src in issues-dst's deps/.
 "show issue" shows most of issue's information in human friendly way.
+"comment" allows you to conveniently add comment.
 
 comment-list, recfile-export and recfile-export-all produces
 recutils'es compatible recfile output, which is machine friendlier.
diff --git a/comment b/comment
new file mode 100755 (executable)
index 0000000..12c953d
--- /dev/null
+++ b/comment
@@ -0,0 +1,25 @@
+#!/usr/bin/env zsh
+
+root=$0:h:a
+. $root/lib.zsh.rc
+
+usage() {
+    die Usage: $0 ISSUE
+}
+
+[[ -n $1 ]] || usage
+issue=${1#issues/}
+comment=issues/$issue/comment
+
+perl -i -npe 's/^/# /' $comment
+zmodload -F zsh/stat b:zstat
+zstat -A ctimePrev +ctime $comment
+$EDITOR $comment
+zstat -A ctime +ctime $comment
+[[ $ctime != $ctimePrev ]] || {
+    echo Aborting comment >&2
+    perl -i -npe 's/^# //' $comment
+    exit 0
+}
+perl -i -ne 'print if $can; if (/^$/) { $can=1 };' $comment
+git add $comment