public static Parameters Parse(string str) { if (str == null) throw new ArgumentNullException("str"); str = str.Trim(); if (str.Length == 0) return new Parameters(); var dict = ParsePairs(str.Split(';')).ToDictionary( p => p.Key, p => p.Value, StringComparer.OrdinalIgnoreCase); Parameters parameters; try { parameters = new Parameters { Project = dict.TryPop("project"), User = dict.TryPop("user"), Status = dict.TryPop("status"), }; } catch (ArgumentException e) { throw new ParametersParseException(e.Message, e); } if (dict.Any()) { throw new ParametersParseException(string.Format( "Parameter '{0}' is unknown.", dict.Keys.First())); } return parameters; }
public string GetCommitMessage( IWin32Window parentWindow, Parameters parameters, string originalMessage) { if (parameters == null) throw new ArgumentNullException("parameters"); try { var project = parameters.Project; if (project.Length == 0) throw new ApplicationException("Missing Google Code project specification."); IList<Issue> issues; using (var dialog = new IssueBrowserDialog { ProjectName = project, UserNamePattern = parameters.User, StatusPattern = parameters.Status, UpdateCheckEnabled = true, }) { var settings = Properties.Settings.Default; new WindowSettings(settings, dialog); var reply = dialog.ShowDialog(parentWindow); issues = dialog.SelectedIssueObjects; settings.Save(); if (reply != DialogResult.OK || issues.Count == 0) return originalMessage; _issues = issues; _project = dialog.Project; } var message = new StringBuilder(originalMessage); if (originalMessage.Length > 0 && !originalMessage.EndsWith("\n")) message.AppendLine(); foreach (var issue in issues) { message .Append("(") .Append(GetIssueTypeAddress(issue.Type)).Append(" issue #") .Append(issue.Id).Append(") : ") .AppendLine(issue.Summary); } return message.ToString(); } catch (Exception e) { ShowErrorBox(parentWindow, e); throw; } }
public string GetCommitMessage( IWin32Window parentWindow, Parameters parameters, string originalMessage) { if (parameters == null) throw new ArgumentNullException("parameters"); _parameters = parameters; var project = parameters.Project; if (project.Length == 0) throw new ApplicationException("Missing project specification."); IList<Issue> issues; using (var dialog = new IssueBrowserDialog(_parameters.Provider) { UserNamePattern = parameters.User, StatusPattern = parameters.Status, UpdateCheckEnabled = true, }) { var settings = Properties.Settings.Default; new WindowSettings(settings, dialog); var reply = dialog.ShowDialog(parentWindow); issues = dialog.SelectedIssueObjects; settings.Save(); if (reply != DialogResult.OK || issues.Count == 0) return originalMessage; _issues = issues; } var message = new StringBuilder(originalMessage); if (originalMessage.Length > 0 && !originalMessage.EndsWith("\n")) message.AppendLine(); foreach (var issue in issues) { var newLine = new StringBuilder(_parameters.CommitTemplate); newLine.Replace("%TYPE%", issue.Type); newLine.Replace("%SUMMARY%", issue.Summary); newLine.Replace("%BUGID%", issue.Id.ToString()); newLine.Replace("%TYPETEXT1%", GetIssueTypeAddress(issue.Type) + "s"); newLine.Replace("%TYPETEXT2%", GetIssueTypeAddress(issue.Type) + "d"); message.Append(newLine + "\n"); } return message.ToString(); }
public string OnCommitFinished(string revision, Parameters parameters) { var project = parameters.Project; if (project.Length == 0) throw new ApplicationException("Missing project specification."); _parameters = parameters; if (_parameters.NoOnCommitFinished) return null; OnCommitFinished(null, revision, _parameters.Provider, _issues); return null; }
public string GetCommitMessage2(IntPtr hParentWnd, string parameters, string commonURL, string commonRoot, string[] pathList, string originalMessage, string bugID, out string bugIDOut, out string[] revPropNames, out string[] revPropValues) { bugIDOut = bugID; Parameters p = Parameters.Parse(parameters); _parameters = p; if (p.Project.Length == 0) { // we can extract the project name from the url, e.g.: // https://gurtle.googlecode.com/svn/trunk // the project name is the first part of the domain Uri url = new Uri(commonURL); string projectName = url.Host.Substring(0, url.Host.IndexOf('.')); parameters += " project=" + projectName; } // If no revision properties are to be set, // the plug-in MUST return empty arrays. revPropNames = new string[0]; revPropValues = new string[0]; return GetCommitMessage(WindowHandleWrapper.TryCreate(hParentWnd), Parameters.Parse(parameters), originalMessage); }
public static Parameters Parse(string str) { if (str == null) throw new ArgumentNullException("str"); str = str.Trim(); if (str.Length == 0) return new Parameters(); var dict = ParsePairs(str).ToDictionary( p => p.Key, p => p.Value, StringComparer.OrdinalIgnoreCase); Parameters parameters; try { parameters = new Parameters { _provider = Providers.ProviderFactory.getProvider(dict.TryPop("provider"), dict.TryPop("project")), User = dict.TryPop("user"), Status = dict.TryPop("status"), CommitTemplate = dict.TryPop("commitTemplate"), }; string noCommitFinished = dict.TryPop("noOnCommitFinished"); if (noCommitFinished != null && (noCommitFinished == "true" || noCommitFinished == "1")) { parameters.NoOnCommitFinished = true; } parameters._project = parameters._provider.ProjectName; } catch (ArgumentException e) { throw new ParametersParseException(e.Message, e); } if (dict.Any()) { throw new ParametersParseException(string.Format( "Parameter '{0}' is unknown.", dict.Keys.First())); } return parameters; }