Adjust to 2.16 API
Since 6b6afe2681 CreateBranch is a Singleton and can be directly
injected rather than being created via a factory.
Change-Id: I51ba1b82ec0986ed643b444885fbac175582ec8e
diff --git a/src/main/java/com/googlesource/gerrit/plugins/refprotection/BackupRef.java b/src/main/java/com/googlesource/gerrit/plugins/refprotection/BackupRef.java
index dd4e21b..d4af191 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/refprotection/BackupRef.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/refprotection/BackupRef.java
@@ -31,6 +31,7 @@
import com.google.gerrit.extensions.api.projects.BranchInput;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
+import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.gerrit.server.data.AccountAttribute;
@@ -64,14 +65,14 @@
public class BackupRef {
public static final String R_BACKUPS = R_REFS + "backups/";
private static final Logger log = LoggerFactory.getLogger(BackupRef.class);
- private final CreateBranch.Factory createBranchFactory;
+ private final CreateBranch createBranch;
@Inject private static PluginConfigFactory cfg;
@Inject private static GitRepositoryManager repoManager;
@Inject @PluginName private static String pluginName;
@Inject
- BackupRef(CreateBranch.Factory createBranchFactory) {
- this.createBranchFactory = createBranchFactory;
+ BackupRef(CreateBranch createBranch) {
+ this.createBranch = createBranch;
}
public void createBackup(RefUpdatedEvent event, ProjectResource project) {
@@ -163,7 +164,7 @@
ObjectId.toString(revWalk.parseCommit(ObjectId.fromString(refUpdate.oldRev)).getId());
try {
- createBranchFactory.create(backupRef).apply(project, input);
+ createBranch.apply(project, IdString.fromDecoded(backupRef), input);
} catch (BadRequestException
| AuthException
| ResourceConflictException