]> Sergey Matveev's repositories - schwabrak.git/commitdiff
Get rid of created file
authorSergey Matveev <stargrave@stargrave.org>
Fri, 17 May 2024 09:36:53 +0000 (12:36 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 17 May 2024 09:36:53 +0000 (12:36 +0300)
README
add
cd
comment
lib.zsh.rc
list
recfile-export
recfile-export-all
show

diff --git a/README b/README
index c536bf82e172d7ef1800f863426d4c4b78ee205297f58e2ea9d78189b3497643..e87c7392481d7a5312c45e63a4fec84b1e887484ad3717c5d588ece5f4646d74 100644 (file)
--- a/README
+++ b/README
@@ -23,19 +23,13 @@ Basically schwabrak is mainly about a convention how to keep issues in
 files, loosely similar to https://github.com/driusan/PoormanIssueTracker,
 from which I borrowed idea of replacing spaces with dashes in issue names.
 
-Issues are kept in the issues/ directory. Each issue can be a part of
-projects hierarchy: main-project/sub-proj/issue-name. Directory's name
-is the issue's brief name. Dashes should be interpreted as spaces and
-n > 1 dashes should be interpreted as n-1 dashes when converting the
-directory name to a human readable issue title, as PoormanIssueTracker
-suggests. The "about" file contains the description of the issue. The
-"result" (initially empty) contains the closed issue resolution
-information.
-
-The "created" issue's file contains the datetime it was created. It is
-used to help sort issues by date. Unfortunately Git does not keep and
-restore mtimes, which would probably eliminate the need of separate
-files with the timestamps.
+Issues are kept in the issues/ directory. Directory's name is the
+issue's brief name, prepended with datetime for sorting purposes. Dashes
+should be interpreted as spaces and n > 1 dashes should be interpreted
+as n-1 dashes when converting the directory name to a human readable
+issue title, as PoormanIssueTracker suggests. The "about" file contains
+the description of the issue. The "result" (initially empty) contains
+the closed issue resolution information.
 
 Each issue can have attached tags. For keeping their set in consistent
 well-defined state, the tags/ directory above the issues/ contains
@@ -50,6 +44,8 @@ It is your choice how to name and deal with them. Want to find all
 issues in done state? for i (issues/**/tags/status:done) print $i:h:h.
 This kind of information are all just enumerations.
 
+Project's name is expected to be "proj:NAME" tag for example.
+
 The deps/ subdirectory in each issue can contain symbolic links to
 another issues, referencing it. Create another kind of links between
 them as you wish.
@@ -68,7 +64,7 @@ The "comment" issue's file is intended to keep the last comment related to
 the issue. By committing it you automatically accompany it with your
 (commit's author) name and the time it was added.
 
-    $ cat > issues/issues-name/comment <<EOF
+    $ cat >issues/issues-name/comment <<EOF
     Here are my thoughts:
     * bla bla bla
     EOF
@@ -87,12 +83,12 @@ able to quickly call commands from it:
 
     $ hash -d s=~/work/schwabrak
     $ cd my/issues
-    $ ~s/add proj/issue name to create
+    $ ~s/add issue name to create
 
-To ease the creation of the new issue's directory structure, you can
-use "add" command as seen above. And yes, it is intended that
-"proj/issue" and "name", "to", "create" can be passed as separate
-arguments, but proj/issue-name-to-create will be created as expected.
+To ease the creation of the new issue's directory structure, you can use
+"add" command as seen above. And yes, it is intended that "issue" and
+"name", "to", "create" can be passed as separate arguments, but
+proj/issue-name-to-create will be created as expected.
 
 All utilities strip off possible "issues/" prefix from the issues
 name, so you can easily complete issue names with something like fzf.
diff --git a/add b/add
index 98442ec8d3c690d74a9e1ef824776b107226b864a31f51ea02c69394019acdeb..e99b94af7381a9cfd801eac9bd1e385974abfc0eb9db9bb52d7a3dacf45becd0 100755 (executable)
--- a/add
+++ b/add
@@ -7,10 +7,10 @@ name="$@"
 name=${name#issues/}
 name=$name:h/`print -- $name:t | endash`
 name=${name#./}
+date -u +"%Y-%m-%dT%H:%M:%S" | read created
+name=$created-$name
 print $name
-mkdir issues/$name
-mkdir issues/$name/tags
-date -u +"%Y-%m-%d %H:%M:%S" > issues/$name/created
+mkdir -p issues/$name/tags
 touch issues/$name/about issues/$name/result issues/$name/comment
 $EDITOR issues/$name/about
 git add issues/$name
diff --git a/cd b/cd
index 05193248aa7901a61e75449f7bb3c815c129bbbdd1d248377bb93feaadd3e2be..09cc64fb43f863bf99be65a1ee6f181b1541cd177adbd0f5a9fce2d6d8db65a8 100755 (executable)
--- a/cd
+++ b/cd
@@ -3,5 +3,5 @@
 root=$0:h:a
 . $root/lib.zsh.rc
 
-$root/list | fzf --ansi -d "\t" --tac --preview="$root/show {2}" | cut -f2 | read d
+$root/list | fzf --ansi --tac --preview="$root/show {1}" | cut -f2 | read d
 print issues/$d
diff --git a/comment b/comment
index 3b4e3de682168683d8f3dfac150655adcb041c35bbb1a52bebaa62d951963f81..7f990ed31ec2f2789980fa5addc9bcea7aa85f94d48108186e548c7780bef16b 100755 (executable)
--- a/comment
+++ b/comment
@@ -13,7 +13,7 @@ comment=issues/$issue/comment
 
 local tmp=`mktemp`
 trap "rm -f $tmp" HUP PIPE INT QUIT TERM EXIT
-{ $PERL -npe 's/^/# /' < $comment ; print } > $tmp
+{ $PERL -npe 's/^/# /' <$comment ; print } >$tmp
 zmodload -F zsh/stat b:zstat
 zstat -A ctimePrev +ctime $tmp
 $EDITOR $tmp
@@ -23,8 +23,8 @@ zstat -A ctime +ctime $tmp
     exit 0
 }
 if [[ -s $comment ]]; then
-    $PERL -ne 'print if $can; if (/^$/) { $can=1 };' < $tmp > $comment
+    $PERL -ne 'print if $can; if (/^$/) { $can=1 };' <$tmp >$comment
 else
-    cat < $tmp > $comment
+    cat <$tmp >$comment
 fi
 git add $comment
index 09e19535e0ac16400b1f0df655461323afee5d43842162faf0f2b60f3eab3260..f00593f142b68987db23f198857e86763bb12dcad47d2260ff095b4b4b58b5c5 100644 (file)
@@ -20,6 +20,11 @@ dedash() {
     $PERL -npe 's/([^-])-([^-])/$1 $2/g ; s/-(-+)/$1/g'
 }
 
+split-issue() {
+    local cols=(${(s/-/)1})
+    REPLY=("${cols[1]}-${cols[2]}-${cols[3]:s/T/ /}" ${(j/-/)cols[4,-1]})
+}
+
 # Usage: colourise ColourSpec:RegExp [ColourSpec:RegExp ...]
 # It is intended to be a drop-in replacement for supercat utility.
 # ColourSpec is comma delimited list of ANSI codes for colour setting.
diff --git a/list b/list
index 334b772496aa926c368c99ec42ac1be96485048c288cfb4b1ae2ef03b44e3feb..f60ae626436d6a87f0e5a8bfe03dfca808af6e262883a17a810d71b73a9b688e 100755 (executable)
--- a/list
+++ b/list
@@ -33,14 +33,14 @@ tagsSatisfied() {
     }
 }
 
-for issue (issues/**/created) {
-    issue=$issue:h
+for issue (issues/*(On)) {
+    issue=$issue:t
     issue=${issue#issues/}
 
     tagsTheir=(`$root/tag-list $issue`)
     tagsSatisfied $tagsTheir || continue
 
-    print -n `cat issues/$issue/created`\\t$issue\\t
+    print -n $issue "| "
     print $tagsTheir
 } | sort -r |
-colourise green:"^.{19}" cyan:"        .+      " red:"proj:[^ ]+"
+colourise green:"^.{19}" bg-cyan:"\|" red:"proj:[^ ]+"
index 2d5f07083e660529eec731158cd7a871165ad41865b7d0491cb7570da36edf6d..b4aed74dc1e5f19d51ebb5d3cec0546c45432b6937530f9dffbec66850bdbb46 100755 (executable)
@@ -4,18 +4,20 @@ root=$0:h:a
 . $root/lib.zsh.rc
 
 issue=${1#issues/}
-print Created: `cat issues/$issue/created`
+split-issue $issue
+created=${REPLY[1]}
+name=${REPLY[2]}
 print Issue: $issue
-print Project: $issue:h
-print Name: `print $issue:t | dedash`
+print Created: $created
+print Name: `print $name | dedash`
 for tag (`$root/tag-list $issue`) print Tag: $tag
 for dep (issues/$issue/deps/*(N)) {
     _dep=$(relative $(realpath $dep))
     print Depends: ${_dep#issues/}
 }
 print About:
-sed "s/^/+ /" < issues/$issue/about
+sed "s/^/+ /" <issues/$issue/about
 print Result:
-sed "s/^/+ /" < issues/$issue/result
+sed "s/^/+ /" <issues/$issue/result
 print Comments:
 NO_COLOR=1 $root/comment-list $issue | sed "s/^/+ /"
index df1f8efa5d804768ad49eac0997e920f1b8ecdf54c8e5014b6c7fa04736b378c..1e79dacffd5b47f7843c0130b0fcced99eed0e8821d09f4a8276cc629173f154 100755 (executable)
@@ -3,9 +3,7 @@
 root=$0:h:a
 . $root/lib.zsh.rc
 
-NO_COLOR=1 $root/list | while read line ; do
-    line=(${=line})
-    issue=${line[3]}
+for issue (issues/*(On)) {
     $root/recfile-export $issue
     print
-done
+}
diff --git a/show b/show
index 45b6a93372da51c42982ad6dec3adeca0035058ea0ef37c233326284544e9074..59a483a0b7c1a667bb254f9fdddcf7b08c05f658ccb4a37de489f5bf9abd621a 100755 (executable)
--- a/show
+++ b/show
@@ -4,8 +4,10 @@ root=$0:h:a
 . $root/lib.zsh.rc
 
 issue=${1#issues/}
-print $issue:h | colourise red:".*" | read proj
-print `cat issues/$issue/created` \| $proj/`print $issue:t | dedash`
+split-issue $issue
+created=${REPLY[1]}
+name=${REPLY[2]}
+print $created \| `print $name | dedash`
 $root/tag-list $issue | colourise cyan:".*"
 deps=(issues/$issue/deps/*(N))
 [[ ${#deps} -eq 0 ]] || {