From 89c6c8718bdd1a113e31e192d16bd0694d332b09 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 22 Jun 2022 18:25:16 +0530 Subject: bin: Run with the top-level directory as the current directory. If we always run with the top-level directory as the current directory, we don't need to frequently discover the top-level directory by walking the filesystem. Also, this sits nicer with a migration from git to libgit2. * bin/tissue (main): Run all subcommands with the top-level directory as the current directory. (load-config): Load tissue.scm without appending the top-level directory to it. (tissue-web): Find the top-level directory using getcwd instead of git-top-level. --- bin/tissue | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/bin/tissue b/bin/tissue index 566a6ea..f323e20 100755 --- a/bin/tissue +++ b/bin/tissue @@ -355,7 +355,7 @@ Show the text of issue #ISSUE-NUMBER. (memoize-thunk (lambda () "Load configuration and return object." - (load (string-append (git-top-level) "/tissue.scm"))))) + (load (canonicalize-path "tissue.scm"))))) (define tissue-repl (match-lambda* @@ -393,7 +393,7 @@ Export the repository as a website to OUTPUT-DIRECTORY. (parameterize ((%project-name (tissue-configuration-project (load-config))) (%tags-path (tissue-configuration-web-tags-path (load-config)))) - (build-website (git-top-level) + (build-website (getcwd) output-directory (tissue-configuration-web-css (load-config)) (tissue-configuration-web-files (load-config))))))) @@ -428,21 +428,23 @@ To get usage information for one of these sub-commands, run (current-error-port)) (newline (current-error-port)) (exit #f))) - (parameterize ((%issue-files (tissue-configuration-issue-files (load-config))) - (%aliases (tissue-configuration-aliases (load-config)))) - (apply (match command - ("news" tissue-news) - ("list" tissue-list) - ("edit" tissue-edit) - ("show" tissue-show) - ("repl" tissue-repl) - ("web" tissue-web) - (invalid-command - (format (current-error-port) "Invalid command `~a'~%~%" - invalid-command) - (print-usage) - (exit #f))) - args)))) + (call-with-current-directory (git-top-level) + (lambda () + (parameterize ((%issue-files (tissue-configuration-issue-files (load-config))) + (%aliases (tissue-configuration-aliases (load-config)))) + (apply (match command + ("news" tissue-news) + ("list" tissue-list) + ("edit" tissue-edit) + ("show" tissue-show) + ("repl" tissue-repl) + ("web" tissue-web) + (invalid-command + (format (current-error-port) "Invalid command `~a'~%~%" + invalid-command) + (print-usage) + (exit #f))) + args)))))) ;; tissue is an alias for `tissue list' ((_) (main "tissue" "list")))) -- cgit v1.2.3