Skip to content

Commit 7526768

Browse files
committed
Override SystemReader#openSystemConfig instead of getenv
- Apply Java plugin for buildSrc
1 parent c0bbde6 commit 7526768

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

buildSrc/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
plugins {
2+
id 'java'
3+
}
4+
15
repositories {
26
mavenCentral();
37
}
48

59
dependencies {
6-
implementation "org.eclipse.jgit:org.eclipse.jgit:7.4.0.202509020913-r"
10+
implementation 'org.eclipse.jgit:org.eclipse.jgit:7.4.0.202509020913-r'
711
}
Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package choonster.testmod3.gradle;
22

3-
import org.eclipse.jgit.lib.Constants;
3+
import org.eclipse.jgit.lib.Config;
4+
import org.eclipse.jgit.storage.file.FileBasedConfig;
5+
import org.eclipse.jgit.util.FS;
46
import org.eclipse.jgit.util.SystemReader;
57

6-
import java.util.Objects;
7-
88
/**
99
* A {@link SystemReader} implementation that disables reading of system config.
1010
*
@@ -16,11 +16,19 @@ public NoSystemConfigSystemReader(final SystemReader delegate) {
1616
}
1717

1818
@Override
19-
public String getenv(final String variable) {
20-
if (Objects.equals(variable, Constants.GIT_CONFIG_NOSYSTEM_KEY)) {
21-
return "true";
22-
}
19+
public FileBasedConfig openSystemConfig(final Config parent, final FS fs) {
20+
// Based on the SystemReader.Default#openSystemConfig implementation
21+
return new FileBasedConfig(parent, null, fs) {
22+
@Override
23+
public void load() {
24+
// empty, do not load
25+
}
2326

24-
return super.getenv(variable);
27+
@Override
28+
public boolean isOutdated() {
29+
// regular class would bomb here
30+
return false;
31+
}
32+
};
2533
}
2634
}

0 commit comments

Comments
 (0)