Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
radicle/storage/init: Remove placeholder files
Lorenz Leutgeb committed 2 months ago
commit fa94638abb8037f6a3c7ade8ac8a1cdf3a52cad4
parent 7425ae4
1 file changed +16 -0
modified crates/radicle/src/storage/git.rs
@@ -416,6 +416,22 @@ impl Repository {
                .no_reinit(true)
                .external_template(false),
        )?;
+

+
        {
+
            // Even though `external_template(false)` is called above,
+
            // libgit2 places stub files in the repository:
+
            // https://github.com/libgit2/libgit2/blob/ca225744b992bf2bf24e9a2eb357ddef78179667/src/libgit2/repo_template.h#L50-L54
+
            // This is helpful for a "normal" repository, directly interacted
+
            // with by a human, but not necessary for our use case.
+
            // Attempt to remove these files, but ignore any errors.
+
            // An alternative solution would be to define our own template,
+
            // but distributing that template is way more complex than
+
            // deleting a handful of files.
+
            let _ = fs::remove_dir_all(path.as_ref().join("hooks"));
+
            let _ = fs::remove_dir_all(path.as_ref().join("info"));
+
            let _ = fs::remove_file(path.as_ref().join("description"));
+
        }
+

        let mut config = backend.config()?;

        config.set_str("user.name", &info.name())?;