Exemplo n.º 1
0
        public void PullRequestStatus()
        {
            string directory = Path.Combine(DataFolder, "GitTests");
            string statusStr = "HEAD detached at pull/6/merge\nnothing to commit, working tree clean";
            string originStr = @"https://github.com/Zingabopp/BeatSaberModdingTools";
            string hash      = "aadfa8f8af8a8f8af8a8fa";

            string expectedOrigin   = originStr;
            string expectedHash     = hash.Substring(0, 7);
            string expectedModified = "Unmodified";

            IGitRunner gitRunner = new MockGitRunner
                                   (
                (GitArgument.Status, statusStr),
                (GitArgument.OriginUrl, originStr),
                (GitArgument.CommitHash, hash))
            ;
            GetCommitInfo task = new MockGetCommitHash("Test.git")
            {
                GitRunner  = gitRunner,
                ProjectDir = directory
            };

            task.Execute();
            Assert.AreEqual("pull/6/merge", task.Branch);
            Assert.AreEqual(expectedHash, task.CommitHash);
            Assert.AreEqual(expectedOrigin, task.OriginUrl);
            Assert.AreEqual(expectedModified, task.Modified);
            Assert.AreEqual(true, task.IsPullRequest);
        }
Exemplo n.º 2
0
        public void NormalStatus_Unmodified()
        {
            string directory = Path.Combine(DataFolder, "GitTests");
            string statusStr = "On branch master\nYour branch is up to date with 'origin/master'.\n\nnothing to commit, working tree clean";
            string originStr = @"https://github.com/Zingabopp/BeatSaberModdingTools";
            string hash      = "aadfa8f8af8a8f8af8a8fa";

            string expectedOrigin   = originStr;
            string expectedHash     = hash.Substring(0, 7);
            string expectedModified = "Unmodified";

            IGitRunner gitRunner = new MockGitRunner
                                   (
                (GitArgument.Status, statusStr),
                (GitArgument.OriginUrl, originStr),
                (GitArgument.CommitHash, hash))
            ;
            GetCommitInfo task = new MockGetCommitHash("Test.git")
            {
                GitRunner  = gitRunner,
                ProjectDir = directory
            };

            task.Execute();
            Assert.AreEqual("master", task.Branch);
            Assert.AreEqual(expectedHash, task.CommitHash);
            Assert.AreEqual(expectedOrigin, task.OriginUrl);
            Assert.AreEqual(expectedModified, task.Modified);
        }
Exemplo n.º 3
0
        public void UntrackedFiles()
        {
            string directory = Path.Combine(DataFolder, "GitTests");
            string statusStr = "On branch master\nYour branch is up to date with 'origin/master'.\n\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n	        Refs / Beat Saber_Data / Managed / IPA.Injector.dll\n        Refs / Libs / Mono.Cecil.Mdb.dll\n        Refs / Libs / Mono.Cecil.Pdb.dll\n        Refs / Libs / Mono.Cecil.Rocks.dll\n        Refs / Libs / Mono.Cecil.dll\n        bsfiles.zip\n\nnothing added to commit but untracked files present(use \"git add\" to track)";

            string originStr = @"https://github.com/Zingabopp/BeatSaberModdingTools";
            string hash      = "aadfa8f8af8a8f8af8a8fa";

            string expectedOrigin   = originStr;
            string expectedHash     = hash.Substring(0, 7);
            string expectedModified = "Unmodified";

            IGitRunner gitRunner = new MockGitRunner
                                   (
                (GitArgument.Status, statusStr),
                (GitArgument.OriginUrl, originStr),
                (GitArgument.CommitHash, hash))
            ;
            GetCommitInfo task = new MockGetCommitHash("Test.git")
            {
                GitRunner  = gitRunner,
                ProjectDir = directory
            };

            task.Execute();
            Assert.AreEqual("master", task.Branch);
            Assert.AreEqual(expectedHash, task.CommitHash);
            Assert.AreEqual(expectedOrigin, task.OriginUrl);
            Assert.AreEqual(expectedModified, task.Modified);
        }
Exemplo n.º 4
0
        public void DefaultHashLength_Manual()
        {
            string        directory      = Path.Combine(DataFolder, "GitTests");
            string        expectedBranch = "master";
            int           hashLength     = 7;
            string        expectedHash   = "4197466ed7682542b4669e98fd962a3925ccaadf".Substring(0, hashLength);
            GetCommitInfo task           = new MockGetCommitHash("Test.git")
            {
                ProjectDir = directory,
                NoGit      = true
            };

            Assert.IsTrue(task.Execute());
            Console.WriteLine($"Branch: {task.Branch}");
            Assert.AreEqual(expectedBranch, task.Branch);
            Console.WriteLine($"Hash: {task.CommitHash}");
            Assert.AreEqual(expectedHash, task.CommitHash);
            Assert.AreEqual(hashLength, task.CommitHash.Length);
        }
Exemplo n.º 5
0
        public void NoGit()
        {
            string        directory      = Path.Combine(DataFolder, "GitTests");
            string        expectedBranch = "master";
            int           hashLength     = 7;
            string        expectedHash   = "4197466ed7682542b4669e98fd962a3925ccaadf".Substring(0, hashLength);
            string        expectedUrl    = @"https://github.com/Zingabopp/BeatSaberModdingTools.Tasks";
            GetCommitInfo task           = new MockGetCommitHash("Test.git")
            {
                ProjectDir = directory,
                NoGit      = true,
                HashLength = hashLength
            };

            Assert.IsTrue(task.Execute());
            Console.WriteLine($"Branch: {task.Branch}");
            Assert.AreEqual(expectedBranch, task.Branch);
            Console.WriteLine($"Hash: {task.CommitHash}");
            Assert.AreEqual(expectedHash, task.CommitHash);
            Assert.AreEqual(hashLength, task.CommitHash.Length);
            Assert.AreEqual(expectedUrl, task.OriginUrl);
        }