summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-01-23 19:18:08 +0000
committerArun Isaac2023-01-23 19:50:38 +0000
commit9e5dffc1f87d5e038f840bdc43e81b74f511bdaf (patch)
tree3eed11259277a4699486480c6375d50ddd32951a
parenta7b103c726dcb0d994fa45de18fe029d539208fd (diff)
downloadtissue-9e5dffc1f87d5e038f840bdc43e81b74f511bdaf.tar.gz
tissue-9e5dffc1f87d5e038f840bdc43e81b74f511bdaf.tar.lz
tissue-9e5dffc1f87d5e038f840bdc43e81b74f511bdaf.zip
web: Change to temporary clone before building website.
* tissue/web/static.scm (build-website): Expect to be at the top level of the repository to be exported. * bin/tissue (pull): Create a temporary clone of the repository and change to it before calling build-website.
-rwxr-xr-xbin/tissue18
-rw-r--r--tissue/web/static.scm31
2 files changed, 24 insertions, 25 deletions
diff --git a/bin/tissue b/bin/tissue
index 85d9b7a..3dfc37b 100755
--- a/bin/tissue
+++ b/bin/tissue
@@ -3,7 +3,7 @@ exec guile --no-auto-compile -s "$0" "$@"
!#
;;; tissue --- Text based issue tracker
-;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2022, 2023 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; This file is part of tissue.
;;;
@@ -415,12 +415,16 @@ HOSTNAME."
(raise c)))
(call-with-temporary-directory
(lambda (temporary-output-directory)
- (build-website (git-top-level)
- temporary-output-directory
- (tissue-configuration-web-files config))
- (delete-file-recursively website-directory)
- (rename-file temporary-output-directory
- website-directory)
+ (call-with-temporary-directory
+ (lambda (temporary-repository-clone)
+ (clone (git-top-level) temporary-repository-clone)
+ (call-with-current-directory temporary-repository-clone
+ (cut build-website
+ temporary-output-directory
+ (tissue-configuration-web-files config)))
+ (delete-file-recursively website-directory)
+ (rename-file temporary-output-directory
+ website-directory)))
(chmod website-directory #o755))))
(format (current-error-port)
"Built website.~%")))))))))))
diff --git a/tissue/web/static.scm b/tissue/web/static.scm
index 97e02be..2b910cb 100644
--- a/tissue/web/static.scm
+++ b/tissue/web/static.scm
@@ -119,10 +119,10 @@ stylesheet is included in the generated web pages."
(evaluate-ast-from-port in #:reader reader)
engine)))))
-(define* (build-website repository-top-level output-directory files
+(define* (build-website output-directory files
#:key (log-port (current-error-port)))
- "Export git repository with REPOSITORY-TOP-LEVEL to OUTPUT-DIRECTORY
-as a website.
+ "Export git repository to OUTPUT-DIRECTORY as a website. The current
+directory must be the top level of the repository being exported.
FILES is a list of <file> objects representing files to be written to
the web output.
@@ -132,18 +132,13 @@ Log to LOG-PORT. When LOG-PORT is #f, do not log."
(make-directories output-directory)
;; Move into a temporary clone of the git repository, and write each
;; of the <file> objects.
- (call-with-temporary-directory
- (lambda (temporary-repository-clone)
- (clone repository-top-level temporary-repository-clone)
- (for-each (lambda (file)
- (let ((output-file
- (string-append output-directory "/" (file-name file))))
- (when log-port
- (display (file-name file) log-port)
- (newline log-port))
- (make-directories (dirname output-file))
- (call-with-output-file output-file
- (lambda (port)
- (call-with-current-directory temporary-repository-clone
- (cut (file-writer file) port))))))
- files))))
+ (for-each (lambda (file)
+ (let ((output-file
+ (string-append output-directory "/" (file-name file))))
+ (when log-port
+ (display (file-name file) log-port)
+ (newline log-port))
+ (make-directories (dirname output-file))
+ (call-with-output-file output-file
+ (cut (file-writer file) <>))))
+ files))