// // Returns a revision list for a given path // private static Revisions Request(string path, Logging logger) { // Get the list of revisions we want to look at string revisonList = GetRevisionList(path, logger); if (revisonList == null) { logger.Log("No revisions were provided"); return(null); } // Parse the list of revisions we're interested in string[] revisionsToReview = ParseRevisionList(revisonList, logger); if (revisionsToReview == null) { return(null); } // Get the URL of this repository string url = Svn.GetBranch(path); logger.Log("Using SVN URL '{0}', url"); // Return our results return(new Revisions(path, url, revisionsToReview)); }
// // Raises a new review // public static ReviewRequestResult RequestReview(string workingDirectory, string server, string username, string password, Review.Review.Properties reviewProperties, Logging logger) { // We may not need to generate a review if (reviewProperties.ReviewLevel != RB_Tools.Shared.Review.Properties.Level.FullReview) { // No review needed so exit logger.Log("Ignoring review request as a full review was not requested"); return(new ReviewRequestResult(string.Empty, string.Empty, reviewProperties)); } // Read out the description and testing into a temp file string descriptionFile = GetFileWithContents(reviewProperties.Description, reviewProperties.Summary); string testingFile = GetFileWithContents(reviewProperties.Testing, null); // Build up the review command string commandProperties = string.Format("--server {0} --summary \"{1}\" ", server, reviewProperties.Summary); if (string.IsNullOrWhiteSpace(descriptionFile) == false) { commandProperties += string.Format("--description-file \"{0}\" ", descriptionFile); } if (string.IsNullOrWhiteSpace(testingFile) == false) { commandProperties += string.Format("--testing-done-file \"{0}\" ", testingFile); } if (string.IsNullOrWhiteSpace(reviewProperties.JiraId) == false) { string formattedJiraIds = BuildJiraLinks(reviewProperties.JiraId); commandProperties += string.Format("--bugs-closed \"{0}\" ", formattedJiraIds); } // Options commandProperties += string.Format("--svn-show-copies-as-adds={0} ", reviewProperties.CopiesAsAdds == true ? "y":"n"); // Build up the review groups if (reviewProperties.Groups.Count != 0) { string reviewGroups = reviewProperties.Groups[0]; for (int i = 1; i < reviewProperties.Groups.Count; ++i) { reviewGroups += "," + reviewProperties.Groups[i]; } // Add the command commandProperties += string.Format("--target-groups \"{0}\" ", reviewGroups); } // Get the name of the branch we're on string branchUrl = Svn.GetBranch(workingDirectory); if (string.IsNullOrWhiteSpace(branchUrl) == false) { commandProperties += string.Format("--branch \"{0}\" ", branchUrl); } // Update an existing review? if (string.IsNullOrWhiteSpace(reviewProperties.ReviewId) == false) { commandProperties += string.Format("--review-request-id \"{0}\" ", reviewProperties.ReviewId); } // Pass through the patch file we generated or used commandProperties += string.Format("--diff-filename \"{0}\" ", reviewProperties.Contents.Patch); // Build up the command string commandOptions = string.Format(@"post {0}", commandProperties); string rbtPath = RB_Tools.Shared.Targets.Reviewboard.Path(); logger.Log("Requesting review"); logger.Log("* Calling {0} {1}", rbtPath, commandOptions); // Run the process Process.Output output = Process.Start(workingDirectory, rbtPath, commandOptions); // Throw to return the error if (string.IsNullOrWhiteSpace(output.StdErr) == false) { logger.Log("Error raised when requesting review - {0}", output.StdErr); throw new ApplicationException(output.StdErr); } // Break up the results string[] outputLines = output.StdOut.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); // Pull out the link to the review (use the diff) string reviewUrl = string.Empty; if (outputLines.Length >= 3) { reviewUrl = outputLines[2]; } // Review URL needs to reference the reviewboard server string reviewError = null; if (reviewUrl.ToLower().Contains(server.ToLower()) == false) { reviewError = output.StdOut; } // Lose the temp files if we have them CleanUpTemporaryFiles(descriptionFile, testingFile, logger); // Return the results return(new ReviewRequestResult(reviewUrl, reviewError, reviewProperties)); }