Skip to content

Commit c7ea305

Browse files
committed
Allowed specifying the location of the dynamic repo clone
1 parent 79ddf6d commit c7ea305

File tree

6 files changed

+20
-3
lines changed

6 files changed

+20
-3
lines changed

GitVersionExe.Tests/ArgumentParserTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ public void update_assembly_info_with_relative_filename()
205205
arguments.UpdateAssemblyInfoFileName.ShouldBe("..\\..\\CommonAssemblyInfo.cs");
206206
}
207207

208+
[Test]
209+
public void dynamicRepoLocation()
210+
{
211+
var arguments = ArgumentParser.ParseArguments("-dynamicRepoLocation c:\\foo\\");
212+
arguments.DynamicRepositoryLocation.ShouldBe("c:\\foo\\");
213+
}
214+
208215
[Test]
209216
public void can_log_to_console()
210217
{

GitVersionExe.Tests/HelpWriterTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public void AllArgsAreInHelp()
1515
{ "Init", "init" },
1616
{ "TargetBranch", "/b" },
1717
{ "LogFilePath" , "/l" },
18+
{ "DynamicRepositoryLocation" , "/dynamicRepoLocation" },
1819
{ "IsHelp", "/?" }
1920
};
2021
string helpText = null;

GitVersionExe/ArgumentParser.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ public static Arguments ParseArguments(List<string> commandLineArguments)
8484
continue;
8585
}
8686

87+
if (IsSwitch("dynamicRepoLocation", name))
88+
{
89+
arguments.DynamicRepositoryLocation = value;
90+
continue;
91+
}
92+
8793
if (IsSwitch("url", name))
8894
{
8995
arguments.TargetUrl = value;

GitVersionExe/Arguments.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public Arguments()
1515
public string TargetUrl;
1616
public string TargetBranch;
1717
public string CommitId;
18+
public string DynamicRepositoryLocation;
1819

1920
public bool Init;
2021

GitVersionExe/GitPreparer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ public void InitialiseDynamicRepositoryIfNeeded()
2525
{
2626
if (string.IsNullOrWhiteSpace(arguments.TargetUrl)) return;
2727

28-
var targetPath = CalculateTemporaryRepositoryPath(arguments.TargetUrl);
28+
var targetPath = CalculateTemporaryRepositoryPath(arguments.TargetUrl, arguments.DynamicRepositoryLocation);
2929
DynamicGitRepositoryPath = CreateDynamicRepository(targetPath, arguments.Authentication, arguments.TargetUrl, arguments.TargetBranch);
3030
}
3131

32-
string CalculateTemporaryRepositoryPath(string targetUrl)
32+
string CalculateTemporaryRepositoryPath(string targetUrl, string dynamicRepositoryLocation)
3333
{
34-
var userTemp = Path.GetTempPath();
34+
var userTemp = dynamicRepositoryLocation ?? Path.GetTempPath();
3535
var repositoryName = targetUrl.Split('/', '\\').Last().Replace(".git", string.Empty);
3636
var possiblePath = Path.Combine(userTemp, repositoryName);
3737

GitVersionExe/HelpWriter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Specify name of AssemblyInfo file. Can also /updateAssemblyInfo GlobalAssemblyIn
3838
/u Username in case authentication is required.
3939
/p Password in case authentication is required.
4040
/c The commit id to check. If not specified, the latest available commit on the specified branch will be used.
41+
/dynamicRepoLocation
42+
By default dynamic repositories will be cloned to %tmp%. Use this switch to override
4143
4244
# Execute build args
4345
/exec Executes target executable making GitVersion variables available as environmental variables

0 commit comments

Comments
 (0)