Package com.google.gerrit.server.notedb
Class CommitRewriter
java.lang.Object
com.google.gerrit.server.notedb.CommitRewriter
Rewrites ('backfills') commit history of change in NoteDb to not contain user data. Only fixes
known cases, rewriting commits case by case.
The cases where we used to put user data in NoteDb can be found by https://gerrit-review.googlesource.com/q/hashtag:user-data-cleanup
As opposed to NoteDbRewriter
implementations, which target a specific change and are
used by REST endpoints, this rewriter is used as standalone tool, that bulk backfills changes by
project.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Result of the backfill run for a project.static class
Diff result of a single commit rewritestatic class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final org.eclipse.jgit.revwalk.FooterKey
-
Method Summary
Modifier and TypeMethodDescriptioncom.google.gerrit.server.notedb.CommitRewriter.ChangeFixProgress
backfillChange
(com.google.gerrit.server.notedb.CommitRewriter.RefsUpdate refsUpdate, org.eclipse.jgit.lib.Ref ref, com.google.common.collect.ImmutableSet<AccountState> accountsInChange, CommitRewriter.RunOptions options) Walks the ref history from oldest update to the most recent update, fixing the commits that contain user data case by case.backfillProject
(Project.NameKey project, org.eclipse.jgit.lib.Repository repo, CommitRewriter.RunOptions options) Rewrites commit history ofRefNames.changeMetaRef(com.google.gerrit.entities.Change.Id)
s in singlerepo
.static byte[]
cutTreeAndParents
(byte[] b) Cuts tree and parent lines from raw unparsed commit body, so they are not included in diff comparison.
-
Field Details
-
FOOTER_ASSIGNEE
public static final org.eclipse.jgit.revwalk.FooterKey FOOTER_ASSIGNEE -
DEFAULT_ACCOUNT_REPLACEMENT
- See Also:
-
-
Method Details
-
backfillProject
public CommitRewriter.BackfillResult backfillProject(Project.NameKey project, org.eclipse.jgit.lib.Repository repo, CommitRewriter.RunOptions options) Rewrites commit history ofRefNames.changeMetaRef(com.google.gerrit.entities.Change.Id)
s in singlerepo
. Only rewrites branch if necessary, i.e. if there were any commits that contained user data.See
CommitRewriter.RunOptions
for the execution and output options.- Parameters:
project
- project to backfillrepo
- repo to backfilloptions
-CommitRewriter.RunOptions
to control how the run is executed.- Returns:
- BackfillResult
-
backfillChange
public com.google.gerrit.server.notedb.CommitRewriter.ChangeFixProgress backfillChange(com.google.gerrit.server.notedb.CommitRewriter.RefsUpdate refsUpdate, org.eclipse.jgit.lib.Ref ref, com.google.common.collect.ImmutableSet<AccountState> accountsInChange, CommitRewriter.RunOptions options) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Walks the ref history from oldest update to the most recent update, fixing the commits that contain user data case by case. Commit history is rewritten from the first commit, that needs to be updated, for all subsequent updates. The new ref tip is returned inCommitRewriter.ChangeFixProgress.newTipId
.- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
cutTreeAndParents
public static byte[] cutTreeAndParents(byte[] b) Cuts tree and parent lines from raw unparsed commit body, so they are not included in diff comparison.- Parameters:
b
- raw unparsed commit body, seeRevCommit.getRawBuffer()
.For parsing, see
RawParseUtils.author(byte[], int)
,RawParseUtils.commitMessage(byte[], int)
, etc.- Returns:
- raw unparsed commit body, without tree and parent lines.
-