Example #1
0
    public override bool Run(string[] args)
    {
        Console.WriteLine("");
        Console.WriteLine("Identifying branch...");
        Console.WriteLine("");

        var nodeBranch = CurrentNode.Properties["Branch"];

        var identifier = new GitBranchIdentifier();

        var branch = identifier.Identify();

        Console.WriteLine("Branch: " + branch);

        if (nodeBranch != branch)
        {
            CurrentNode.Properties["Branch"] = branch;
            CurrentNode.Save();

            Console.WriteLine("Updated branch in file node properties.");
        }
        else
        {
            Console.WriteLine("The branch name specified in the file node properties matches the current branch. Keeping as is.");
        }

        return(!IsError);
    }
        public void Test_Identify()
        {
            var branchName = "TestBranch";

            var initializer = new TestSourceProjectInitializer(OriginalDirectory, WorkingDirectory);

            initializer.CloneSource = true;

            initializer.Initialize();

            var gitter = new Gitter();

            gitter.Branch(branchName, true); // Create a new test branch and move to it
            gitter.Branch("zz");             // Create a branch at the end of the list

            var identifier       = new GitBranchIdentifier();
            var identifiedBranch = identifier.Identify();

            Assert.AreEqual(branchName, identifiedBranch, "Branch doesn't match.");
        }