public void Run() { if (Args.Length > 0 && (Args[0] == "-h" || Args[0] == "--help")) { ShowHelp(); return; } GitUtils.CheckIfRepository(); if (Args.Length == 0) { StartMultiSelectClean(); return; } if (Args.Length == 1 && (Args[0] == "-a" || Args[0] == "--auto")) { StartAutoClean(); return; } if (Args.Length == 3 && (Args[0] == "-a" || Args[0] == "--auto") && (Args[1] == "-p" || Args[1] == "--protect") && Args[2].Length > 0) { StartAutoClean(Args[2]); return; } HandleUnknownParam(); }
private void StartSelectCheckout() { const string selectDescription = "Select a branch to check out"; using Repository repo = new Repository(Environment.CurrentDirectory); var availableBranches = repo.Branches.OrderBy(b => b.IsRemote).ToArray(); if (availableBranches.Length < 1) { Log.Error("No branches found."); Environment.Exit(1); } string[] branchNames = availableBranches.Select(b => b.FriendlyName).ToArray(); int selectedIndex = new SimpleSelect(selectDescription, branchNames).Show(); if (selectedIndex < 0) { return; } if (availableBranches[selectedIndex].IsRemote) { CheckoutRemote(repo, availableBranches[selectedIndex]); return; } GitUtils.CheckOutBranch(repo, availableBranches[selectedIndex]); GitUtils.ShowLatestCommit(repo); }
private void StartSelectReview(Branch[] options = null) { var selectDescription = "There were more than one results. Select a branch to review:"; if (options == null) { selectDescription = "Select a branch to review"; GitUtils.PerformFetch(); } using Repository repo = new Repository(Environment.CurrentDirectory); var availableBranches = options ?? repo.Branches.Where(b => b.IsRemote).ToArray(); if (availableBranches.Length < 1) { Log.Error("No remote branches found."); Environment.Exit(1); } string[] branchNames = availableBranches.Select(b => b.FriendlyName).ToArray(); int selectedIndex = new SimpleSelect(selectDescription, branchNames).Show(); if (selectedIndex < 0) { return; } GitUtils.CheckOutBranch(repo, availableBranches[selectedIndex]); GitUtils.ShowLatestCommit(repo); }
private void CheckoutRemote(Repository repo, Branch branch) { Log.Blue("Only remote found."); GitUtils.PerformFetch(); Console.WriteLine(); GitUtils.CheckOutBranch(GetLocalName(branch)); GitUtils.ShowLatestCommit(repo); }
private void PullOriginHead() { using Repository repo = new Repository(Environment.CurrentDirectory); string currentHead = repo.Head.FriendlyName; GitUtils.PerformPull(currentHead); GitUtils.ShowLatestCommit(repo); }
public void Run() { if (Args.Length == 1 && (Args[0] == "-h" || Args[0] == "--help")) { ShowHelp(); return; } GitUtils.CheckIfRepository(); if (Args.Length == 0) { ShowUser(isGlobal: false); return; } if (Args.Length == 1 && (Args[0] == "-g" || Args[0] == "--global")) { ShowUser(isGlobal: true); return; } if (Args.Length == 1 && (Args[0] == "-p" || Args[0] == "--personal")) { SetUser(isGlobal: false, config: UserConfig.Personal); return; } if (Args.Length == 1 && (Args[0] == "-w" || Args[0] == "--work")) { SetUser(isGlobal: false, config: UserConfig.Work); return; } if ( Args.Length == 2 && (Args.Contains("-g") || Args.Contains("--global")) && (Args.Contains("-p") || Args.Contains("--personal")) ) { SetUser(isGlobal: true, config: UserConfig.Personal); return; } if ( Args.Length == 2 && (Args.Contains("-g") || Args.Contains("--global")) && (Args.Contains("-w") || Args.Contains("--work")) ) { SetUser(isGlobal: true, config: UserConfig.Work); return; } HandleUnknownParam(); }
public void Run() { if (Args.Length == 1 && (Args[0] == "-h" || Args[0] == "--help")) { ShowHelp(); return; } if (Args.Length != 0) { HandleUnknownParam(); } GitUtils.CheckIfRepository(); PullOriginHead(); }
public void RunShortcut(string action) { GitUtils.CheckIfRepository(); using Repository repo = new Repository(Environment.CurrentDirectory); Branch branch; try { branch = repo.Branches.First(b => !b.IsRemote && IsRequiredBranch(action, b)); } catch (Exception e) { if (e is InvalidOperationException) { branch = null; } else { throw; } } if (branch == null) { Log.Error("No such branch found."); return; } GitUtils.CheckOutBranch(repo, branch); GitUtils.ShowLatestCommit(repo); if (Args.Length == 1 && Args[0] == "-r") { GitUtils.PerformPull(branch.FriendlyName); GitUtils.ShowLatestCommit(repo); return; } if (Args.Length > 0) { HandleUnknownParam(); } }
private void StartCheckout(string arg) { using Repository repo = new Repository(Environment.CurrentDirectory); Branch branch; try { branch = repo.Branches .OrderBy(b => b.IsRemote) .First(b => b.FriendlyName.Contains(arg)); } catch (Exception e) { if (e is InvalidOperationException) { branch = null; } else { throw; } } if (branch == null) { Log.Error("No such branch found."); return; } if (branch.IsRemote) { CheckoutRemote(repo, branch); return; } GitUtils.CheckOutBranch(repo, branch); GitUtils.ShowLatestCommit(repo); }
private void StartReview(string arg) { GitUtils.PerformFetch(); using Repository repo = new Repository(Environment.CurrentDirectory); var results = repo.Branches .Where(b => b.IsRemote && b.FriendlyName.Contains(arg)) .ToArray(); if (results.Length == 0) { Log.Error("No such branch found."); return; } if (results.Length > 1) { StartSelectReview(results); return; } GitUtils.CheckOutBranch(repo, results[0]); GitUtils.ShowLatestCommit(repo); }
public void Run() { if (Args.Length == 1 && (Args[0] == "-h" || Args[0] == "--help")) { ShowHelp(); return; } GitUtils.CheckIfRepository(); if (Args.Length == 0) { StartSelectCheckout(); return; } if (Args.Length == 1) { StartCheckout(Args[0]); return; } HandleUnknownParam(); }