Store push certificate in patch set during ReceiveCommits
Push certificates for new/updated changes contain commands for refs/for/*, even though that ref is not created. This means if we store such certificates in PushCertificateStore, we can't use the history of push certs on that ref to reconstruct anything like a reflog. It would be confusing to see in refs/meta/push-certs a push cert mentioning refs/for/* either on that ref (which doesn't exist) or refs/changes/* (which is a completely unrelated refname). Pushing to refs/for/* and having the data become a patch set is a detail of the Gerrit model, so it makes sense to store the cert in the same place as the patch set SHA-1 itself, namely the PatchSets table. Change-Id: I51924054742fbd31b1abcce1ccdcf9bce76642ac
This commit is contained in:
@@ -199,6 +199,10 @@ public final class PatchSet {
|
||||
@Column(id = 6, notNull = false)
|
||||
protected String groups;
|
||||
|
||||
/** Certificate sent with a push that created this patch set. */
|
||||
@Column(id = 7, notNull = false)
|
||||
protected String pushCertficate;
|
||||
|
||||
protected PatchSet() {
|
||||
}
|
||||
|
||||
@@ -258,6 +262,14 @@ public final class PatchSet {
|
||||
return id.toRefName();
|
||||
}
|
||||
|
||||
public String getPushCertificate() {
|
||||
return pushCertficate;
|
||||
}
|
||||
|
||||
public void setPushCertificate(String cert) {
|
||||
pushCertficate = cert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[PatchSet " + getId().toString() + "]";
|
||||
|
@@ -2075,6 +2075,10 @@ public class ReceiveCommits {
|
||||
newPatchSet.setUploader(currentUser.getAccountId());
|
||||
newPatchSet.setRevision(toRevId(newCommit));
|
||||
newPatchSet.setGroups(groups);
|
||||
if (rp.getPushCertificate() != null) {
|
||||
newPatchSet.setPushCertificate(
|
||||
rp.getPushCertificate().toTextWithSignature());
|
||||
}
|
||||
if (magicBranch != null && magicBranch.draft) {
|
||||
newPatchSet.setDraft(true);
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
/** A version of the database schema. */
|
||||
public abstract class SchemaVersion {
|
||||
/** The current schema version. */
|
||||
public static final Class<Schema_112> C = Schema_112.class;
|
||||
public static final Class<Schema_113> C = Schema_113.class;
|
||||
|
||||
public static int getBinaryVersion() {
|
||||
return guessVersion(C);
|
||||
|
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.schema;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
public class Schema_113 extends SchemaVersion {
|
||||
@Inject
|
||||
Schema_113(Provider<Schema_112> prior) {
|
||||
super(prior);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user