private void BranchDropDown(object sender, EventArgs e) { GitModule module = new GitModule(Directory.Text); var heads = module.GetHeads(false); heads.Insert(0, GitHead.NoHead(module)); Branch.DisplayMember = "Name"; Branch.DataSource = heads; }
private void RemotesUpdated(object sender, EventArgs e) { if (TabControlTagBranch.SelectedTab == MultipleBranchTab) { UpdateMultiBranchView(); } EnableLoadSshButton(); // update the text box of the Remote Url combobox to show the URL of selected remote { string pushUrl = Module.GetPathSetting(string.Format(SettingKeyString.RemotePushUrl, _NO_TRANSLATE_Remotes.Text)); if (pushUrl.IsNullOrEmpty()) { pushUrl = Module.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, _NO_TRANSLATE_Remotes.Text)); } PushDestination.Text = pushUrl; } var pushSettingValue = Module.GetSetting(string.Format("remote.{0}.push", _NO_TRANSLATE_Remotes.Text)); if (PushToRemote.Checked && !string.IsNullOrEmpty(pushSettingValue)) { string defaultLocal = GetDefaultPushLocal(_NO_TRANSLATE_Remotes.Text); string defaultRemote = GetDefaultPushRemote(_NO_TRANSLATE_Remotes.Text); RemoteBranch.Text = ""; if (!string.IsNullOrEmpty(defaultLocal)) { var currentBranch = new GitHead(Module, null, defaultLocal, _NO_TRANSLATE_Remotes.Text); _NO_TRANSLATE_Branch.Items.Add(currentBranch); _NO_TRANSLATE_Branch.SelectedItem = currentBranch; } if (!string.IsNullOrEmpty(defaultRemote)) { RemoteBranch.Text = defaultRemote; } return; } if (string.IsNullOrEmpty(_NO_TRANSLATE_Branch.Text)) { // Doing this makes it pretty easy to accidentally create a branch on the remote. // But leaving it blank will do the 'default' thing, meaning all branches are pushed. // Solution: when pushing a branch that doesn't exist on the remote, ask what to do var currentBranch = new GitHead(Module, null, _currentBranch, _NO_TRANSLATE_Remotes.Text); _NO_TRANSLATE_Branch.Items.Add(currentBranch); _NO_TRANSLATE_Branch.SelectedItem = currentBranch; return; } BranchSelectedValueChanged(null, null); }
private void BranchesDropDown(object sender, EventArgs e) { if ((PullFromUrl.Checked && string.IsNullOrEmpty(comboBoxPullSource.Text)) && (PullFromRemote.Checked && string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text))) { Branches.DataSource = null; return; } Cursor.Current = Cursors.WaitCursor; LoadPuttyKey(); if (_heads == null) { if (PullFromUrl.Checked) { _heads = Module.GetHeads(false, true); } else { // The line below is the most reliable way to get a list containing // all remote branches but it is also the slowest. // Heads = GitCommands.GitCommands.GetRemoteHeads(Remotes.Text, false, true); // The code below is a quick way to get a list contains all remote branches. // It only returns the heads that are already known to the repository. This // doesn't return heads that are new on the server. This can be updated using // update branch info in the manage remotes dialog. _heads = new List <GitHead>(); foreach (var head in Module.GetHeads(true, true)) { if (!head.IsRemote || !head.Name.StartsWith(_NO_TRANSLATE_Remotes.Text, StringComparison.CurrentCultureIgnoreCase)) { continue; } _heads.Insert(0, head); } } } Branches.DisplayMember = "LocalName"; //_heads.Insert(0, GitHead.AllHeads); --> disable this because it is only for expert users _heads.Insert(0, GitHead.NoHead(Module)); Branches.DataSource = _heads; Cursor.Current = Cursors.Default; }
public void SelectBranch(string name) { int index = 0; foreach (object item in Branches.Items) { GitHead branch = item as GitHead; if (branch != null && branch.Name == name) { Branches.SetItemChecked(index, true); return; } index++; } }
public IEnumerable <GitHead> GetSelectedBranches() { foreach (string branch in branches.Text.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)) { GitHead gitHead = _branchesToSelect.FirstOrDefault(g => g.Name == branch); if (gitHead == null) { MessageBox.Show(string.Format(_branchCheckoutError.Text, branch)); } else { yield return(gitHead); } } }
private void RemotesUpdated(object sender, EventArgs e) { if (TabControlTagBranch.SelectedTab == MultipleBranchTab) { UpdateMultiBranchView(); } EnableLoadSshButton(); var pushSettingValue = GitCommandHelpers.GetSetting("remote." + Remotes.Text + ".push"); if (PullFromRemote.Checked && !string.IsNullOrEmpty(pushSettingValue)) { var values = pushSettingValue.Split(':'); RemoteBranch.Text = ""; if (values.Length > 0) { var currentBranch = new GitHead(null, values[0], Remotes.Text); Branch.Items.Add(currentBranch); Branch.SelectedItem = currentBranch; } if (values.Length > 1) { RemoteBranch.Text = values[1]; } return; } if (string.IsNullOrEmpty(Branch.Text)) { // Doing this makes it pretty easy to accidentally create a branch on the remote. // But leaving it blank will do the 'default' thing, meaning all branches are pushed. // Solution: when pushing a branch that doesn't exist on the remote, ask what to do var currentBranch = new GitHead(null, _currentBranch, Remotes.Text); Branch.Items.Add(currentBranch); Branch.SelectedItem = currentBranch; return; } BranchSelectedValueChanged(null, null); }
public IList <GitHead> GetSelectedBranches() { IList <GitHead> selectedBranches = new List <GitHead>(); if (!string.IsNullOrEmpty(branches.Text)) { foreach (string branch in branches.Text.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)) { GitHead gitHead = _branchesToSelect.FirstOrDefault(g => g.Name == branch); if (gitHead == null) { MessageBox.Show("Branch '" + branch + "' is not selectable, this branch has been removed from the selection."); } else { selectedBranches.Add(gitHead); } } } return(selectedBranches); }
private void OkClick(object sender, EventArgs e) { try { if (MessageBox.Show(_deleteBranchQuestion.Text, _deleteBranchCaption.Text, MessageBoxButtons.YesNo) == DialogResult.Yes) { GitHead head = Heads.Find(h => h.Name.Equals(Branches.Text)); bool isRemote; isRemote = head != null && head.IsRemote; var deleteBranchResult = GitCommandHelpers.DeleteBranch(Branches.Text, ForceDelete.Checked, isRemote); MessageBox.Show(_branchDeleted.Text + Environment.NewLine + deleteBranchResult, _deleteBranchCaption.Text); } } catch (Exception ex) { Trace.WriteLine(ex.Message); } Close(); }
private void UpdateMultiBranchView() { _branchTable = new DataTable(); _branchTable.Columns.Add("Local", typeof(string)); _branchTable.Columns.Add("Remote", typeof(string)); _branchTable.Columns.Add("New", typeof(string)); _branchTable.Columns.Add("Push", typeof(bool)); _branchTable.Columns.Add("Force", typeof(bool)); _branchTable.Columns.Add("Delete", typeof(bool)); _branchTable.ColumnChanged += BranchTable_ColumnChanged; var bs = new BindingSource { DataSource = _branchTable }; BranchGrid.DataSource = bs; string remote = Remotes.Text.Trim(); if (remote == "") { return; } List <GitHead> localHeads = GitCommandHelpers.GetHeads(false, true); List <GitHead> remoteHeads = GitCommandHelpers.GetRemoteHeads(remote, false, true); // Add all the local branches. foreach (var head in localHeads) { DataRow row = _branchTable.NewRow(); row["Force"] = false; row["Delete"] = false; row["Local"] = head.Name; string remoteName; if (head.Remote == remote) { remoteName = head.MergeWith ?? head.Name; } else { remoteName = head.Name; } row["Remote"] = remoteName; bool newAtRemote = remoteHeads.Any(h => h.Name == remoteName); row["New"] = newAtRemote ? _no.Text : _yes.Text; row["Push"] = newAtRemote; _branchTable.Rows.Add(row); } // Offer to delete all the left over remote branches. foreach (var remoteHead in remoteHeads) { GitHead head = remoteHead; if (!localHeads.Any(h => h.Name == head.Name)) { DataRow row = _branchTable.NewRow(); row["Local"] = null; row["Remote"] = remoteHead.Name; row["New"] = _no.Text; row["Push"] = false; row["Force"] = false; row["Delete"] = false; _branchTable.Rows.Add(row); } } }
/// <summary>Indicates whether this <see cref="BranchNode"/> is setup for remote tracking.</summary> public bool IsTrackingSetup(ConfigFile config) {// NOT (not whitespace) return(!string.IsNullOrWhiteSpace(config.GetValue(GitHead.RemoteSettingName(FullPath)))); }
private bool PushChanges(IWin32Window owner) { if (PullFromUrl.Checked && string.IsNullOrEmpty(PushDestination.Text)) { MessageBox.Show(owner, _selectDestinationDirectory.Text); return(false); } if (PullFromRemote.Checked && string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text)) { MessageBox.Show(owner, _selectRemote.Text); return(false); } if (TabControlTagBranch.SelectedTab == TagTab && string.IsNullOrEmpty(TagComboBox.Text) && !PushAllTags.Checked) { MessageBox.Show(owner, _selectTag.Text); return(false); } //Extra check if the branch is already known to the remote, give a warning when not. //This is not possible when the remote is an URL, but this is ok since most users push to //known remotes anyway. if (TabControlTagBranch.SelectedTab == BranchTab && PullFromRemote.Checked) { //If the current branch is not the default push, and not known by the remote //(as far as we know since we are disconnected....) if (RemoteBranch.Text != GetDefaultPushRemote(_NO_TRANSLATE_Remotes.Text) && !Module.GetHeads(true, true).Exists(x => x.Remote == _NO_TRANSLATE_Remotes.Text && x.LocalName == RemoteBranch.Text)) { //Ask if this is really what the user wants if (MessageBox.Show(owner, _branchNewForRemote.Text, _pushCaption.Text, MessageBoxButtons.YesNo) == DialogResult.No) { return(false); } } } Repositories.AddMostRecentRepository(PushDestination.Text); Settings.PushAllTags = PushAllTags.Checked; Settings.AutoPullOnRejected = AutoPullOnRejected.Checked; Settings.RecursiveSubmodulesCheck = RecursiveSubmodulesCheck.Checked; var remote = ""; string destination; if (PullFromUrl.Checked) { destination = PushDestination.Text; } else { if (GitCommandHelpers.Plink()) { if (!File.Exists(Settings.Pageant)) { MessageBox.Show(owner, _cannotLoadPutty.Text, PuttyText); } else { Module.StartPageantForRemote(_NO_TRANSLATE_Remotes.Text); } } destination = _NO_TRANSLATE_Remotes.Text; remote = _NO_TRANSLATE_Remotes.Text.Trim(); } string pushCmd; if (TabControlTagBranch.SelectedTab == BranchTab) { bool track = ReplaceTrackingReference.Checked; if (!track && !string.IsNullOrWhiteSpace(RemoteBranch.Text)) { GitHead selectedLocalBranch = _NO_TRANSLATE_Branch.SelectedItem as GitHead; track = selectedLocalBranch != null && string.IsNullOrEmpty(selectedLocalBranch.TrackingRemote); string[] remotes = _NO_TRANSLATE_Remotes.DataSource as string[]; if (remotes != null) { foreach (string remoteBranch in remotes) { if (!string.IsNullOrEmpty(remoteBranch) && _NO_TRANSLATE_Branch.Text.StartsWith(remoteBranch)) { track = false; } } } if (track) { DialogResult result = MessageBox.Show(String.Format(_updateTrackingReference.Text, selectedLocalBranch.Name, RemoteBranch.Text), _pushCaption.Text, MessageBoxButtons.YesNoCancel); if (result == DialogResult.Cancel) { return(false); } track = result == DialogResult.OK; } } pushCmd = GitCommandHelpers.PushCmd(destination, _NO_TRANSLATE_Branch.Text, RemoteBranch.Text, PushAllBranches.Checked, ForcePushBranches.Checked, track, RecursiveSubmodulesCheck.Checked); } else if (TabControlTagBranch.SelectedTab == TagTab) { pushCmd = GitCommandHelpers.PushTagCmd(destination, TagComboBox.Text, PushAllTags.Checked, ForcePushBranches.Checked); } else { // Push Multiple Branches Tab selected var pushActions = new List <GitPushAction>(); foreach (DataRow row in _branchTable.Rows) { var push = Convert.ToBoolean(row["Push"]); var force = Convert.ToBoolean(row["Force"]); var delete = Convert.ToBoolean(row["Delete"]); if (push || force) { pushActions.Add(new GitPushAction(row["Local"].ToString(), row["Remote"].ToString(), force)); } else if (delete) { pushActions.Add(new GitPushAction(row["Remote"].ToString())); } } pushCmd = GitCommandHelpers.PushMultipleCmd(destination, pushActions); } ScriptManager.RunEventScripts(Module, ScriptEvent.BeforePush); //controls can be accessed only from UI thread candidateForRebasingMergeCommit = Settings.PullMerge == Settings.PullAction.Rebase && PullFromRemote.Checked && !PushAllBranches.Checked && TabControlTagBranch.SelectedTab == BranchTab; selectedBranch = _NO_TRANSLATE_Branch.Text; selectedBranchRemote = _NO_TRANSLATE_Remotes.Text; selectedRemoteBranchName = RemoteBranch.Text; using (var form = new FormRemoteProcess(Module, pushCmd) { Remote = remote, Text = string.Format(_pushToCaption.Text, destination), HandleOnExitCallback = HandlePushOnExit }) { form.ShowDialog(owner); if (!Module.InTheMiddleOfConflictedMerge() && !Module.InTheMiddleOfRebase() && !form.ErrorOccurred()) { ScriptManager.RunEventScripts(Module, ScriptEvent.AfterPush); if (_createPullRequestCB.Checked) { UICommands.StartCreatePullRequest(owner); } return(true); } } return(false); }
public GitHeaderGuiWrapper(GitHead gitHead) { _gitHead = gitHead; }