1
- use std :: path :: Path ;
2
-
1
+ use crate :: named_repo ;
2
+ use crate :: util :: named_subrepo_opts ;
3
3
use gix_sec:: Permission ;
4
4
use gix_testtools:: Env ;
5
5
use serial_test:: serial;
6
+ use std:: path:: Path ;
6
7
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
+ }
8
22
9
23
#[ test]
10
24
#[ serial]
@@ -29,17 +43,7 @@ fn author_and_committer_and_fallback() -> crate::Result {
29
43
. set ( "GIT_CONFIG_VALUE_0" , work_dir. join ( "c.config" ) . display ( ) . to_string ( ) ) ;
30
44
let repo = gix:: open_opts (
31
45
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) ) ,
43
47
) ?;
44
48
45
49
assert_eq ! (
@@ -147,18 +151,12 @@ fn author_from_different_config_sections() -> crate::Result {
147
151
148
152
let repo = gix:: open_opts (
149
153
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
+ ) ,
162
160
) ?;
163
161
164
162
assert_eq ! (
@@ -191,3 +189,14 @@ fn author_from_different_config_sections() -> crate::Result {
191
189
) ;
192
190
Ok ( ( ) )
193
191
}
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