private PostReviewResult RunPostReviewProcess(ReviewRequest reviewRequest, string arguments) { var process = new Process { StartInfo = new ProcessStartInfo { FileName = "post-review", Arguments = arguments, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false } }; log.Info(process.StartInfo.Arguments); process.Start(); int result = 0; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.EnableRaisingEvents = true; bool hasExceptionToSkip = false; DataReceivedEventHandler dataReceived = (sender, e) => { var regexString = Regex.Escape(config.ReviewBoardServer + "/r/") + "(?<reviewId>\\d+)/"; var regex = new Regex(regexString); var line = e.Data; log.Info(line); var match = regex.Match(line ?? string.Empty); if (match.Success) { log.Info("Found match for reviewId"); result = int.Parse(match.Groups["reviewId"].Value); } if (line != null && line.Contains("svn.py\", line 268, in convert_to_absolute_paths")) { hasExceptionToSkip = true; } }; process.OutputDataReceived += dataReceived; process.ErrorDataReceived += dataReceived; process.WaitForExit(); if (hasExceptionToSkip) { log.Warning("Skipping revision"); return new PostReviewResult { SkipRevision = true }; } if (process.ExitCode != 0) { log.Error(string.Format("post-review existed with code '{0}'", process.ExitCode)); return PostReviewResult.Error; } return new PostReviewResult { ReviewId = result, IsNewRequest = reviewRequest == null, IsSuccess = true }; }
private void FormParametersForExistingRequest(ReviewRequest reviewRequest, Changeset changeset, string commiterName, StringBuilder sb) { sb.AppendFormat(" --review-request-id={0}", reviewRequest.Id); FormCommonAuthenticationAndRepositoryParameters(changeset, commiterName, sb); var summaryMatch = config.ParsingPreviousSummaryExpression.Match(reviewRequest.Summary); string comment = config.ReferenceToPrevious.Replace(changeset.Comment.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ?? string.Empty, string.Empty); string summary = summaryMatch.Success ? string.Format(config.UpdateSummaryExpression, summaryMatch.Groups["revisions"], changeset.ChangesetId, summaryMatch.Groups["summary"], comment) : string.Format("C{0}: {1}", changeset.ChangesetId, comment); string description = string.Format("{0}\r\nReview for chageset {1} by {2}:\r\n{3}", reviewRequest.Description, changeset.ChangesetId, changeset.Committer, changeset.Comment); sb.AppendFormat(@" --summary=""{0}""", summary); sb.AppendFormat(" --description=\"{0}\"", description); sb.AppendFormat(@" --publish"); }
private string MergeSummaries(ReviewRequest baseRequest, ReviewRequest nextRequest) { var baseMatch = config.ParsingPreviousSummaryExpression.Match(baseRequest.Summary); var nextMatch = config.ParsingPreviousSummaryExpression.Match(nextRequest.Summary); return string.Format("{0}, {1}: {2} and {3}", baseMatch.Groups["revisions"], nextMatch.Groups["revisions"], baseMatch.Groups["summary"], nextMatch.Groups["summary"]); }