예제 #1
0
        public void CloneWithMainAndGitignore()
        {
            // Verifies that no extraneous "master" branch is introduced when git is configured to use
            // a default initial branch that is not "master"

            string gitignoreFile    = Path.Combine(h.Workdir, "gitignore");
            string gitignoreContent = "*.exe\r\n*.com\r\n";

            File.WriteAllText(gitignoreFile, gitignoreContent);

            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");
                r.Changeset(2, "First commit", 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");
            });
            h.RunInWithConfig(".", "GitTfs.Test.Integration.GlobalConfigs.mainDefaultBranch.gitconfig", "clone", h.TfsUrl, "$/MyProject", "MyProject", $"--gitignore={gitignoreFile}");
            h.AssertCommitMessage("MyProject", "HEAD", "First commit", "", "git-tfs-id: [" + h.TfsUrl + "]$/MyProject;C2");
            h.AssertFileInWorkspace("MyProject", "Folder/File.txt", "File contents");
            h.AssertFileInWorkspace("MyProject", "README", "tldr");
            AssertNewClone("MyProject", new[] { "HEAD", "refs/heads/main", "refs/remotes/tfs/default" },
                           commit: "1e9f1c2dfc1a0b5e4e6f135525a60d7c33a2d0aa",
                           tree: "2ef92a065910b3cc3a1379e41a034e90f2e610ec");
            h.AssertNoRef("MyProject", "master");
        }
예제 #2
0
        public void InitializesWithGitignore()
        {
            // Tests both:
            //   1. No extraneous "master" branch is introduced when gitconfig calls for "main" as the initial branch
            //   2. The initial .gitignore commit is on both the main branch and the tfs remote so they have common history

            string gitignoreFile    = Path.Combine(h.Workdir, "gitignore");
            string gitignoreContent = "*.exe\r\n*.com\r\n";

            File.WriteAllText(gitignoreFile, gitignoreContent);

            h.SetupFake(r => { });
            h.RunInWithConfig(".", "GitTfs.Test.Integration.GlobalConfigs.mainDefaultBranch.gitconfig", "init", "http://my-tfs.local/tfs", "$/MyProject", "MyProject", $"--gitignore={gitignoreFile}");
            h.AssertNoRef("MyProject", "refs/heads/master");
            h.AssertRef("MyProject", "refs/heads/main", "077fd68c084ef718a505f0a7375330c68d699f40");
            h.AssertRef("MyProject", "refs/remotes/tfs/default", "077fd68c084ef718a505f0a7375330c68d699f40");
        }