summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-04-05 14:25:08 +0530
committerArun Isaac2022-04-05 14:30:22 +0530
commit4bbaea54a4d549912aa773311cbda9fe659b9c0c (patch)
treeb23f82ab9a029d0dfa2b469219815efb8d58a13d
parent5206de9b15d46d703161565cdb6909bcf5c10f97 (diff)
downloadtissue-4bbaea54a4d549912aa773311cbda9fe659b9c0c.tar.gz
tissue-4bbaea54a4d549912aa773311cbda9fe659b9c0c.tar.lz
tissue-4bbaea54a4d549912aa773311cbda9fe659b9c0c.zip
git: Abstract out `git ls-files'.
* tissue/git.scm: New file. * tissue/issue.scm: Import (tissue git). (issues): Use git-tracked-files.
-rw-r--r--tissue/git.scm30
-rw-r--r--tissue/issue.scm63
2 files changed, 60 insertions, 33 deletions
diff --git a/tissue/git.scm b/tissue/git.scm
new file mode 100644
index 0000000..bd9798d
--- /dev/null
+++ b/tissue/git.scm
@@ -0,0 +1,30 @@
+;;; tissue --- Text based issue tracker
+;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of tissue.
+;;;
+;;; tissue is free software: you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; tissue is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with tissue. If not, see <https://www.gnu.org/licenses/>.
+
+(define-module (tissue git)
+ #:use-module (rnrs io ports)
+ #:use-module (srfi srfi-26)
+ #:use-module (srfi srfi-171)
+ #:use-module (tissue utils)
+ #:export (git-tracked-files))
+
+(define (git-tracked-files)
+ "Return a list of all files tracked in the current git repository."
+ (call-with-input-pipe
+ (cut port-transduce (tmap identity) rcons get-line <>)
+ "git" "ls-files"))
diff --git a/tissue/issue.scm b/tissue/issue.scm
index 100ce64..f7dcef9 100644
--- a/tissue/issue.scm
+++ b/tissue/issue.scm
@@ -27,6 +27,7 @@
#:use-module (srfi srfi-171)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
+ #:use-module (tissue git)
#:use-module (tissue utils)
#:export (%aliases
issue
@@ -266,39 +267,35 @@ in (tissue tissue). If no alias is found, NAME is returned as such."
;; Get all gemini files except README.gmi and hidden files. Text
;; editors tend to create hidden files while editing, and we want to
;; avoid them.
- (sort (call-with-input-pipe
- (lambda (port)
- (port-transduce
- (tfilter-map (lambda (file)
- (and (string-suffix? ".gmi" file)
- (not (string=? (basename file) "README.gmi"))
- (not (string-prefix? "." (basename file)))
- (let* ((file-details (file-details file))
- ;; Downcase keywords to make
- ;; them case-insensitive.
- (all-keywords (map string-downcase
- (hashtable-ref file-details 'keywords '()))))
- (issue file
- ;; Fallback to filename if title has no alphabetic
- ;; characters.
- (let ((title (hashtable-ref file-details 'title "")))
- (if (string-any char-set:letter title) title file))
- (hashtable-ref file-details 'creator #f)
- (hashtable-ref file-details 'created-date #f)
- (hashtable-ref file-details 'created-relative-date #f)
- (hashtable-ref file-details 'last-updater #f)
- (hashtable-ref file-details 'last-updated-date #f)
- (hashtable-ref file-details 'last-updated-relative-date #f)
- (hashtable-ref file-details 'assigned '())
- ;; "closed" is a special keyword to indicate
- ;; the open/closed status of an issue.
- (delete "closed" all-keywords)
- (not (member "closed" all-keywords))
- (hashtable-ref file-details 'tasks 0)
- (hashtable-ref file-details 'completed-tasks 0)
- (hashtable-ref file-details 'posts #f))))))
- rcons get-line port))
- "git" "ls-files")
+ (sort (filter-map (lambda (file)
+ (and (string-suffix? ".gmi" file)
+ (not (string=? (basename file) "README.gmi"))
+ (not (string-prefix? "." (basename file)))
+ (let* ((file-details (file-details file))
+ ;; Downcase keywords to make them
+ ;; case-insensitive.
+ (all-keywords (map string-downcase
+ (hashtable-ref file-details 'keywords '()))))
+ (issue file
+ ;; Fallback to filename if title has no alphabetic
+ ;; characters.
+ (let ((title (hashtable-ref file-details 'title "")))
+ (if (string-any char-set:letter title) title file))
+ (hashtable-ref file-details 'creator #f)
+ (hashtable-ref file-details 'created-date #f)
+ (hashtable-ref file-details 'created-relative-date #f)
+ (hashtable-ref file-details 'last-updater #f)
+ (hashtable-ref file-details 'last-updated-date #f)
+ (hashtable-ref file-details 'last-updated-relative-date #f)
+ (hashtable-ref file-details 'assigned '())
+ ;; "closed" is a special keyword to indicate
+ ;; the open/closed status of an issue.
+ (delete "closed" all-keywords)
+ (not (member "closed" all-keywords))
+ (hashtable-ref file-details 'tasks 0)
+ (hashtable-ref file-details 'completed-tasks 0)
+ (hashtable-ref file-details 'posts #f)))))
+ (git-tracked-files))
(lambda (issue1 issue2)
(time<? (date->time-monotonic (issue-created-date issue1))
(date->time-monotonic (issue-created-date issue2))))))))