From 25ed6b8b28d2280429b0de7d8dba1d0214891b63 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Mon, 13 Nov 2023 16:53:28 +0000 Subject: [PATCH] httpd: consistent default branch The test suite for `radicle-httpd` assumed that `master` would be used for the working copy. However, if a user set their Git default branch to be something other than `master` then the test suite will fail for them. To remedy this, initialise the working copy with the `master` branch as well. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-httpd/src/test.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/radicle-httpd/src/test.rs b/radicle-httpd/src/test.rs index 1604f307..75645a1e 100644 --- a/radicle-httpd/src/test.rs +++ b/radicle-httpd/src/test.rs @@ -95,6 +95,8 @@ pub fn contributor(dir: &Path) -> Context { } fn seed_with_signer(dir: &Path, profile: radicle::Profile, signer: &G) -> Context { + const DEFAULT_BRANCH: &'static str = "master"; + let tracking_db = dir.join("radicle").join("node").join("tracking.db"); let routing_db = dir.join("radicle").join("node").join("routing.db"); let addresses_db = dir.join("radicle").join("node").join("addresses.db"); @@ -112,7 +114,9 @@ fn seed_with_signer(dir: &Path, profile: radicle::Profile, signer: &G fs::create_dir_all(&workdir).unwrap(); // add commits to workdir (repo) - let repo = git2::Repository::init(&workdir).unwrap(); + let mut opts = git2::RepositoryInitOptions::new(); + opts.initial_head(DEFAULT_BRANCH); + let repo = git2::Repository::init_opts(&workdir, &opts).unwrap(); let tree = radicle::git::write_tree(Path::new("README"), "Hello World!\n".as_bytes(), &repo).unwrap(); @@ -180,7 +184,7 @@ fn seed_with_signer(dir: &Path, profile: radicle::Profile, signer: &G let repo = git2::Repository::open(&workdir).unwrap(); let name = "hello-world".to_string(); let description = "Rad repository for tests".to_string(); - let branch = RefString::try_from("master").unwrap(); + let branch = RefString::try_from(DEFAULT_BRANCH).unwrap(); let visibility = Visibility::default(); let (id, _, _) = radicle::rad::init( &repo,