Exemplo n.º 1
0
        private static void MakeNewBranch()
        {
            string suggestedPrefix = "u/" + Environment.GetEnvironmentVariable("USERNAME") + "/";

            OldLogger.Log("\r\nPrefix? [" + suggestedPrefix + "] : ");
            string prefix = Console.ReadLine().Trim().ToLower().Replace('_', '-').Replace(' ', '-');

            if (string.IsNullOrEmpty(prefix))
            {
                prefix = suggestedPrefix;
            }
            OldLogger.Log("Short name : ");
            string shortName = Console.ReadLine().Trim().ToLower().Replace('_', '-').Replace(' ', '-');

            if (string.IsNullOrEmpty(shortName))
            {
                OldLogger.LogLine("Short name must be provided!", OldLogger.LevelValue.Error);
                return;
            }
            string branchName = string.Join("/", string.Join("/", new string[] { prefix, shortName }).Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries));

            string suggestedBasedOn = GitOperations.GetBranchBase(GitOperations.GetCurrentBranchName());

            if (string.IsNullOrEmpty(suggestedBasedOn))
            {
                suggestedBasedOn = GetDefaultBranch();
            }
            OldLogger.Log("Based on what branch? [" + suggestedBasedOn + "] : ");
            string basedOn = Console.ReadLine().Trim();

            if (string.IsNullOrEmpty(basedOn))
            {
                basedOn = suggestedBasedOn;
            }

            string remoteBranchName = "origin/" + branchName;

            OldLogger.LogLine("Confirming new branch called " + branchName + " based on " + basedOn);
            OldLogger.LogLine("This will also be tracking " + remoteBranchName);
            OldLogger.Log("That look ok? [y] ");
            string prompt = Console.ReadKey().KeyChar.ToString().Trim().ToLower();

            OldLogger.LogLine(string.Empty);
            if (string.IsNullOrEmpty(prompt))
            {
                prompt = "y";
            }
            if (prompt == "y")
            {
                CreateBranch(branchName, basedOn);
            }
        }
Exemplo n.º 2
0
 public BranchInfo(string name)
 {
     this.Name             = name;
     this.ParentBranchName = GitOperations.GetBranchBase(name);
 }