aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/git.rs7
-rw-r--r--src/main.rs1
2 files changed, 8 insertions, 0 deletions
diff --git a/src/git.rs b/src/git.rs
index ac950e5..753137c 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -44,6 +44,7 @@ pub fn mirror<P: AsRef<Path>>(
url: &str,
path: P,
description: &str,
+ default_branch: &str,
) -> Result<(), Error> {
let repo = git2::Repository::init_opts(
path,
@@ -74,6 +75,12 @@ pub fn mirror<P: AsRef<Path>>(
let refspecs: [&str; 0] = [];
remote.fetch(&refspecs, None, None)?;
+ if default_branch != "master" {
+ repo.set_head(
+ &format!("refs/heads/{}", default_branch),
+ )?;
+ }
+
Ok(())
}
diff --git a/src/main.rs b/src/main.rs
index 811dcb4..0fdc715 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -244,6 +244,7 @@ where
&repo.git_url,
&clone_path,
repo.description(),
+ &repo.default_branch,
)?;
// Copy the base cgitrc file into the newly-cloned repository.