Exemplo n.º 1
0
 public static string[] getRemoteNames(out bool success)
 {
     string[] cmds = new string[1];
     cmds[0] = g("remote -v");
     string[] feedback = CMD.CMDcmdsLines(cmds, false);
     success = true;
     for (int i = 0; i < feedback.Length; i++)
     {
         if (feedback[i].Contains("fatal:"))
         {
             success = false;
         }
     }
     if (success)
     {
         //worked now filter out to find those branch names ye ken
         string[] filtered = new string[feedback.Length - 1];
         for (int i = 0; i < filtered.Length; i++)
         {
             int k = i + 1;
             filtered[i] = filterOriginName(feedback[k]);
         }
         return(StringFilter.FindDouble(filtered));
     }
     else
     {
         string err = "ERROR GIT MIGHT NOT BE INITIALISED";
         UI.giveWarning(err);
         return(new string[] { err });
     }
 }
Exemplo n.º 2
0
 public static string[] getAllBranchNames()
 {
     string[] c = new string[1];
     c[0] = git.g("branch");
     string[] feedback = CMD.CMDcmdsLines(c, false);
     //now filter
     string[] cleaned = new string[feedback.Length - 1];
     for (int i = 0; i < feedback.Length - 1; i++)
     {
         int k = i + 1;
         cleaned[i] = StringFilter.filterAstrix(feedback[k]);
     }
     //now to rid of empty entries
     string[] emptied = removeEmpty(cleaned);
     if (emptied.Length == 0)
     {
         //nothing so we must return the current branch
         string curBranch = Settings.curBranchN;
         return(new string[] { curBranch });
     }
     else
     {
         return(emptied);
     }
 }
Exemplo n.º 3
0
 private static void Merge(string branch, bool squash)
 {
     string[] cmds = new string[2];
     cmds[0] = git.g("checkout " + branch);//checkout this one
     if (squash == false)
     {
         cmds[1] = git.g("merge " + Settings.curBranchN);//merge this one in, regular fast forward
     }
     else
     {
         cmds[1] = git.g("merge --squash" + Settings.curBranchN);
     }
     string[] lineoutput = CMD.CMDcmdsLines(cmds, true);
 }
Exemplo n.º 4
0
 public static void CheckoutBranch(string branchname, bool newb)
 {
     curBranchN = branchname;
     string[] cmnds = new string[1];
     if (newb)
     {
         cmnds[0] = git.g("checkout -b " + branchname);
     }
     else
     {
         cmnds[0] = git.g("checkout " + branchname);
     }
     string[] lineoutput = CMD.CMDcmdsLines(cmnds, true);
     SaveConfig();
 }
Exemplo n.º 5
0
        public static void PushAll(string msg)
        {
            GitIgnore.GitIgnorecheck();

            string[] strCmds = new string[3];
            strCmds[0] = git.g("add --all");
            strCmds[1] = git.g("commit -m \"" + msg + "\"");
            for (int i = 0; i < Settings.curRemote.Count; i++)
            {
                int k = 2 + i;
                strCmds[k] = git.g("push " + Settings.curRemote[i] + " " + Settings.curBranchN);
            }
            //execute
            string[] lineoutput = CMD.CMDcmdsLines(strCmds, true);
        }
Exemplo n.º 6
0
 public static string getBranchFeedback(out bool success)
 {
     string[] cmds = new string[1];
     cmds[0] = g("branch --show-current");
     string[] feedback = CMD.CMDcmdsLines(cmds, false);
     success = true;
     for (int i = 0; i < feedback.Length; i++)
     {
         if (feedback[i].Contains("fatal:"))
         {
             success = false;
         }
     }
     if (success)
     {
         return(feedback[1]);
     }
     else
     {
         string err = "ERROR GIT MIGHT NOT BE INITIALISED";
         UI.giveWarning(err);
         return(err);
     }
 }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            //version info print
            VersionController.WriteVersion();
            //find out OS
            OS.IdentifyOS();
            OS.PrintOS();
            UI.blank(1);

            //now check if there is an init folder
            git.IsInit();

            while (true)
            {
                bool workedReading = Settings.Read();
                //Settings.ChangeCurBranch("thisbranch");//can change branch like this
                if (!workedReading)
                {
                    UI.red();
                    Console.WriteLine("Couldn't read config file in:");
                    Console.WriteLine(" " + Settings.configFN);
                    Console.WriteLine("aborting...");
                    UI.white();
                    //give offer to return default file
                }
                else
                {
                    Console.WriteLine();
                    //now ask about pushing
                    Console.WriteLine("give commit message for auto push or enter a setting");
                    Console.WriteLine("Settings are:");
                    UI.green();
                    Console.WriteLine("(b)    create/checkout branch from current and be pushing to this");
                    Console.WriteLine("(r)    change remote to commit on");
                    Console.WriteLine("(ar)   add remote to commit on");
                    Console.WriteLine("(rr)   remove remote to commit on");
                    Console.WriteLine("(m)    merge current branch to another");
                    Console.WriteLine("(cmd)  pure cmd input");
                    Console.WriteLine("(l)    see license info");
                    Console.WriteLine("(help) help!");
                    Console.WriteLine("(q)    quit program");
                    UI.white();

                    string resp = Console.ReadLine();
                    if (resp == "r")
                    {
                        Settings.PromptChangeRemote();
                    }
                    else if (resp == "ar")
                    {
                        Settings.PromptAddRemote();
                    }
                    else if (resp == "rr")
                    {
                        Settings.RemoveRemote();
                    }
                    else if (resp == "b")
                    {
                        Settings.PromptCheckoutNB();
                    }
                    else if (resp == "m")
                    {
                        git.PromptMerge();
                    }
                    else if (resp == "cmd")
                    {
                        Console.WriteLine("Give command for cmd to run");
                        string[] cmds = new string[1];
                        cmds[0] = Console.ReadLine();
                        string[] lineoutput = CMD.CMDcmdsLines(cmds, true);
                    }
                    else if (resp == "l")
                    {
                        Licence.DisplayScreen();
                    }
                    else if (resp == "help")
                    {
                        DisplayHelp();
                    }
                    else if (resp == "q")
                    {
                        ExitPrint();
                        break;
                    }
                    else
                    {
                        git.PushAll(resp);
                    }
                }
                Console.WriteLine();
            }
            //all done either reloop or quit
        }
Exemplo n.º 8
0
 static void Initalise()
 {
     string[] commands = new string[1];
     commands[0] = git.g("init");
     string[] lineoutput = CMD.CMDcmdsLines(commands, true);
 }