Package com.google.gerrit.server.patch
Class ApplyPatchUtil
java.lang.Object
com.google.gerrit.server.patch.ApplyPatchUtil
Utility for applying a patch.
- 
Method SummaryModifier and TypeMethodDescriptionstatic org.eclipse.jgit.patch.PatchApplier.ResultapplyPatch(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.lib.ObjectInserter oi, ApplyPatchInput input, org.eclipse.jgit.revwalk.RevCommit mergeTip) Applies the given patch on top of the merge tip, using the given object inserter.static StringbuildCommitMessage(String message, List<org.eclipse.jgit.revwalk.FooterLine> footerLines, ApplyPatchInput patchInput, String resultPatch, List<org.eclipse.jgit.patch.PatchApplier.Result.Error> errors) Build commit message for commits with applied patch.static StringgetResultPatch(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.lib.ObjectReader reader, org.eclipse.jgit.revwalk.RevCommit baseCommit, org.eclipse.jgit.revwalk.RevTree resultTree) Fetch the patch of the result tree.static com.google.common.hash.HashCode
- 
Method Details- 
applyPatchpublic static org.eclipse.jgit.patch.PatchApplier.Result applyPatch(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.lib.ObjectInserter oi, ApplyPatchInput input, org.eclipse.jgit.revwalk.RevCommit mergeTip) throws IOException, RestApiException Applies the given patch on top of the merge tip, using the given object inserter.- Parameters:
- repo- to apply the patch in
- oi- to operate with
- input- the patch for applying
- mergeTip- the tip to apply the patch on
- Returns:
- the tree ID with the applied patch
- Throws:
- IOException- if unable to create the jgit PatchApplier object
- RestApiException- for any other failure
 
- 
buildCommitMessagepublic static String buildCommitMessage(String message, List<org.eclipse.jgit.revwalk.FooterLine> footerLines, ApplyPatchInput patchInput, String resultPatch, List<org.eclipse.jgit.patch.PatchApplier.Result.Error> errors) throws BadRequestException Build commit message for commits with applied patch.Message structure: - Provided message.
- In case of errors while applying the patch - a warning message which includes the errors; as well as the original patch's header if available, or the full original patch otherwise.
- If there are no explicit errors, but the result change's patch is not the same as the original patch - a warning message which includes the diff; as well as the original patch's header if available, or the full original patch otherwise.
- The provided footerLines, if any.
 - Parameters:
- message- the first message piece, excluding footers
- footerLines- footer lines to append to the message
- patchInput- API input that triggered this action
- resultPatch- to validate accuracy for
- Returns:
- the commit message
- Throws:
- BadRequestException- if the commit message cannot be sanitized
 
- Provided 
- 
getResultPatchpublic static String getResultPatch(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.lib.ObjectReader reader, org.eclipse.jgit.revwalk.RevCommit baseCommit, org.eclipse.jgit.revwalk.RevTree resultTree) throws IOException Fetch the patch of the result tree.- Parameters:
- repo- in which the patch was applied
- reader- for the repo objects, including- resultTree
- baseCommit- to generate patch against
- resultTree- to generate the patch for
- Returns:
- the result patch
- Throws:
- IOException- if the result patch cannot be written
 
- 
sha1
 
-