yagit

Yet another static site generator for Git 🙀️

Commit
cc8f8e6dd611a0ff19b43fa4d28fb8315ac861d3
Parent
cf4cd99607cbdf50df13455085f6283b42e84b88
Author
Pablo <pablo-pie@riseup.net>
Date

Fixed a bug

Fixed the post-update hook generation

Diffstats

2 files changed, 12 insertions, 11 deletions

Status Name Changes Insertions Deletions
Modified src/main.rs 2 files changed 9 7
Modified yagit.1 2 files changed 3 4
diff --git a/src/main.rs b/src/main.rs
@@ -1453,13 +1453,14 @@ fn render_index(repos: &[RepoInfo], private: bool) -> io::Result<()> {
 }
 
 fn setup_repo(
-  repo_path: &PathBuf,
+  name: &str,
+  path: &Path,
   description: &str,
   private: bool,
 ) -> io::Result<()> {
   const HOOK_MODE: u32 = 0o755;
 
-  let mut owner_path = repo_path.clone();
+  let mut owner_path = path.to_path_buf();
   owner_path.push("owner");
 
   let mut owner_f = match File::create(&owner_path) {
@@ -1472,7 +1473,7 @@ fn setup_repo(
 
   write!(&mut owner_f, "{}", config::OWNER.trim())?;
 
-  let mut dsc_path = repo_path.clone();
+  let mut dsc_path = path.to_path_buf();
   dsc_path.push("description");
 
   let mut dsc_f = match File::create(&dsc_path) {
@@ -1485,7 +1486,7 @@ fn setup_repo(
 
   write!(&mut dsc_f, "{}", description)?;
 
-  let mut hook_path = repo_path.clone();
+  let mut hook_path = path.to_path_buf();
   hook_path.push("hooks");
   hook_path.push("post-update");
 
@@ -1499,9 +1500,9 @@ fn setup_repo(
 
   writeln!(&mut hook_f, "#!/bin/sh")?;
   if private {
-    writeln!(&mut hook_f, "yagit --private render {repo_path:?}")?;
+    writeln!(&mut hook_f, "yagit --private render {name:?}")?;
   } else {
-    writeln!(&mut hook_f, "yagit render {repo_path:?}")?;
+    writeln!(&mut hook_f, "yagit render {name:?}")?;
   }
 
   let mut mode = hook_f.metadata()?.permissions();
@@ -1642,7 +1643,8 @@ fn main() -> ExitCode {
         return ExitCode::FAILURE;
       }
 
-      if setup_repo(&repo_path, &description, cmd.flags.private()).is_err() {
+      if setup_repo(&repo_name, &repo_path, &description, cmd.flags.private())
+        .is_err() {
         return ExitCode::FAILURE;
       }
 
diff --git a/yagit.1 b/yagit.1
@@ -23,8 +23,7 @@ render
 maintains a store of Git repositories at
 .Ar REPOS_DIR/
 and renders HTML pages for such repositories at the location
-.Ar OUTPUT_DIR/
-\.
+.Ar OUTPUT_DIR/.
 
 By default,
 .Nm
@@ -36,8 +35,8 @@ flag.
 
 .Nm
 also maintains a store of Git repositories at
-.Ar PRIVATE_REPOS_DIR/
-, which can be switched on using the
+.Ar PRIVATE_REPOS_DIR/,
+which can be switched on using the
 .Fl --private
 flag. The HTML pages for repositories at
 .Ar PRIVATE_REPOS_DIR/