From: Sergey Matveev Date: Wed, 20 Mar 2024 18:16:41 +0000 (+0300) Subject: Convenient commenting X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=d95f4ce2de1a915570bb27ee6cfd34bf3dd3eda43bc6ffba9ddb4a0e2a0a0943;p=schwabrak.git Convenient commenting --- diff --git a/README b/README index 28f7576..c536bf8 100644 --- 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 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