From 0864d73e2ed3724d33ff4d1cdaf4fe7f48ae050c2021fd9caf74d916094a73f9 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Fri, 17 May 2024 12:36:53 +0300 Subject: [PATCH] Get rid of created file --- README | 34 +++++++++++++++------------------- add | 6 +++--- cd | 2 +- comment | 6 +++--- lib.zsh.rc | 5 +++++ list | 8 ++++---- recfile-export | 12 +++++++----- recfile-export-all | 6 ++---- show | 6 ++++-- 9 files changed, 44 insertions(+), 41 deletions(-) diff --git a/README b/README index c536bf8..e87c739 100644 --- 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 <issues/issues-name/comment < 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 0519324..09cc64f 100755 --- 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 3b4e3de..7f990ed 100755 --- 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 diff --git a/lib.zsh.rc b/lib.zsh.rc index 09e1953..f00593f 100644 --- a/lib.zsh.rc +++ b/lib.zsh.rc @@ -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 334b772..f60ae62 100755 --- 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:[^ ]+" diff --git a/recfile-export b/recfile-export index 2d5f070..b4aed74 100755 --- a/recfile-export +++ b/recfile-export @@ -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/^/+ /"