public void HistoryWalker_should_rename_any_branch_but_master() { HistoryWalker.Walk(new EntryPoint(1)); var result = GitProcess.Execute("for-each-ref --format='%(refname:short)' refs/heads"); Assert.That(result.Stderr.Count(), Is.EqualTo(0)); Assert.That(result.Stdout.Count(), Is.EqualTo(2)); Assert.That(result.Stdout.Contains("'master'")); Assert.That(result.Stdout.Contains("'new-branch'")); }
public void HistoryWalker_should_exclude_files_matching_regex_patterns() { HistoryWalker.Walk(new EntryPoint(1)); var result = GitProcess.Execute("rev-list --all --count"); Assert.That(result.Stderr.Count(), Is.EqualTo(0)); Assert.That(result.Stdout.Count(), Is.EqualTo(1)); Assert.That(result.Stdout.Contains("1")); Assert.That(File.ReadAllText(SanePath.Combine(RepoPath, "AliceA.txt")), Is.EqualTo("Alice A1")); }
public void HistoryWalker_should_edit_files() { HistoryWalker.Walk(new EntryPoint(1)); File.WriteAllText(SanePath.Combine(RepoPath, "AliceA.txt"), "xxx"); GitProcess.Execute("checkout -- .", false); Assert.That(File.ReadAllText(SanePath.Combine(RepoPath, "AliceA.txt")), Is.EqualTo("Alice A2")); Assert.That(File.ReadAllText(SanePath.Combine(RepoPath, "AliceB.txt")), Is.EqualTo("Alice B2")); Assert.That(File.ReadAllText(SanePath.Combine(RepoPath, "AliceC.txt")), Is.EqualTo("Alice C2")); }
public void HistoryWalker_should_delete_files() { HistoryWalker.Walk(new EntryPoint(1)); var result = GitProcess.Execute("ls-files", false); Assert.That(result.Stderr.Count(), Is.EqualTo(0)); Assert.That(result.Stdout.Count(), Is.EqualTo(3)); Assert.That(result.Stdout.Contains(".gitattributes")); Assert.That(result.Stdout.Contains(".gitignore")); Assert.That(result.Stdout.Contains("AliceA.txt")); }
public void HistoryWalker_should_exclude_files_matching_regex_patterns() { HistoryWalker.Walk(new EntryPoint(1)); var result = GitProcess.Execute("ls-files"); Assert.That(result.Stderr.Count(), Is.EqualTo(0)); Assert.That(result.Stdout.Count(), Is.EqualTo(3)); Assert.That(result.Stdout.Contains(".gitattributes")); Assert.That(result.Stdout.Contains(".gitignore")); Assert.That(result.Stdout.Contains("AliceA.txt")); }
public void HistoryWalker_should_delete_the_branch_if_the_changeset_only_contains_deletes() { HistoryWalker.Walk(new EntryPoint(1)); var result = GitProcess.Execute("ls-files"); Assert.That(result.Stderr.Count(), Is.EqualTo(0)); Assert.That(result.Stdout.Count(), Is.EqualTo(4)); Assert.That(result.Stdout.Contains(".gitattributes")); Assert.That(result.Stdout.Contains(".gitignore")); Assert.That(result.Stdout.Contains("BobA.txt")); Assert.That(result.Stdout.Contains("BobB.txt")); }
public void HistoryWalker_should_add_files_from_multiple_mapped_branches_into_one() { HistoryWalker.Walk(new EntryPoint(1)); var result = GitProcess.Execute("ls-files"); Assert.That(result.Stderr.Count(), Is.EqualTo(0)); Assert.That(result.Stdout.Count(), Is.EqualTo(4)); Assert.That(result.Stdout.Contains(".gitattributes")); Assert.That(result.Stdout.Contains(".gitignore")); Assert.That(result.Stdout.Contains("A/AliceA.txt")); Assert.That(result.Stdout.Contains("B/AliceB.txt")); }
protected override void OneTimeSetUp() { base.OneTimeSetUp(); var aliceBContent = GenerateRandomString(200); Env .Branch("master", "$/Mock/Main/X", SanePath.Combine(RepoPath, "X")) .Branch("feature-branch", "$/Mock/Feature/X", SanePath.Combine(RepoPath, "X")) .Branch("feature-branch", "$/Mock/Feature/Y", SanePath.Combine(RepoPath, "Y")) // Alice creates files on branch 'master' .Changeset(OldUserAlice, UserAlice, "Add files") .Add("$/Mock/Main/X/SubFolderA/AliceA.txt", "Alice A") .Add("$/Mock/Main/X/AliceB1.txt", aliceBContent) .Add("$/Mock/Main/X/AliceC.txt", "Alice C") // Bob creates/deletes/edits files on branch 'feature-branch' .Changeset(OldUserBob, UserBob, "Edit files") .Hierarchy("$/Mock/Main/X/", "$/Mock/Feature/X/") .Add("$/Mock/Feature/X/BobA.txt", "Bob A") .Add("$/Mock/Feature/X/BobB.txt", "Should be undone in the merge by the changes from the Tfs") .Edit("$/Mock/Feature/X/SubFolderA/AliceA.txt", "Alice A, Bob A") .Delete("$/Mock/Feature/X/AliceB1.txt", ItemType.File, ChangeType.Delete | ChangeType.SourceRename) .Rename("$/Mock/Feature/X/AliceB1.txt", "$/Mock/Feature/X/AliceB2.txt", aliceBContent + "xxx", ItemType.File, ChangeType.Rename | ChangeType.Edit) .Delete("$/Mock/Feature/X/AliceC.txt") .Add("$/Mock/Feature/Y/BobC.txt", "Bob C") .End(); HistoryWalker.Walk(new EntryPoint(1)); Env // Alice merges 'feature-branch' into 'master' .Changeset(OldUserAlice, UserAlice, "Merge feature-branch") .File(SanePath.Combine(RepoPath, "Y/AlienB.txt"), "Alien file that does not belong to the changeset") .Add("$/Mock/Main/X/BobA.txt", "Bob A", ItemType.File, ChangeType.Merge | ChangeType.Branch) .Edit("$/Mock/Main/X/SubFolderA/AliceA.txt", "Alice A", ItemType.File, ChangeType.Merge | ChangeType.Edit) .Merge("$/Mock/Feature/X/SubFolderA/AliceA.txt") .Delete("$/Mock/Main/X/AliceB1.txt", ItemType.File, ChangeType.Merge | ChangeType.Delete | ChangeType.SourceRename) .Rename("$/Mock/Main/X/AliceB1.txt", "$/Mock/Main/X/AliceB2.txt", aliceBContent + "xxx", ItemType.File, ChangeType.Merge | ChangeType.Rename | ChangeType.Edit) .Delete("$/Mock/Main/X/AliceC.txt", ItemType.File, ChangeType.Merge | ChangeType.Delete) .End(); HistoryWalker.Walk(new EntryPoint(3)); }
static void Main(string[] args) { XmlConfigurator.Configure(new FileInfo("./log.config")); Log.Info("Initializing"); try { var netsh = new NetshCommand(new NetshProcess()); var versionControlServer = new VersionControlServer(Configuration.TfsServerUri, Configuration.TfsProject); var git = new GitCommand(new GitProcess(Configuration.GitRepoPath, Configuration.UserMappings), Configuration.GitRepoPath, Configuration.GitConfig, Configuration.GitOrigin); var changesetFilter = new ChangesetFilter(git, Configuration.ExcludedChangesets, Configuration.InitializeRepo); var historyWalker = new HistoryWalker(versionControlServer, git, changesetFilter, Configuration.BranchMappings, Configuration.ExcludedPaths); if (Configuration.ListUsers) { versionControlServer.ListUsers(Configuration.EntryPoint, Configuration.UserListingBaseHostName); } else { if (Configuration.InitializeRepo) { git.Init(); } netsh.ConfigureAvailablePorts(); netsh.Status(); git.Configure(false); historyWalker.Walk(Configuration.EntryPoint); } } catch (Exception e) { Log.Error(e); } Log.Info("Done, press any key to exit"); Console.ReadKey(); }
protected override void OneTimeSetUp() { base.OneTimeSetUp(); Env .Exclude(new Regex(@"/SubFolder", RegexOptions.IgnoreCase)) .Branch("master", "$/Mock/Main", RepoPath) .Changeset(OldUserAlice, UserAlice, "Add files") .Add("$/Mock/Main/AliceA1.txt", _aliceAContent) .Add("$/Mock/Main/AliceB1.txt", _aliceBContent) .Add("$/Mock/Main/AliceC1.txt", _aliceCContent) .Add("$/Mock/Main/AliceD1.txt", _aliceDContent) .Add("$/Mock/Main/AliceE1.txt", _aliceEContent) .Changeset(OldUserAlice, UserAlice, "Edit files") .Delete("$/Mock/Main/AliceA1.txt", ItemType.File, ChangeType.Delete | ChangeType.SourceRename) .Rename("$/Mock/Main/AliceA1.txt", "$/Mock/Main/AliceA2.txt", _aliceAContent, ItemType.File, ChangeType.Rename | ChangeType.Edit) .Delete("$/Mock/Main/AliceB1.txt", ItemType.File, ChangeType.Delete | ChangeType.SourceRename) .Rename("$/Mock/Main/AliceB1.txt", "$/Mock/Main/AliceB2.txt", _aliceBContent + "xxx", ItemType.File, ChangeType.Rename | ChangeType.Edit) .Delete("$/Mock/Main/AliceC1.txt", ItemType.File, ChangeType.Delete | ChangeType.SourceRename) .Rename("$/Mock/Main/AliceC1.txt", "$/Mock/Main/alicec1.txt", _aliceCContent, ItemType.File, ChangeType.Rename | ChangeType.Edit) .Delete("$/Mock/Main/AliceD1.txt", ItemType.File, ChangeType.Delete | ChangeType.SourceRename) .Rename("$/Mock/Main/AliceD1.txt", "$/Mock/Main/AliceD1.txt", _aliceDContent, ItemType.File, ChangeType.Rename | ChangeType.Edit) .Delete("$/Mock/Main/AliceE1.txt", ItemType.File, ChangeType.Delete | ChangeType.SourceRename) .Rename("$/Mock/Main/AliceE1.txt", "$/Mock/Main/SubFolder/AliceE1.txt", _aliceDContent, ItemType.File, ChangeType.Rename | ChangeType.Edit) .Delete("$/Mock/Main/NotTrackedByGit.txt", ItemType.File, ChangeType.Delete | ChangeType.SourceRename) .Rename("$/Mock/Main/NotTrackedByGit.txt", "$/Mock/Main/ShouldNotBeRenamed.txt", "Should not be added", ItemType.File, ChangeType.Rename | ChangeType.Edit) .PopItem() .End(); HistoryWalker.Walk(new EntryPoint(1)); }
public void HistoryWalker_should_create_a_new_branch_from_the_parent_branch() { Env .Branch("master", "$/Mock/Main", RepoPath) .Branch("feature-branch-x", "$/Mock/FeatureX", RepoPath) .Branch("feature-branch-y", "$/Mock/FeatureY", RepoPath) .Changeset(OldUserAlice, UserAlice, "Add files") .Add("$/Mock/Main/AliceMaster.txt", "Alice Master") .Changeset(OldUserAlice, UserAlice, "Branch from master to X") .Hierarchy("$/Mock/Main/", "$/Mock/FeatureX/") .Add("$/Mock/FeatureX/AliceX.txt", "Alice X") .Changeset(OldUserAlice, UserAlice, "Branch from master to Y") .Hierarchy("$/Mock/Main/", "$/Mock/FeatureY/") .Add("$/Mock/FeatureY/AliceY.txt", "Alice Y") .End(); HistoryWalker.Walk(new EntryPoint(1)); var branches = GitProcess.Execute("for-each-ref --format='%(refname:short)' refs/heads"); Assert.That(branches.Stderr.Count(), Is.EqualTo(0)); Assert.That(branches.Stdout.Count(), Is.EqualTo(3)); Assert.That(branches.Stdout.Contains("'master'")); Assert.That(branches.Stdout.Contains("'feature-branch-x'")); Assert.That(branches.Stdout.Contains("'feature-branch-y'")); Assert.That(Git.CurrentBranch(), Is.EqualTo("feature-branch-y")); var commits = GitProcess.Execute("log --pretty=format:'%s'"); Assert.That(commits.Stderr.Count(), Is.EqualTo(0)); Assert.That(commits.Stdout.Count(), Is.EqualTo(2)); Assert.That(commits.Stdout.Contains("'[C3] Branch from master to Y'")); Assert.That(commits.Stdout.Contains("'[C1] Add files'")); }