private static string GetRevision(BackupArguments args, DirectoryInfo repo) { int rev; // version using (var look = new SvnLook(SvnLook.Commands.Youngest)) { look.RepositoryPath = repo.FullName; if (!string.IsNullOrEmpty(args.SubverisonPath)) { look.ToolPath = args.SubverisonPath; } look.Execute(); if (!string.IsNullOrEmpty(look.StandardError)) { _log.Info(look.StandardError); } if (!look.TryGetRevision(out rev)) { _log.WarnFormat("'{0}' is not a repository.", repo.Name); if (!string.IsNullOrEmpty(look.StandardOutput)) { _log.Info(look.StandardOutput); } return(null); } } return("v" + rev.ToString().PadLeft(7, '0')); }
public void TestDateTimeOffsetParsing() { var offsetString = SvnLook.ParseDateTimeOffsetString("2018-08-01 19:21:10 +0200 (Mi, 01 Aug 2018)"); Assert.True(DateTimeOffset.TryParse(offsetString, out var offset)); Assert.That(offset, Is.EqualTo(new DateTimeOffset(2018, 8, 1, 19, 21, 10, new TimeSpan(0, 2, 0, 0)))); }
public void TestReplacedItemsAreTracked() { var changedString = @" A + trunk/vendors/baker/toast.txt (von trunk/vendors/baker/bread.txt:r63) D trunk/vendors/baker/bread.txt"; var items = SvnLook.ParseAffectedItems(changedString); Assert.True(items.Count == 2); Assert.True(items.Any(x => x.Path == "/trunk/vendors/baker/toast.txt" && x.Action == RepositoryItemAction.Add && x.NodeKind == RepositoryItemNodeKind.File)); Assert.True(items.Any(x => x.Path == "/trunk/vendors/baker/bread.txt" && x.Action == RepositoryItemAction.Replace && x.NodeKind == RepositoryItemNodeKind.File)); }
public void TestEvaluateNodeKind() { Assert.That(SvnLook.EvaluateNodeKind("/test/"), Is.EqualTo(RepositoryItemNodeKind.Directory)); Assert.That(SvnLook.EvaluateNodeKind("test/"), Is.EqualTo(RepositoryItemNodeKind.Directory)); Assert.That(SvnLook.EvaluateNodeKind("test\\"), Is.EqualTo(RepositoryItemNodeKind.Directory)); Assert.That(SvnLook.EvaluateNodeKind("\\test\\test\\"), Is.EqualTo(RepositoryItemNodeKind.Directory)); Assert.That(SvnLook.EvaluateNodeKind("/test"), Is.EqualTo(RepositoryItemNodeKind.File)); Assert.That(SvnLook.EvaluateNodeKind("test/test.txt"), Is.EqualTo(RepositoryItemNodeKind.File)); Assert.That(SvnLook.EvaluateNodeKind("/test/.test"), Is.EqualTo(RepositoryItemNodeKind.File)); Assert.That(SvnLook.EvaluateNodeKind("\\test"), Is.EqualTo(RepositoryItemNodeKind.File)); Assert.That(SvnLook.EvaluateNodeKind("\\test\\_"), Is.EqualTo(RepositoryItemNodeKind.File)); Assert.That(SvnLook.EvaluateNodeKind("\\test\\_.txt"), Is.EqualTo(RepositoryItemNodeKind.File)); Assert.That(SvnLook.EvaluateNodeKind("\\test\\.txt"), Is.EqualTo(RepositoryItemNodeKind.File)); }
public void TestItemActionParsing([Values("A ", "D ", "U ", "_U", "UU")] string svnAction) { var expected = new Dictionary <string, RepositoryItemAction> { { "A ", RepositoryItemAction.Add }, { "D ", RepositoryItemAction.Delete }, { "U ", RepositoryItemAction.Modifiy }, { "_U", RepositoryItemAction.Modifiy }, { "UU", RepositoryItemAction.Modifiy }, }; var result = SvnLook.ParseAction(svnAction); Assert.That(result, Is.Not.EqualTo(RepositoryItemAction.None)); Assert.AreEqual(expected[svnAction], result); }
public void TestAffectedItems() { var changedString = @" A trunk/vendors/baker/toast.txt U trunk/vendors/baker/bakerman.txt U trunk/vendors/baker/oven.txt A trunk/vendors/baker/bread.txt"; var items = SvnLook.ParseAffectedItems(changedString); Assert.True(items.Count == 4); Assert.True(items.Any(x => x.Path == "/trunk/vendors/baker/toast.txt" && x.Action == RepositoryItemAction.Add && x.NodeKind == RepositoryItemNodeKind.File)); Assert.True(items.Any(x => x.Path == "/trunk/vendors/baker/bakerman.txt" && x.Action == RepositoryItemAction.Modifiy && x.NodeKind == RepositoryItemNodeKind.File)); Assert.True(items.Any(x => x.Path == "/trunk/vendors/baker/oven.txt" && x.Action == RepositoryItemAction.Modifiy && x.NodeKind == RepositoryItemNodeKind.File)); Assert.True(items.Any(x => x.Path == "/trunk/vendors/baker/bread.txt" && x.Action == RepositoryItemAction.Add && x.NodeKind == RepositoryItemNodeKind.File)); }
public void Youngest() { string repositoryPath = TestHelper.TestRepository; // make sure there is a repo TestHelper.CreateRepository(repositoryPath, false); using (var look = new SvnLook("youngest")) { look.RepositoryPath = repositoryPath; var r = look.Execute(); Assert.IsTrue(r); int rev; Assert.IsTrue(look.TryGetRevision(out rev)); } }
public void TestCopySourceIsTracked() { var changedString = @" _U branches/123/vendors/baker/ U branches/123/vendors/baker/toast.txt A + branches/123/vendors/baker/bread.txt (from trunk/vendors/baker/bread.txt:r111) U branches/123/vendors/baker/oven.txt"; var items = SvnLook.ParseAffectedItems(changedString); Assert.True(items.Count == 5); Assert.True(items.Any(x => x.Path == "/branches/123/vendors/baker/" && x.Action == RepositoryItemAction.Modifiy && x.NodeKind == RepositoryItemNodeKind.Directory)); Assert.True(items.Any(x => x.Path == "/branches/123/vendors/baker/toast.txt" && x.Action == RepositoryItemAction.Modifiy && x.NodeKind == RepositoryItemNodeKind.File)); Assert.True(items.Any(x => x.Path == "/branches/123/vendors/baker/bread.txt" && x.Action == RepositoryItemAction.Add && x.NodeKind == RepositoryItemNodeKind.File)); Assert.True(items.Any(x => x.Path == "/trunk/vendors/baker/bread.txt" && x.Action == RepositoryItemAction.None && x.NodeKind == RepositoryItemNodeKind.File)); Assert.True(items.Any(x => x.Path == "/branches/123/vendors/baker/oven.txt" && x.Action == RepositoryItemAction.Modifiy && x.NodeKind == RepositoryItemNodeKind.File)); }
private static string GetRevision(BackupArguments args, DirectoryInfo repo) { int rev; // version using (var look = new SvnLook(SvnLook.Commands.Youngest)) { look.RepositoryPath = repo.FullName; if (!string.IsNullOrEmpty(args.SubverisonPath)) look.ToolPath = args.SubverisonPath; look.Execute(); if (!string.IsNullOrEmpty(look.StandardError)) _log.Info(look.StandardError); if (!look.TryGetRevision(out rev)) { _log.WarnFormat("'{0}' is not a repository.", repo.Name); if (!string.IsNullOrEmpty(look.StandardOutput)) _log.Info(look.StandardOutput); return null; } } return "v" + rev.ToString().PadLeft(7, '0'); }
public void TestReplacedItemPathParsing() { var path = SvnLook.ParseReplacedPath(" (from trunk/vendors/baker/bread.txt:r123)"); Assert.That(path, Is.EqualTo("trunk/vendors/baker/bread.txt")); }