public static void ForceCheckout(this Branch branch) { branch.Checkout(new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force }); }
public static Branch CreatePullRequest(this IRepository repository, string from, string to, int prNumber = 2, bool isRemotePr = true) { repository.Checkout(to); repository.MergeNoFF(from); repository.CreateBranch("pull/" + prNumber + "/merge").Checkout(); repository.Checkout(to); repository.Reset(ResetMode.Hard, "HEAD~1"); var pullBranch = repository.Checkout("pull/" + prNumber + "/merge"); if (isRemotePr) { // If we delete the branch, it is effectively the same as remote PR repository.Branches.Remove(from); } return pullBranch; }
public static void UpdateRepository(this IRepository git, string committishOrBranchSpec) { git.RemoveUntrackedFiles(); git.Reset(ResetMode.Hard); git.Fetch(git.Network.Remotes.First().Name, new FetchOptions { TagFetchMode = TagFetchMode.None }); // TODO: Check out correct branch if needed git.Checkout(committishOrBranchSpec, new CheckoutOptions(), Program.GitSignature); }
public static Commit CreatePullRequestRef(this IRepository repository, string from, string to, int prNumber = 2, bool normalise = false, bool allowFastFowardMerge = false) { repository.Checkout(repository.FindBranch(to).Tip); if (allowFastFowardMerge) { repository.Merge(repository.FindBranch(from), Constants.SignatureNow()); } else { repository.MergeNoFF(from); } var commit = repository.Head.Tip; repository.Refs.Add("refs/pull/" + prNumber + "/merge", commit.Id); repository.Checkout(to); if (normalise) { // Turn the ref into a real branch repository.Checkout(repository.Branches.Add("pull/" + prNumber + "/merge", commit)); } return commit; }
public static bool TryCheckout(this Repository repository, Branch branch, bool force = false) { CheckoutOptions options = new CheckoutOptions(); if (force) { options.CheckoutModifiers = CheckoutModifiers.Force; } try { var checkoutBranch = repository.Checkout(branch, options); GitFlowExtensions.Log("Checked out Branch : " + checkoutBranch.FriendlyName); } catch (CheckoutConflictException conflict) { GitFlowExtensions.LogError("Checkout Failed", conflict.Message); return false; } return true; }
public static void ForceCheckout(this Branch branch) { branch.Checkout(CheckoutModifiers.Force, null, null); }