Skip to content

Commit 3741db4

Browse files
Make sure any set global mailmap doesn't interfere with functional tests.
1 parent 4d41cb0 commit 3741db4

2 files changed

Lines changed: 14 additions & 21 deletions

File tree

test/functional/lib/cmd.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def initialize(exec_path, rundir)
1212
@rundir = rundir
1313
end
1414

15-
def run(*args, cache_home: nil, config_home: nil, n_procs: nil)
15+
def run(*args, cache_home: nil, git_config_path: nil, n_procs: nil)
1616
env_hash = {}
1717

1818
if cache_home
@@ -21,8 +21,11 @@ def run(*args, cache_home: nil, config_home: nil, n_procs: nil)
2121
env_hash['GIT_WHO_DISABLE_CACHE'] = '1'
2222
end
2323

24-
if config_home
25-
env_hash['XDG_CONFIG_HOME'] = config_home.to_s
24+
env_hash['GIT_CONFIG_SYSTEM'] = ''
25+
if git_config_path
26+
env_hash['GIT_CONFIG_GLOBAL'] = git_config_path.to_s
27+
else
28+
env_hash['GIT_CONFIG_GLOBAL'] = ''
2629
end
2730

2831
unless n_procs.nil?

test/functional/mailmap_test.rb

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ def test_global_mailmap
6565
Dir.mktmpdir do |dir|
6666
dir = Pathname.new(dir)
6767
cache_home = dir / ".cache"
68-
config_home = dir / ".config"
6968
cache_home.mkdir
70-
config_home.mkdir
7169

7270
# Try with no mailmap
7371
cmd = GitWho.new(GitWho.built_bin_path, BigRepo.path)
@@ -76,7 +74,6 @@ def test_global_mailmap
7674
'--csv',
7775
'-e',
7876
cache_home: cache_home,
79-
config_home: config_home,
8077
)
8178
refute_empty(stdout_s)
8279

@@ -86,7 +83,7 @@ def test_global_mailmap
8683
assert_equal data[3]['commits'], '110'
8784

8885
# Try with mailmap, does it invalidate cache?
89-
git_dir = config_home / "git"
86+
git_dir = dir / "git"
9087
git_dir.mkdir
9188

9289
mailmap_path = git_dir / ".mailmap"
@@ -100,7 +97,7 @@ def test_global_mailmap
10097
'--csv',
10198
'-e',
10299
cache_home: cache_home,
103-
config_home: config_home,
100+
git_config_path: git_config_path,
104101
)
105102
refute_empty(stdout_s)
106103

@@ -117,7 +114,7 @@ def test_global_mailmap
117114
'--csv',
118115
'-e',
119116
cache_home: cache_home,
120-
config_home: config_home,
117+
git_config_path: git_config_path,
121118
)
122119
refute_empty(stdout_s)
123120

@@ -132,9 +129,7 @@ def test_both_mailmap
132129
Dir.mktmpdir do |dir|
133130
dir = Pathname.new(dir)
134131
cache_home = dir / ".cache"
135-
config_home = dir / ".config"
136132
cache_home.mkdir
137-
config_home.mkdir
138133

139134
# Try with no mailmap
140135
cmd = GitWho.new(GitWho.built_bin_path, BigRepo.path)
@@ -143,7 +138,6 @@ def test_both_mailmap
143138
'--csv',
144139
'-e',
145140
cache_home: cache_home,
146-
config_home: config_home,
147141
)
148142
refute_empty(stdout_s)
149143

@@ -164,7 +158,6 @@ def test_both_mailmap
164158
'--csv',
165159
'-e',
166160
cache_home: cache_home,
167-
config_home: config_home,
168161
)
169162
refute_empty(stdout_s)
170163

@@ -177,7 +170,7 @@ def test_both_mailmap
177170
assert_equal data[3]['commits'], '110'
178171

179172
# Try with two mailmaps, does it invalidate cache?
180-
git_dir = config_home / "git"
173+
git_dir = dir / "git"
181174
git_dir.mkdir
182175

183176
global_mailmap_path = git_dir / ".mailmap"
@@ -191,7 +184,7 @@ def test_both_mailmap
191184
'--csv',
192185
'-e',
193186
cache_home: cache_home,
194-
config_home: config_home,
187+
git_config_path: git_config_path,
195188
)
196189
refute_empty(stdout_s)
197190

@@ -211,7 +204,7 @@ def test_both_mailmap
211204
'--csv',
212205
'-e',
213206
cache_home: cache_home,
214-
config_home: config_home,
207+
git_config_path: git_config_path,
215208
)
216209
refute_empty(stdout_s)
217210

@@ -231,7 +224,6 @@ def test_both_mailmap
231224
'--csv',
232225
'-e',
233226
cache_home: cache_home,
234-
config_home: config_home,
235227
)
236228
refute_empty(stdout_s)
237229

@@ -250,11 +242,9 @@ def test_bad_configured_global_mailmap_path
250242
Dir.mktmpdir do |dir|
251243
dir = Pathname.new(dir)
252244
cache_home = dir / ".cache"
253-
config_home = dir / ".config"
254245
cache_home.mkdir
255-
config_home.mkdir
256246

257-
git_dir = config_home / "git"
247+
git_dir = dir / "git"
258248
git_dir.mkdir
259249
mailmap_path = git_dir / ".mailmap"
260250
# NOTE: We aren't creating the file!
@@ -268,7 +258,7 @@ def test_bad_configured_global_mailmap_path
268258
'--csv',
269259
'-e',
270260
cache_home: cache_home,
271-
config_home: config_home,
261+
git_config_path: git_config_path,
272262
)
273263
refute_empty(stdout_s)
274264

0 commit comments

Comments
 (0)