Beispiel #1
0
 public bool ValidBranch(int number, out GitBranch branch)
 {
     if (number > 0 && number <= Branches.Count)
     {
         branch = Branches[number - 1];
         return(true);
     }
     branch = null;
     return(false);
 }
Beispiel #2
0
 private void DeleteOriginFeatureBranch(GitBranch branch)
 {
     if (!branch.IsFeatureBranch)
     {
         Inform("please select a feature branch to complete a feature", ConsoleColor.Red);
     }
     else
     {
         if (Confirm($"Permanently Delete REMOTE ORIGIN Branch: {branch.Branch}"))
         {
             Inform(GitCommands.DeleteRemoteFeatureBranch(branch.Branch));
         }
     }
 }
Beispiel #3
0
 //this flow is designed to work with repositories that are running pull-requests
 //on the develop branch. as such we do not run a git-flow feature finish locally
 // as it wont be accepted into the server workflow.
 // the developer will do a pull request, and when it is completed on the server
 // do a cleanup of the local branch, removing remote tracking and dropping the
 // branches
 private void DeleteFeatureBranch(GitBranch branch)
 {
     if (!branch.IsFeatureBranch)
     {
         Inform("please select a feature branch to complete a feature", ConsoleColor.Red);
     }
     else
     {
         if (Confirm($"Permanently Delete Branch: {branch.Branch}"))
         {
             Inform(GitCommands.DeleteFeatureBranch(branch.Branch, git.ActiveBranch.Branch.ToLower() != "develop"));
         }
     }
 }
Beispiel #4
0
        //cmdSwitch has some options in relation to switching branches
        //   s perform stash backup before moving to a new branch so you can recover the work
        //
        //   sp stash all work and switch to a new branch and pop it
        //      ideal if you are accidentally coding in the wrong branch and haven't committed
        //   sa stash and apply to new branch, but leave the stash available
        //   ff if the branch is a feature, then finish and close up the feature branch
        //      only do this if the pullrequest and remote doesnt exist
        private void ProcessBranchCommand(GitBranch gitBranch, CmdLine cmdSwitch)
        {
            if (gitBranch.Branch.ToLower().Equals("master"))
            {
                Inform("Switching to master branch is not supported in this tool");
                return;
            }
            if (cmdSwitch.HasArg("FF") || cmdSwitch.HasArg("FFF"))
            {
                DeleteFeatureBranch(gitBranch);

                if (cmdSwitch.HasArg("FFF"))
                {
                    DeleteOriginFeatureBranch(gitBranch);
                }
                return;
            }

            if (!gitBranch.IsActive)
            {
                //                render.WriteLn("S -> will create a stash before switching");
                //               render.WriteLn("SP-> will create a stash and apply the stash in the new branch and delete the stash");
                //              render.WriteLn("SA-> will create a stash and apply the stash in the new branch and preserve the stash");

                StashKind stashKind = StashKind.None;

                if (cmdSwitch.HasArg("S"))
                {
                    stashKind = StashKind.Stash;
                }
                else
                if (cmdSwitch.HasArg("SP"))
                {
                    stashKind = StashKind.StashAndPop;
                }
                else
                if (cmdSwitch.HasArg("SA"))
                {
                    stashKind = StashKind.StashAndApply;
                }

                Inform(GitCommands.CheckoutBranch(gitBranch.Branch, stashKind));
            }
        }
Beispiel #5
0
        public void ParseBranch(string branches)
        {
            Branches.Clear();
            LocalBranches.Clear();
            OriginBranches.Clear();
            GitBranch gitBranch;

            ActiveBranch = null;
            var branchList = branches.Split("\n");

            for (var i = 0; i < branchList.Length; i++)
            {
                var branch = GitBranch.SanitizeName(branchList[i]);
                if (branch.Contains("->"))
                {
                    continue;
                }
                if (branch.Trim() == "")
                {
                    continue;
                }
                if (branchList[i].Contains('*'))
                {
                    gitBranch    = new GitBranch(GitBranch.CommonName(branch), true);
                    ActiveBranch = gitBranch;
                }
                else
                {
                    gitBranch = new GitBranch(GitBranch.CommonName(branch));
                }

                if (GitBranch.IsOrigin(branch))
                {
                    OriginBranches.Add(gitBranch);
                }
                else
                {
                    LocalBranches.Add(gitBranch);
                }
                Branches.AddDistinct(gitBranch);
            }
        }