Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions src/GitVersionCore.Tests/DynamicRepositoryTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Diagnostics;
using System.IO;
using GitVersion;
using GitVersionCore.Tests;
using NUnit.Framework;
Expand All @@ -9,43 +10,54 @@ public class DynamicRepositoryTests : TestBase
string workDirectory;


[SetUp]
[OneTimeSetUp]
public void CreateTemporaryRepository()
{
// Note: we can't use guid because paths will be too long
workDirectory = Path.Combine(Path.GetTempPath(), "DynRepoTests");
}


//[TearDown]
//public void Cleanup()
//{
// Directory.Delete(workDirectory, true);
//}
[OneTimeTearDown]
public void Cleanup()
{
Directory.Delete(workDirectory, true);
}

[Ignore("These tests are slow and fail on the second run in Test Explorer and need to be re-written")]
[TestCase("GV_master_1", "https://github.com/GitTools/GitVersion", "master", "4783d325521463cd6cf1b61074352da84451f25d", "4.0.0+1126")]
[TestCase("GV_master_2", "https://github.com/GitTools/GitVersion", "master", "3bdcd899530b4e9b37d13639f317da04a749e728", "4.0.0+1132")]
//[Ignore("These tests are slow and fail on the second run in Test Explorer and need to be re-written")]
[NonParallelizable]
[TestCase("GV_master_1", "https://github.com/GitTools/GitVersion", "master", "4783d325521463cd6cf1b61074352da84451f25d", "4.0.0+1086")]
[TestCase("GV_master_2", "https://github.com/GitTools/GitVersion", "master", "3bdcd899530b4e9b37d13639f317da04a749e728", "4.0.0+1092")]
// Note: use same name twice to see if changing commits works on same (cached) repository
[TestCase("Catel_develop_1", "https://github.com/Catel/Catel", "develop", "0e2b6c125a730d2fa5e24394ef64abe62c98e9e9", "5.12.0-alpha.188")]
[TestCase("Catel_develop_1", "https://github.com/Catel/Catel", "develop", "71e71359f37581784e18c94e7a45eee72cbeeb30", "5.12.0-alpha.192")]
[TestCase("Catel_master_1", "https://github.com/Catel/Catel", "master", "f5de8964c35180a5f8607f5954007d5828aa849f", "5.10.0")]
public void FindsVersionInDynamicRepo(string name, string url, string targetBranch, string commitId, string expectedFullSemVer)
{
var root = Path.Combine(workDirectory, name);
var dynamicDirectory = Path.Combine(root, "dynamic");
var workingDirectory = Path.Combine(root, "working");

// Clear upfront
if (Directory.Exists(root))
{
Directory.Delete(root, true);
}
//// Clear upfront
//if (Directory.Exists(root))
//{
// Directory.Delete(root, true);
//}

Directory.CreateDirectory(dynamicDirectory);
Directory.CreateDirectory(workingDirectory);

Logger.AddLoggersTemporarily(
x => Debug.WriteLine($"[DEBUG] {x}"),
x => Debug.WriteLine($"[INFO] {x}"),
x => Debug.WriteLine($"[WARNING] {x}"),
x => Debug.WriteLine($"[ERROR] {x}"));

var executeCore = new ExecuteCore(new TestFileSystem());

var versionVariables = executeCore.ExecuteGitVersion(url, dynamicDirectory, null, targetBranch,
false, workingDirectory, commitId);

Assert.AreEqual(expectedFullSemVer, versionVariables.FullSemVer);
}
}
}
7 changes: 3 additions & 4 deletions src/GitVersionCore/GitPreparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ public GitPreparer(string targetUrl, string dynamicRepositoryLocation, Authentic
{
this.targetUrl = targetUrl;
this.dynamicRepositoryLocation = dynamicRepositoryLocation;
this.authentication = authentication == null ?
null :
this.authentication =
new AuthenticationInfo
{
Username = authentication.Username,
Password = authentication.Password
Username = authentication?.Username,
Password = authentication?.Password
};
this.noFetch = noFetch;
this.targetPath = targetPath.TrimEnd('/', '\\');
Expand Down