private string GetTagVerificationMessage(IGitRef tagRef, bool raw = true) { string tagName = tagRef.LocalName; if (string.IsNullOrWhiteSpace(tagName)) { return(null); } string rawFlag = raw ? "--raw" : ""; var module = GetModule(); return(module.RunGitCmd($"verify-tag {rawFlag} {tagName}")); }
private string GetTagVerificationMessage(IGitRef tagRef, bool raw = true) { string tagName = tagRef.LocalName; if (string.IsNullOrWhiteSpace(tagName)) { return(null); } var module = GetModule(); var args = new GitArgumentBuilder("verify-tag") { { raw, "--raw" }, tagName }; return(module.RunGitCmd(args)); }
public FormCreateBranch(GitUICommands commands, ObjectId objectId, string newBranchNamePrefix = null) : base(commands, enablePositionRestore: false) { InitializeComponent(); // work-around the designer bug that can't add controls to FlowLayoutPanel ControlsPanel.Controls.Add(Ok); AcceptButton = Ok; InitializeComplete(); groupBox1.AutoSize = true; if (objectId is not null && objectId.IsArtificial) { objectId = null; } commitSummaryUserControl1.Revision = null; objectId ??= Module.GetCurrentCheckout(); if (objectId is not null) { commitPickerSmallControl1.SetSelectedCommitHash(objectId.ToString()); if (string.IsNullOrWhiteSpace(newBranchNamePrefix)) { GitRevision revision = Module.GetRevision(objectId, shortFormat: true, loadRefs: true); IGitRef firstRef = revision.Refs.FirstOrDefault(r => !r.IsTag) ?? revision.Refs.FirstOrDefault(r => r.IsTag); newBranchNamePrefix = firstRef?.LocalName; commitSummaryUserControl1.Revision = revision; } } if (!string.IsNullOrWhiteSpace(newBranchNamePrefix)) { BranchNameTextBox.Text = newBranchNamePrefix; } }
public TagNode(Tree aTree, string aFullPath, IGitRef tagInfo) : base(aTree, aFullPath) { _tagInfo = tagInfo; }
public TagNode(Tree tree, string fullPath, IGitRef tagInfo) : base(tree, fullPath) { _tagInfo = tagInfo; }
private DialogResult OkClick() { // Ok button set as the "AcceptButton" for the form // if the user hits [Enter] at any point, we need to trigger txtCustomBranchName Leave event Ok.Focus(); GitCheckoutBranchCmd cmd = new GitCheckoutBranchCmd(Branches.Text.Trim(), Remotebranch.Checked); if (Remotebranch.Checked) { if (rbCreateBranchWithCustomName.Checked) { cmd.NewBranchName = txtCustomBranchName.Text.Trim(); cmd.NewBranchAction = GitCheckoutBranchCmd.NewBranch.Create; if (cmd.NewBranchName.IsNullOrWhiteSpace()) { MessageBox.Show(_customBranchNameIsEmpty.Text, Text); DialogResult = DialogResult.None; return(DialogResult.None); } if (!Module.CheckBranchFormat(cmd.NewBranchName)) { MessageBox.Show(string.Format(_customBranchNameIsNotValid.Text, cmd.NewBranchName), Text); DialogResult = DialogResult.None; return(DialogResult.None); } } else if (rbResetBranch.Checked) { IGitRef localBranchRef = GetLocalBranchRef(_localBranchName); IGitRef remoteBranchRef = GetRemoteBranchRef(cmd.BranchName); if (localBranchRef != null && remoteBranchRef != null) { string mergeBaseGuid = Module.GetMergeBase(localBranchRef.Guid, remoteBranchRef.Guid); bool isResetFastForward = localBranchRef.Guid.Equals(mergeBaseGuid); if (!isResetFastForward) { string mergeBaseText = mergeBaseGuid.IsNullOrWhiteSpace() ? "merge base" : GitRevision.ToShortSha(mergeBaseGuid); string warningMessage = string.Format(_resetNonFastForwardBranch.Text, _localBranchName, mergeBaseText); if (MessageBox.Show(this, warningMessage, _resetCaption.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { DialogResult = DialogResult.None; return(DialogResult.None); } } } cmd.NewBranchAction = GitCheckoutBranchCmd.NewBranch.Reset; cmd.NewBranchName = _localBranchName; } else { cmd.NewBranchAction = GitCheckoutBranchCmd.NewBranch.DontCreate; cmd.NewBranchName = null; } } LocalChangesAction changes = ChangesMode; if (changes != LocalChangesAction.Reset && chkSetLocalChangesActionAsDefault.Checked) { AppSettings.CheckoutBranchAction = changes; } if ((Visible || AppSettings.UseDefaultCheckoutBranchAction) && HasUncommittedChanges) { cmd.LocalChanges = changes; } else { cmd.LocalChanges = LocalChangesAction.DontChange; } IWin32Window owner = Visible ? this : Owner; bool stash = false; if (changes == LocalChangesAction.Stash) { if (_isDirtyDir == null && Visible) { _isDirtyDir = Module.IsDirtyDir(); } stash = _isDirtyDir == true; if (stash) { UICommands.StashSave(owner, AppSettings.IncludeUntrackedFilesInAutoStash); } } var originalHash = Module.GetCurrentCheckout(); ScriptManager.RunEventScripts(this, ScriptEvent.BeforeCheckout); if (UICommands.StartCommandLineProcessDialog(cmd, owner)) { if (stash) { bool?messageBoxResult = AppSettings.AutoPopStashAfterCheckoutBranch; if (messageBoxResult == null) { DialogResult res = cTaskDialog.MessageBox( this, _applyShashedItemsAgainCaption.Text, "", _applyShashedItemsAgain.Text, "", "", _dontShowAgain.Text, eTaskDialogButtons.YesNo, eSysIcons.Question, eSysIcons.Question); messageBoxResult = res == DialogResult.Yes; if (cTaskDialog.VerificationChecked) { AppSettings.AutoPopStashAfterCheckoutBranch = messageBoxResult; } } if (messageBoxResult ?? false) { UICommands.StashPop(this); } } var currentHash = Module.GetCurrentCheckout(); if (!string.Equals(originalHash, currentHash, StringComparison.OrdinalIgnoreCase)) { UICommands.UpdateSubmodules(this); } ScriptManager.RunEventScripts(this, ScriptEvent.AfterCheckout); return(DialogResult.OK); } return(DialogResult.None); }
private DialogResult OkClick() { // Ok button set as the "AcceptButton" for the form // if the user hits [Enter] at any point, we need to trigger txtCustomBranchName Leave event Ok.Focus(); var branchName = Branches.Text.Trim(); var isRemote = Remotebranch.Checked; var newBranchName = (string)null; var newBranchMode = CheckoutNewBranchMode.DontCreate; if (isRemote) { if (rbCreateBranchWithCustomName.Checked) { newBranchName = txtCustomBranchName.Text.Trim(); newBranchMode = CheckoutNewBranchMode.Create; if (string.IsNullOrWhiteSpace(newBranchName)) { MessageBox.Show(_customBranchNameIsEmpty.Text, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; return(DialogResult.None); } if (!Module.CheckBranchFormat(newBranchName)) { MessageBox.Show(string.Format(_customBranchNameIsNotValid.Text, newBranchName), Text, MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; return(DialogResult.None); } } else if (rbResetBranch.Checked) { IGitRef localBranchRef = GetLocalBranchRef(_localBranchName); IGitRef remoteBranchRef = GetRemoteBranchRef(branchName); if (localBranchRef != null && remoteBranchRef != null) { var mergeBaseGuid = Module.GetMergeBase(localBranchRef.ObjectId, remoteBranchRef.ObjectId); var isResetFastForward = localBranchRef.ObjectId == mergeBaseGuid; if (!isResetFastForward) { string mergeBaseText = mergeBaseGuid == null ? "merge base" : mergeBaseGuid.ToShortString(); string warningMessage = string.Format(_resetNonFastForwardBranch.Text, _localBranchName, mergeBaseText); if (MessageBox.Show(this, warningMessage, _resetCaption.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { DialogResult = DialogResult.None; return(DialogResult.None); } } } newBranchMode = CheckoutNewBranchMode.Reset; newBranchName = _localBranchName; } else { newBranchMode = CheckoutNewBranchMode.DontCreate; } } var localChanges = ChangesMode; if (localChanges != LocalChangesAction.Reset && chkSetLocalChangesActionAsDefault.Checked) { AppSettings.CheckoutBranchAction = localChanges; } if ((!Visible && !AppSettings.UseDefaultCheckoutBranchAction) || !HasUncommittedChanges) { localChanges = LocalChangesAction.DontChange; } IWin32Window owner = Visible ? this : Owner; bool stash = false; if (localChanges == LocalChangesAction.Stash) { if (_isDirtyDir == null && Visible) { _isDirtyDir = Module.IsDirtyDir(); } stash = _isDirtyDir == true; if (stash) { UICommands.StashSave(owner, AppSettings.IncludeUntrackedFilesInAutoStash); } } var originalId = Module.GetCurrentCheckout(); Debug.Assert(originalId != null, "originalId != null"); ScriptManager.RunEventScripts(this, ScriptEvent.BeforeCheckout); if (UICommands.StartCommandLineProcessDialog(owner, new GitCheckoutBranchCmd(branchName, isRemote, localChanges, newBranchMode, newBranchName))) { if (stash) { bool?messageBoxResult = AppSettings.AutoPopStashAfterCheckoutBranch; if (messageBoxResult == null) { using var dialog = new TaskDialog { OwnerWindowHandle = Handle, Text = _applyStashedItemsAgain.Text, Caption = _applyStashedItemsAgainCaption.Text, Icon = TaskDialogStandardIcon.Information, StandardButtons = TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No, FooterCheckBoxText = _dontShowAgain.Text, FooterIcon = TaskDialogStandardIcon.Information, StartupLocation = TaskDialogStartupLocation.CenterOwner }; messageBoxResult = dialog.Show() == TaskDialogResult.Yes; if (dialog.FooterCheckBoxChecked == true) { AppSettings.AutoPopStashAfterCheckoutBranch = messageBoxResult; } } if (messageBoxResult ?? false) { UICommands.StashPop(this); } } var currentId = Module.GetCurrentCheckout(); if (originalId != currentId) { UICommands.UpdateSubmodules(this); } ScriptManager.RunEventScripts(this, ScriptEvent.AfterCheckout); return(DialogResult.OK); } return(DialogResult.None); IGitRef GetLocalBranchRef(string name) { return(GetLocalBranches().FirstOrDefault(head => head.Name.Equals(name, StringComparison.OrdinalIgnoreCase))); } IGitRef GetRemoteBranchRef(string name) { return(GetRemoteBranches().FirstOrDefault(head => head.Name.Equals(name, StringComparison.OrdinalIgnoreCase))); } }
private void comboBoxTags_TextChanged(object sender, EventArgs e) { if (comboBoxTags.DataSource == null) { return; } _selectedTag = DataSourceToGitRefs(comboBoxTags).FirstOrDefault(a => a.LocalName == comboBoxTags.Text); SetSelectedRevisionByFocusedControl(); }
private void comboBoxTags_SelectionChangeCommitted(object sender, EventArgs e) { if (comboBoxTags.SelectedValue == null) { return; } _selectedTag = (IGitRef)comboBoxTags.SelectedValue; SetSelectedRevisionByFocusedControl(); Go(); }
public bool ShowRemoteRef(IGitRef r) { if (r.IsTag) return AppSettings.ShowSuperprojectTags; if (r.IsHead) return AppSettings.ShowSuperprojectBranches; if (r.IsRemote) return AppSettings.ShowSuperprojectRemoteBranches; return false; }
private static Color GetHeadColor(IGitRef gitRef) { if (gitRef.IsTag) return AppSettings.TagColor; if (gitRef.IsHead) return AppSettings.BranchColor; if (gitRef.IsRemote) return AppSettings.RemoteBranchColor; return AppSettings.OtherTagColor; }