]> Sergey Matveev's repositories - schwabrak.git/blob - comment
a2fc9e4193cd891d6e79d5e9b13cdbf589516d6fd1805b401cca25c58d3ccf79
[schwabrak.git] / comment
1 #!/usr/bin/env zsh
2
3 root=$0:h:a
4 . $root/lib.zsh.rc
5
6 usage() {
7     die Usage: $0 ISSUE
8 }
9
10 [[ -n $1 ]] || usage
11 issue=${1#issues/}
12 comment=issues/$issue/comment
13
14 $PERL -i -npe 's/^/# /' $comment
15 zmodload -F zsh/stat b:zstat
16 zstat -A ctimePrev +ctime $comment
17 $EDITOR $comment
18 zstat -A ctime +ctime $comment
19 [[ $ctime != $ctimePrev ]] || {
20     echo Aborting comment >&2
21     $PERL -i -npe 's/^# //' $comment
22     exit 0
23 }
24 $PERL -i -ne 'print if $can; if (/^$/) { $can=1 };' $comment
25 git add $comment