Skip to content

Commit 4fe4a08

Browse files
committed
Add global mutex to prevent concurrent use
1 parent 4dcddf4 commit 4fe4a08

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/GitVersion.App/GitVersionExecutor.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.IO;
33
using System.Reflection;
4+
using System.Threading;
45
using GitVersion.Configuration;
56
using GitVersion.Extensions;
67
using GitVersion.Logging;
@@ -56,8 +57,15 @@ public int Execute(GitVersionOptions gitVersionOptions)
5657

5758
private int RunGitVersionTool(GitVersionOptions gitVersionOptions)
5859
{
60+
using var mutex = new Mutex(true, "sdfsdf", out var acquired);
61+
5962
try
6063
{
64+
if (!acquired)
65+
{
66+
mutex.WaitOne();
67+
}
68+
6169
var variables = gitVersionCalculateTool.CalculateVersionVariables();
6270

6371
var configuration = configProvider.Provide(overrideConfig: gitVersionOptions.ConfigInfo.OverrideConfig);
@@ -92,6 +100,10 @@ private int RunGitVersionTool(GitVersionOptions gitVersionOptions)
92100
}
93101
return 1;
94102
}
103+
finally
104+
{
105+
mutex.ReleaseMutex();
106+
}
95107

96108
return 0;
97109
}

0 commit comments

Comments
 (0)