diff options
author | Arun Isaac | 2022-07-20 16:25:08 +0530 |
---|---|---|
committer | Arun Isaac | 2022-07-20 16:32:56 +0530 |
commit | 3ccf00c699de35d409bf8152d16617f54f97e4f1 (patch) | |
tree | b542d6fb9e9d9b36e6eeebd49f4ef0579d4287a9 | |
parent | 8ec2730db7031a05d63f59ba7080f13da9677d2d (diff) | |
download | tissue-3ccf00c699de35d409bf8152d16617f54f97e4f1.tar.gz tissue-3ccf00c699de35d409bf8152d16617f54f97e4f1.tar.lz tissue-3ccf00c699de35d409bf8152d16617f54f97e4f1.zip |
git: Add git-tracked-file? utility.
* tissue/git.scm: Import (rnrs exceptions).
(git-tracked-file?): New public function.
-rw-r--r-- | tissue/git.scm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tissue/git.scm b/tissue/git.scm index 1f6c0ef..166ebd3 100644 --- a/tissue/git.scm +++ b/tissue/git.scm @@ -19,6 +19,7 @@ (define-module (tissue git) #:use-module (rnrs arithmetic bitwise) #:use-module (rnrs conditions) + #:use-module (rnrs exceptions) #:use-module (rnrs hashtables) #:use-module (rnrs io ports) #:use-module (srfi srfi-1) @@ -42,6 +43,7 @@ %current-git-repository current-git-repository commit-author-date + git-tracked-file? git-tracked-files call-with-file-in-git file-modification-table @@ -108,6 +110,17 @@ directory." (time-time time)) (* 60 (time-offset time))))) +(define (git-tracked-file? path repository) + "Return non-#f if PATH is a file tracked in REPOSITORY. Else, return +#f." + (guard (c ((let ((git-error (condition-git-error c))) + (and git-error + (= (git-error-code git-error) + GIT_ENOTFOUND))) + #f)) + (tree-entry-bypath (head-tree repository) + path))) + (define* (git-tracked-files #:optional (repository (current-git-repository))) "Return a list of all files and directories tracked in REPOSITORY. The returned paths are relative to the top-level directory of REPOSITORY |