public static void ShowSubmitted(IWin32Window owner, string change) { var form = new FormGerritChangeSubmitted(); form._NO_TRANSLATE_TargetLabel.Text = change; form._NO_TRANSLATE_TargetLabel.Click += (s, e) => Process.Start(change); form.ShowDialog(owner); }
private bool PublishChange(IWin32Window owner) { string branch = _NO_TRANSLATE_Branch.Text.Trim(); if (string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text)) { MessageBox.Show(owner, _selectRemote.Text); return(false); } if (string.IsNullOrEmpty(branch)) { MessageBox.Show(owner, _selectBranch.Text); return(false); } GerritUtil.StartAgent(owner, Module, _NO_TRANSLATE_Remotes.Text); string targetRef = PublishDraft.Checked ? "drafts" : "publish"; var pushCommand = UICommands.CreateRemoteCommand(); string targetBranch = "refs/" + targetRef + "/" + branch; string topic = _NO_TRANSLATE_Topic.Text.Trim(); if (!string.IsNullOrEmpty(topic)) { targetBranch += "/" + topic; } pushCommand.CommandText = PushCmd( _NO_TRANSLATE_Remotes.Text, targetBranch); pushCommand.Remote = _NO_TRANSLATE_Remotes.Text; pushCommand.Title = _publishCaption.Text; pushCommand.Execute(); if (!pushCommand.ErrorOccurred) { bool hadNewChanges = false; string change = null; foreach (string line in pushCommand.CommandOutput.Split('\n')) { if (hadNewChanges) { change = line; const string remotePrefix = "remote:"; if (change.StartsWith(remotePrefix)) { change = change.Substring(remotePrefix.Length); } int escapePos = change.LastIndexOf((char)27); if (escapePos != -1) { change = change.Substring(0, escapePos); } change = change.Trim(); int spacePos = change.IndexOf(' '); if (spacePos != -1) { change = change.Substring(0, spacePos); } break; } else if (line.Contains("New Changes")) { hadNewChanges = true; } } if (change != null) { FormGerritChangeSubmitted.ShowSubmitted(owner, change); } } return(true); }
private bool PublishChange(IWin32Window owner) { string branch = _NO_TRANSLATE_Branch.Text.Trim(); if (string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text)) { MessageBox.Show(owner, _selectRemote.Text); return(false); } if (string.IsNullOrEmpty(branch)) { MessageBox.Show(owner, _selectBranch.Text); return(false); } GerritUtil.StartAgent(owner, Module, _NO_TRANSLATE_Remotes.Text); List <string> additionalOptions = new List <string>(); additionalOptions.Add(((KeyValuePair <string, string>)PublishType.SelectedItem).Value); string reviewers = _NO_TRANSLATE_Reviewers.Text.Trim(); if (!string.IsNullOrEmpty(reviewers)) { additionalOptions.AddRange(reviewers.Split(new[] { ' ', ',', ';', '|' }) .Where(r => !string.IsNullOrEmpty(r)) .Select(r => "r=" + r)); } string cc = _NO_TRANSLATE_Cc.Text.Trim(); if (!string.IsNullOrEmpty(cc)) { additionalOptions.AddRange(cc.Split(new[] { ' ', ',', ';', '|' }) .Where(r => !string.IsNullOrEmpty(r)) .Select(r => "cc=" + r)); } string topic = _NO_TRANSLATE_Topic.Text.Trim(); if (!string.IsNullOrEmpty(topic)) { additionalOptions.Add("topic=" + topic); } string hashtag = _NO_TRANSLATE_Hashtag.Text.Trim(); if (!string.IsNullOrEmpty(hashtag)) { additionalOptions.Add("hashtag=" + hashtag); } additionalOptions = additionalOptions.Where(r => !string.IsNullOrEmpty(r)).ToList(); string targetBranch = "refs/for/" + branch; if (additionalOptions.Count > 0) { targetBranch += "%" + string.Join(",", additionalOptions); } var pushCommand = UICommands.CreateRemoteCommand(); pushCommand.CommandText = PushCmd( _NO_TRANSLATE_Remotes.Text, targetBranch); pushCommand.Remote = _NO_TRANSLATE_Remotes.Text; pushCommand.Title = _publishCaption.Text; pushCommand.Execute(); if (!pushCommand.ErrorOccurred) { bool hadNewChanges = false; string change = null; foreach (string line in pushCommand.CommandOutput.Split('\n')) { if (hadNewChanges) { const char esc = (char)27; change = line .RemovePrefix("remote:") .SubstringUntilLast(esc) .Trim() .SubstringUntil(' '); break; } else if (line.Contains("New Changes")) { hadNewChanges = true; } } if (change != null) { FormGerritChangeSubmitted.ShowSubmitted(owner, change); } } return(true); }
private bool PublishChange(IWin32Window owner) { string branch = _NO_TRANSLATE_Branch.Text.Trim(); if (string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text)) { MessageBox.Show(owner, _selectRemote.Text); return(false); } if (string.IsNullOrEmpty(branch)) { MessageBox.Show(owner, _selectBranch.Text); return(false); } GerritUtil.StartAgent(owner, Module, _NO_TRANSLATE_Remotes.Text); string targetRef = PublishDraft.Checked ? "drafts" : "publish"; var pushCommand = UICommands.CreateRemoteCommand(); string targetBranch = "refs/" + targetRef + "/" + branch; string topic = _NO_TRANSLATE_Topic.Text.Trim(); if (!string.IsNullOrEmpty(topic)) { targetBranch += "/" + topic; } string reviewers = _NO_TRANSLATE_Reviewers.Text.Trim(); if (!string.IsNullOrEmpty(reviewers)) { string formattedReviewers = string.Join(",", reviewers.Split(' ') .Where(r => !string.IsNullOrEmpty(r)) .Select(r => "r=" + r)); if (!formattedReviewers.IsNullOrEmpty()) { targetBranch += "%" + formattedReviewers; } } pushCommand.CommandText = PushCmd( _NO_TRANSLATE_Remotes.Text, targetBranch); pushCommand.Remote = _NO_TRANSLATE_Remotes.Text; pushCommand.Title = _publishCaption.Text; pushCommand.Execute(); if (!pushCommand.ErrorOccurred) { bool hadNewChanges = false; string change = null; foreach (string line in pushCommand.CommandOutput.Split('\n')) { if (hadNewChanges) { const char esc = (char)27; change = line .RemovePrefix("remote:") .SubstringUntilLast(esc) .Trim() .SubstringUntil(' '); break; } else if (line.Contains("New Changes")) { hadNewChanges = true; } } if (change != null) { FormGerritChangeSubmitted.ShowSubmitted(owner, change); } } return(true); }