Skip to content

Commit d51aec9

Browse files
committed
add test to assure hasconfig is working on gix level as well.
1 parent 92558a1 commit d51aec9

File tree

3 files changed

+52
-26
lines changed

3 files changed

+52
-26
lines changed
Binary file not shown.

gix/tests/fixtures/make_config_repos.sh

+17
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,20 @@ git init ssl-no-verify-enabled
175175
git config http.sslVerify true
176176
git config gitoxide.http.sslNoVerify true
177177
)
178+
179+
180+
git init --bare with-hasconfig
181+
(cd with-hasconfig
182+
cat >include-with-url <<-\EOF
183+
[user]
184+
name = "works"
185+
186+
EOF
187+
cat >system.config <<-\EOF
188+
[includeIf "hasconfig:remote.*.url:anyurl"]
189+
path = "include-with-url"
190+
EOF
191+
192+
echo $'[remote "any"]\n\turl=anyurl' >>config
193+
194+
)

gix/tests/gix/repository/config/identity.rs

+35-26
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1-
use std::path::Path;
2-
1+
use crate::named_repo;
2+
use crate::util::named_subrepo_opts;
33
use gix_sec::Permission;
44
use gix_testtools::Env;
55
use serial_test::serial;
6+
use std::path::Path;
67

7-
use crate::named_repo;
8+
#[test]
9+
#[serial]
10+
fn author_included_by_hasconfig() -> crate::Result {
11+
let repo = named_subrepo_opts("make_config_repos.sh", "with-hasconfig", gix::open::Options::isolated())?;
12+
let _env = Env::new().set(
13+
"GIT_CONFIG_SYSTEM",
14+
repo.git_dir().join("system.config").display().to_string(),
15+
);
16+
let repo = gix::open_opts(repo.git_dir(), allow_system_options(repo.open_options().clone()))?;
17+
let author = repo.author().expect("set in system config via include")?;
18+
assert_eq!(author.name, "works");
19+
assert_eq!(author.email, "[email protected]");
20+
Ok(())
21+
}
822

923
#[test]
1024
#[serial]
@@ -29,17 +43,7 @@ fn author_and_committer_and_fallback() -> crate::Result {
2943
.set("GIT_CONFIG_VALUE_0", work_dir.join("c.config").display().to_string());
3044
let repo = gix::open_opts(
3145
repo.git_dir(),
32-
repo.open_options()
33-
.clone()
34-
.with(trust)
35-
.permissions(gix::open::Permissions {
36-
env: gix::open::permissions::Environment {
37-
xdg_config_home: Permission::Deny,
38-
home: Permission::Deny,
39-
..gix::open::permissions::Environment::all()
40-
},
41-
..Default::default()
42-
}),
46+
allow_system_options(repo.open_options().clone().with(trust)),
4347
)?;
4448

4549
assert_eq!(
@@ -147,18 +151,12 @@ fn author_from_different_config_sections() -> crate::Result {
147151

148152
let repo = gix::open_opts(
149153
repo.git_dir(),
150-
repo.open_options()
151-
.clone()
152-
.config_overrides(None::<&str>)
153-
.with(gix_sec::Trust::Full)
154-
.permissions(gix::open::Permissions {
155-
env: gix::open::permissions::Environment {
156-
xdg_config_home: Permission::Deny,
157-
home: Permission::Deny,
158-
..gix::open::permissions::Environment::all()
159-
},
160-
..Default::default()
161-
}),
154+
allow_system_options(
155+
repo.open_options()
156+
.clone()
157+
.config_overrides(None::<&str>)
158+
.with(gix_sec::Trust::Full),
159+
),
162160
)?;
163161

164162
assert_eq!(
@@ -191,3 +189,14 @@ fn author_from_different_config_sections() -> crate::Result {
191189
);
192190
Ok(())
193191
}
192+
193+
fn allow_system_options(opts: gix::open::Options) -> gix::open::Options {
194+
opts.permissions(gix::open::Permissions {
195+
env: gix::open::permissions::Environment {
196+
xdg_config_home: Permission::Deny,
197+
home: Permission::Deny,
198+
..gix::open::permissions::Environment::all()
199+
},
200+
..Default::default()
201+
})
202+
}

0 commit comments

Comments
 (0)