Exemple #1
0
        internal static string CreateStash(string s, bool keepCode)
        {
            var msg      = '"' + s + '"';
            var sKeepCmd = keepCode ? " &&  git stash apply " : "";

            return(ExecuteShell.RunCmdProcess($"git stash push -u  -m {msg} {sKeepCmd} ", false));
        }
Exemple #2
0
        public static string ApplyStash(int number, bool dropStash)
        {
            var stash = "stash@{" + number.ToString() + "}";
            var cmd   = dropStash ? "pop" : "apply";

            return(ExecuteShell.RunCmdProcess($"git stash {cmd} {stash} ", false));
        }
Exemple #3
0
        public static string DeleteFeatureBranch(string branch, bool switchToDevelop)
        {
            string before = "";

            if (switchToDevelop)
            {
                before = "git checkout develop && ";
            }

            return(ExecuteShell.RunCmdProcess($"{before} git branch -d {branch}", false));
        }
Exemple #4
0
        public static string CheckoutBranch(string branch, StashKind stashKind)
        {
            string before = "";
            string after  = "";

            switch (stashKind)
            {
            case StashKind.Stash:
                before = $"git stash push -u -m \"khGit auto-switch-stash {DateTime.Now.ToString()}\"  &&  ";
                break;

            case StashKind.StashAndPop:
                before = $"git stash push -u && ";
                after  = "&&  git stash pop";
                break;

            case StashKind.StashAndApply:
                before = $"git stash push -u -m \"khGit auto-switch-stash {DateTime.Now.ToString()}\" &&  ";
                after  = "&&  git stash apply";
                break;
            }
            return(ExecuteShell.RunCmdProcess($"{before} git checkout {branch} {after}", false));
        }
Exemple #5
0
        //this is the main command processing loop
        private void ProcessCommands(CmdLine cmdLine)
        {
            var       cmd = cmdLine.FirstCommand;
            GitBranch branch;
            Int32     branchNum = cmdLine.FirstNumber;

            if (cmd.ToLower() == "git")
            {
                ExecuteShell.RunCmdProcess(cmdLine.FullCommand, false);
                return;
            }

            // if the primary command is a number then we are performing an action
            // based on a branch. any invalid numbers will be ignored
            if (branchNum != -1)
            {
                if (git.ValidBranch(branchNum, out branch))
                {
                    ProcessBranchCommand(branch, cmdLine);
                }
                else
                {
                    Warn($"{branchNum} does not correspond to a branch");
                }
            }
            else
            {
                switch (cmd)
                {
                case "i":
                    //this will only occurr if there is no develop branch.
                    CreateDevelop();
                    break;

                case "/?":
                case "--help":
                    //no help yet as it is built into the view for simple reminder use
                    ShowHelp();
                    break;

                case "exit":
                case "":
                    CloseApp = true;
                    break;

                case "s":
                    //run the stash menu subloop for apply/delete/pop stash
                    ShowStashMenu(cmdLine);
                    break;

                case "p":
                    Inform(GitCommands.PruneRemotes());
                    break;

                case "f":
                    var featureName = "";
                    // a feature can be run in the form of :
                    // f this is a feature
                    // will will run a new feature called this-is-a-feature
                    if (cmdLine.Count > 1)
                    {
                        featureName = String.Join("-", cmdLine.commands, 1, cmdLine.Count - 1);
                    }
                    //if feature name is empty then we will request a name
                    CreateFeatureBranch(featureName);
                    break;

                default:
                    Console.WriteLine("Unknown Command");
                    break;
                }
            }
        }
Exemple #6
0
 public static string DeleteRemoteFeatureBranch(string branch)
 {
     return(ExecuteShell.RunCmdProcess($"git push origin --delete {branch}", false));
 }
Exemple #7
0
 public static string PruneRemotes() => ExecuteShell.RunCmdProcess("git remote prune origin", false);
Exemple #8
0
 public static string GetAllBranches() => ExecuteShell.RunCmdProcess("git branch && git branch --list -r");
Exemple #9
0
 public static string GetUserDetails() => ExecuteShell.RunCmdProcess("git config user.name && git config user.email").Replace("\n", ",");
Exemple #10
0
        public static string CreateFeatureBranch(string branchName)
        {
            var s = $"git checkout develop &&  git checkout -b feature/{branchName} && git push -u origin feature/{branchName}  ";

            return(ExecuteShell.RunCmdProcess(s, false));
        }
Exemple #11
0
 public static string CreateDevelopBranch() => ExecuteShell.RunCmdProcess("git checkout master && git branch develop && git push -u origin develop && git checkout develop", false);
Exemple #12
0
 public static string GetBranchList() => ExecuteShell.RunCmdProcess("git branch");
Exemple #13
0
        public static string DropStash(int number)
        {
            var stash = "stash@{" + number.ToString() + "}";

            return(ExecuteShell.RunCmdProcess($"git stash drop {stash} ", false));
        }
Exemple #14
0
 public static string GetStashList() => ExecuteShell.RunCmdProcess($"git stash list");