Beispiel #1
0
        public void CloneWithAllBranchesShouldHandleFolderDeletedAndRecreatedAsBranch()
        {
            //Arrange
            h.SetupFake(
                r =>
            {
                r.SetRootBranch("$/MyTeamProject/Root");
                r.Changeset(1, "Create initial team project.", DateTime.Now)
                .Change(TfsChangeType.Add, TfsItemType.Folder, "$/MyTeamProject");

                r.Changeset(2, "Create root branch.", DateTime.Now)
                .Change(TfsChangeType.Add, TfsItemType.Folder, "$/MyTeamProject/Root");

                r.Changeset(3, "Create \"branch\" (as a folder).", DateTime.Now)
                .Change(TfsChangeType.Add, TfsItemType.Folder, "$/MyTeamProject/Branch");

                r.Changeset(4, "Delete the \"branch\" folder.", DateTime.Now)
                .Change(TfsChangeType.Delete, TfsItemType.Folder, "$/MyTeamProject/Branch");

                r.BranchChangeset(5, "Create a proper branch.", DateTime.Now, "$/MyTeamProject/Root", "$/MyTeamProject/Branch", 2)
                .Change(TfsChangeType.Branch, TfsItemType.Folder, "$/MyTeamProject/Branch");
            });

            //Act
            h.Run("clone", h.TfsUrl, "$/MyTeamProject/Root", "MyTeamProject", "--branches=all");

            //Assert
            h.AssertGitRepo("MyTeamProject");

            var branchCollection = h.Repository("MyTeamProject").Branches.Cast <Branch>().ToList();
            var branch           = branchCollection.FirstOrDefault(b => b.Name == "Branch");

            //Ensure our Branch was migrated...
            Assert.NotNull(branch);

            // So, it turns out GetRootChangesetForBranch is really the unit under test here.
            // Because it's faked out for unit tests, this test is worthless except as an illustration of expected behavior
            //  in the actual implementations.

            //Ensure we didn't migrate our branch from the "folder creation" point of $/MyTeamProject/Branch e.g. C2 -> C3,C4...
            Assert.False(branch.Commits.Any(c => c.Message.IndexOf("Create \"branch\" (as a folder).", StringComparison.InvariantCultureIgnoreCase) >= 0));
            //... and that, instead, we migrated it from the branch creation point, e.g. C2 -> C5
            Assert.True(branch.Commits.Any(c => c.Message.IndexOf("Create a proper branch.", StringComparison.InvariantCultureIgnoreCase) >= 0));

            var refs = new[]
            {
                "HEAD",
                "refs/remotes/tfs/default",
                "refs/heads/master",
                "refs/remotes/tfs/Branch",
                "refs/heads/Branch"
            };

            AssertNewClone("MyTeamProject", refs);
        }
Beispiel #2
0
 private void CloneRepoWithTwoCommits()
 {
     integrationHelper.SetupFake(r =>
     {
         r.Changeset(1, "Project created from template", DateTime.Parse("2012-01-01 12:12:12 -05:00"))
         .Change(TfsChangeType.Add, TfsItemType.Folder, "$/MyProject");
         r.Changeset(2, "Add Readme", DateTime.Parse("2012-01-02 12:12:12 -05:00"))
         .Change(TfsChangeType.Add, TfsItemType.Folder, "$/MyProject/Folder")
         .Change(TfsChangeType.Add, TfsItemType.File, "$/MyProject/Folder/File.txt", "File contents")
         .Change(TfsChangeType.Add, TfsItemType.File, "$/MyProject/README", "tldr");
     });
     integrationHelper.Run("clone", integrationHelper.TfsUrl, "$/MyProject");
     integrationHelper.AssertGitRepo("MyProject");
 }
Beispiel #3
0
        public void ClonesEmptyProject()
        {
            h.SetupFake(r =>
            {
                r.Changeset(1, "Project created from template", DateTime.Parse("2012-01-01 12:12:12 -05:00"))
                .Change(TfsChangeType.Add, TfsItemType.Folder, "$/MyProject");
            });
            h.Run("clone", h.TfsUrl, "$/MyProject");
            h.AssertGitRepo("MyProject");
            const string expectedSha = "4053764b2868a2be71ae7f5f113ad84dff8a052a";

            h.AssertRef("MyProject", "HEAD", expectedSha);
            h.AssertRef("MyProject", "master", expectedSha);
            h.AssertRef("MyProject", "refs/remotes/tfs/default", expectedSha);
            h.AssertEmptyWorkspace("MyProject");
        }
Beispiel #4
0
        public void CloneWithAllBranchesShouldHandleFolderDeletedAndRecreatedAsBranch()
        {
            h.SetupFake(r =>
            {
                r.SetRootBranch("$/MyTeamProject/Root");

                r.Changeset(1, "Create initial team project.", DateTime.Now)
                .Change(TfsChangeType.Add, TfsItemType.Folder, "$/MyTeamProject");

                r.Changeset(2, "Create root branch.", DateTime.Now)
                .Change(TfsChangeType.Add, TfsItemType.Folder, "$/MyTeamProject/Root");

                r.Changeset(3, @"Create ""branch"" (as a folder).", DateTime.Now)
                .Change(TfsChangeType.Add, TfsItemType.Folder, "$/MyTeamProject/Branch");

                r.Changeset(4, @"Delete the ""branch"" folder.", DateTime.Now)
                .Change(TfsChangeType.Delete, TfsItemType.Folder, "$/MyTeamProject/Branch");

                r.BranchChangeset(5, "Create a proper branch (though, with the same name as the previously deleted folder)",
                                  DateTime.Now, "$/MyTeamProject/Root", "$/MyTeamProject/Branch", 2)
                .Change(TfsChangeType.Branch, TfsItemType.Folder, "$/MyTeamProject/Branch");
            });

            h.Run("clone", h.TfsUrl, "$/MyTeamProject/Root", "MyTeamProject", "--branches=all");

            h.AssertGitRepo("MyTeamProject");

            var branchCollection = h.Repository("MyTeamProject").Branches.Cast <Branch>().ToList();
            var branch           = branchCollection.FirstOrDefault(b => b.FriendlyName == "Branch");

            Assert.NotNull(branch);

            // So, it turns out GetRootChangesetForBranch is really the unit under test here.
            // Because it's faked out for unit tests, this test is worthless except as an
            // illustration of expected behavior in the actual implementation.

            // Ensure we didn't migrate our branch from the "folder creation" point of
            // $/MyTeamProject/Branch (e.g. C2 -> C3, C4...
            Assert.False(branch.Commits.Any(c => c.Message.IndexOf(@"Create ""branch"" (as a folder).", StringComparison.InvariantCultureIgnoreCase) >= 0));

            // Ensure we migrated the branch from it's creation point, e.g. C2 immediately followed by C5 (C2 -> C5)
            var expectedBranchChangesetParentCommit = branch.Commits.Where(c => c.Message.IndexOf("Create root branch.", StringComparison.InvariantCultureIgnoreCase) >= 0).FirstOrDefault();

            Assert.NotNull(expectedBranchChangesetParentCommit);

            var branchChangesetCommit = branch.Commits.Where(c => c.Message.IndexOf("Create a proper branch (though, with the same name as the previously deleted folder)", StringComparison.InvariantCultureIgnoreCase) >= 0).FirstOrDefault();

            Assert.NotNull(branchChangesetCommit);

            // This wasn't part of the original test by @jeremy-sylvis-tmg, but this does ensure the relationship
            // C2 -> C5; it may not be enough to just ensure C5 exists.
            Assert.True(branchChangesetCommit.Parents.Contains(expectedBranchChangesetParentCommit));

            var refs = new[]
            {
                "HEAD",
                "refs/remotes/tfs/default",
                "refs/heads/master",
                "refs/heads/tfs/branch",
                "refs/heads/Branch"
            };

            AssertNewClone("MyTeamProject", refs);
        }