|
3 | 3 | import java.io.IOException;
|
4 | 4 | import java.util.Map;
|
5 | 5 |
|
| 6 | +import com.rudikershaw.gitbuildhook.threadsafety.ClassLock; |
6 | 7 | import org.apache.maven.plugin.MojoFailureException;
|
7 | 8 | import org.apache.maven.plugins.annotations.LifecyclePhase;
|
8 | 9 | import org.apache.maven.plugins.annotations.Mojo;
|
@@ -37,21 +38,23 @@ public void execute() throws MojoFailureException {
|
37 | 38 | if (repoBuilder.getGitDir().getAbsolutePath().contains(".git/worktrees/")) {
|
38 | 39 | getLog().warn(
|
39 | 40 | "The plugin appears to be running in a Git worktree. "
|
40 |
| - + "Worktree configuration is not currently supported. No configuration changes made." |
| 41 | + + "No configuration changes made." |
41 | 42 | );
|
42 | 43 | return;
|
43 | 44 | }
|
44 | 45 |
|
45 |
| - try (Git git = Git.open(repoBuilder.getGitDir())) { |
46 |
| - final StoredConfig config = git.getRepository().getConfig(); |
47 |
| - for (final Map.Entry<String, String> entry : gitConfig.entrySet()) { |
48 |
| - final String[] conf = stringToConfigArray(entry.getKey()); |
49 |
| - config.setString(conf[0], conf[1], conf[2], entry.getValue()); |
50 |
| - getLog().info("Git config '" + entry.getKey() + "' set to - " + entry.getValue()); |
| 46 | + synchronized (ClassLock.class) { |
| 47 | + try (Git git = Git.open(repoBuilder.getGitDir())) { |
| 48 | + final StoredConfig config = git.getRepository().getConfig(); |
| 49 | + for (final Map.Entry<String, String> entry : gitConfig.entrySet()) { |
| 50 | + final String[] conf = stringToConfigArray(entry.getKey()); |
| 51 | + config.setString(conf[0], conf[1], conf[2], entry.getValue()); |
| 52 | + getLog().info("Git config '" + entry.getKey() + "' set to - " + entry.getValue()); |
| 53 | + } |
| 54 | + config.save(); |
| 55 | + } catch (final IOException ioe) { |
| 56 | + failBuildBecauseRepoCouldNotBeFound(ioe); |
51 | 57 | }
|
52 |
| - config.save(); |
53 |
| - } catch (final IOException ioe) { |
54 |
| - failBuildBecauseRepoCouldNotBeFound(ioe); |
55 | 58 | }
|
56 | 59 | }
|
57 | 60 |
|
|
0 commit comments