summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-03-14 08:21:51 +0300
committerArun Isaac2022-03-14 13:35:45 +0530
commit001c55e00c194928ea1027c857be3ae154074e15 (patch)
tree161642bda1dd67e93f1a42a3af54ea22c77db5de
parent9ccc8f8f1d0732a6716a569fa05854d6fc2c23c3 (diff)
downloadtissue-001c55e00c194928ea1027c857be3ae154074e15.tar.gz
tissue-001c55e00c194928ea1027c857be3ae154074e15.tar.lz
tissue-001c55e00c194928ea1027c857be3ae154074e15.zip
tissue: Ignore missing files when listing issues.
tissue would fail to list issues and throw an exception when a user deletes a file, or renames a file, but has not committed the changes to the issue tracker. This commit simply ignores such deletions and renames, and lists out the other issues that have not changed. * tissue/issue.scm (file-details): Read the file only if it exists. Signed-off-by: Arun Isaac <arunisaac@systemreboot.net>
-rw-r--r--tissue/issue.scm118
1 files changed, 61 insertions, 57 deletions
diff --git a/tissue/issue.scm b/tissue/issue.scm
index 8281588..262e327 100644
--- a/tissue/issue.scm
+++ b/tissue/issue.scm
@@ -1,5 +1,6 @@
;;; tissue --- Text based issue tracker
;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2022 Frederick Muriuki Muriithi <fredmanglis@gmail.com>
;;;
;;; This file is part of tissue.
;;;
@@ -83,63 +84,66 @@ strings, and return them as a list."
(define (file-details file)
"Return a hashtable of details extracted from gemini FILE."
(let ((result (make-eq-hashtable)))
- (call-with-input-file file
- (lambda (port)
- (port-transduce (tmap (lambda (line)
- (cond
- ;; Lists with the assigned: prefix
- ;; specify assignees.
- ((string-prefix? "* assigned:" line)
- (hashtable-append! result 'assigned
- (comma-split
- (remove-prefix "* assigned:" line))))
- ;; Lists with the keywords: prefix
- ;; specify keywords.
- ((string-prefix? "* keywords:" line)
- (hashtable-append! result 'keywords
- (comma-split
- (remove-prefix "* keywords:" line))))
- ;; A more fuzzy heuristic to find keywords
- ((and (string-prefix? "* " line)
- ;; Is every comma-separated
- ;; element two words utmost?
- (every (lambda (element)
- (<= (length
- (string-split element #\space))
- 2))
- (comma-split (remove-prefix "* " line)))
- ;; Does any comma-separated
- ;; element contain a potential
- ;; keyword?
- (any (lambda (element)
- (any (lambda (keyword)
- (string-contains element keyword))
- (list "request" "bug" "critical"
- "enhancement" "progress"
- "testing" "later" "documentation"
- "help" "closed")))
- (comma-split (remove-prefix "* " line))))
- (hashtable-append! result 'keywords
- (comma-split
- (remove-prefix "* " line))))
- ;; Checkbox lists are tasks. If the
- ;; checkbox has any character other
- ;; than space in it, the task is
- ;; completed.
- ((string-match "\\* \\[(.)\\]" line)
- => (lambda (m)
- (hashtable-update! result 'tasks 1+ 0)
- (unless (string=? (match:substring m 1) " ")
- (hashtable-update! result 'completed-tasks 1+ 0))))
- ;; The first level one heading is the
- ;; title.
- ((string-prefix? "# " line)
- (unless (hashtable-contains? result 'title)
- (hashtable-set! result 'title
- (remove-prefix "# " line)))))))
- (const #t)
- get-line-dos-or-unix
- port)))
+ ;; Files may be renamed or deleted, but not committed. Therefore,
+ ;; only read the file if it exists.
+ (when (file-exists? file)
+ (call-with-input-file file
+ (lambda (port)
+ (port-transduce (tmap (lambda (line)
+ (cond
+ ;; Lists with the assigned: prefix
+ ;; specify assignees.
+ ((string-prefix? "* assigned:" line)
+ (hashtable-append! result 'assigned
+ (comma-split
+ (remove-prefix "* assigned:" line))))
+ ;; Lists with the keywords: prefix
+ ;; specify keywords.
+ ((string-prefix? "* keywords:" line)
+ (hashtable-append! result 'keywords
+ (comma-split
+ (remove-prefix "* keywords:" line))))
+ ;; A more fuzzy heuristic to find keywords
+ ((and (string-prefix? "* " line)
+ ;; Is every comma-separated
+ ;; element two words utmost?
+ (every (lambda (element)
+ (<= (length
+ (string-split element #\space))
+ 2))
+ (comma-split (remove-prefix "* " line)))
+ ;; Does any comma-separated
+ ;; element contain a potential
+ ;; keyword?
+ (any (lambda (element)
+ (any (lambda (keyword)
+ (string-contains element keyword))
+ (list "request" "bug" "critical"
+ "enhancement" "progress"
+ "testing" "later" "documentation"
+ "help" "closed")))
+ (comma-split (remove-prefix "* " line))))
+ (hashtable-append! result 'keywords
+ (comma-split
+ (remove-prefix "* " line))))
+ ;; Checkbox lists are tasks. If the
+ ;; checkbox has any character other
+ ;; than space in it, the task is
+ ;; completed.
+ ((string-match "\\* \\[(.)\\]" line)
+ => (lambda (m)
+ (hashtable-update! result 'tasks 1+ 0)
+ (unless (string=? (match:substring m 1) " ")
+ (hashtable-update! result 'completed-tasks 1+ 0))))
+ ;; The first level one heading is the
+ ;; title.
+ ((string-prefix? "# " line)
+ (unless (hashtable-contains? result 'title)
+ (hashtable-set! result 'title
+ (remove-prefix "# " line)))))))
+ (const #t)
+ get-line-dos-or-unix
+ port))))
(call-with-input-pipe
(lambda (port)
(hashtable-set!