Fix deprecation warnings from latest JGit update
- FS is no longer required for LockFile constructor. - TestRepository#getClock was renamed getDate. - Replace usages of RefDatabase#getRef with either exactRef, when we know we can bypass the full lookup path, or findRef, where the input is user-provided and we might need to add an implicit prefix. Change-Id: I6309b91ccf99ffaa724be273ddae0d9857b825f9
This commit is contained in:
@@ -102,7 +102,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
@After
|
||||
public void clearPublicKeyStore() throws Exception {
|
||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||
Ref ref = repo.getRef(REFS_GPG_KEYS);
|
||||
Ref ref = repo.exactRef(REFS_GPG_KEYS);
|
||||
if (ref != null) {
|
||||
RefUpdate ru = repo.updateRef(REFS_GPG_KEYS);
|
||||
ru.setForceUpdate(true);
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
gApi.changes().id(changeId).get();
|
||||
|
||||
BranchInput b = new BranchInput();
|
||||
b.revision = repo().getRef("HEAD").getObjectId().name();
|
||||
b.revision = repo().exactRef("HEAD").getObjectId().name();
|
||||
gApi.projects()
|
||||
.name(project.get())
|
||||
.branch("other")
|
||||
|
||||
@@ -377,7 +377,7 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void mergeable() throws Exception {
|
||||
ObjectId initial = repo().getRef(HEAD).getLeaf().getObjectId();
|
||||
ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
|
||||
|
||||
PushOneCommit push1 =
|
||||
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ForcePushIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void forcePushNotAllowed() throws Exception {
|
||||
ObjectId initial = repo().getRef(HEAD).getLeaf().getObjectId();
|
||||
ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
|
||||
PushOneCommit push1 =
|
||||
pushFactory.create(db, admin.getIdent(), testRepo, "change1", "a.txt", "content");
|
||||
PushOneCommit.Result r1 = push1.to("refs/heads/master");
|
||||
@@ -49,7 +49,7 @@ public class ForcePushIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void forcePushAllowed() throws Exception {
|
||||
ObjectId initial = repo().getRef(HEAD).getLeaf().getObjectId();
|
||||
ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
|
||||
grant(Permission.PUSH, project, "refs/*", true);
|
||||
PushOneCommit push1 =
|
||||
pushFactory.create(db, admin.getIdent(), testRepo, "change1", "a.txt", "content");
|
||||
|
||||
@@ -107,7 +107,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void submitOnPushMergeConflict() throws Exception {
|
||||
ObjectId objectId = repo().getRef("HEAD").getObjectId();
|
||||
ObjectId objectId = repo().exactRef("HEAD").getObjectId();
|
||||
push("refs/heads/master", "one change", "a.txt", "some content");
|
||||
testRepo.reset(objectId);
|
||||
|
||||
@@ -123,7 +123,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void submitOnPushSuccessfulMerge() throws Exception {
|
||||
String master = "refs/heads/master";
|
||||
ObjectId objectId = repo().getRef("HEAD").getObjectId();
|
||||
ObjectId objectId = repo().exactRef("HEAD").getObjectId();
|
||||
push(master, "one change", "a.txt", "some content");
|
||||
testRepo.reset(objectId);
|
||||
|
||||
@@ -233,7 +233,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
||||
private void assertCommit(Project.NameKey project, String branch) throws IOException {
|
||||
try (Repository r = repoManager.openRepository(project);
|
||||
RevWalk rw = new RevWalk(r)) {
|
||||
RevCommit c = rw.parseCommit(r.getRef(branch).getObjectId());
|
||||
RevCommit c = rw.parseCommit(r.exactRef(branch).getObjectId());
|
||||
assertThat(c.getShortMessage()).isEqualTo(PushOneCommit.SUBJECT);
|
||||
assertThat(c.getAuthorIdent().getEmailAddress()).isEqualTo(admin.email);
|
||||
assertThat(c.getCommitterIdent().getEmailAddress()).isEqualTo(
|
||||
@@ -244,7 +244,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
||||
private void assertMergeCommit(String branch, String subject) throws IOException {
|
||||
try (Repository r = repoManager.openRepository(project);
|
||||
RevWalk rw = new RevWalk(r)) {
|
||||
RevCommit c = rw.parseCommit(r.getRef(branch).getObjectId());
|
||||
RevCommit c = rw.parseCommit(r.exactRef(branch).getObjectId());
|
||||
assertThat(c.getParentCount()).isEqualTo(2);
|
||||
assertThat(c.getShortMessage()).isEqualTo("Merge \"" + subject + "\"");
|
||||
assertThat(c.getAuthorIdent().getEmailAddress()).isEqualTo(admin.email);
|
||||
@@ -256,7 +256,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
||||
private void assertTag(Project.NameKey project, String branch,
|
||||
PushOneCommit.Tag tag) throws IOException {
|
||||
try (Repository repo = repoManager.openRepository(project)) {
|
||||
Ref tagRef = repo.getRef(tag.name);
|
||||
Ref tagRef = repo.findRef(tag.name);
|
||||
assertThat(tagRef).isNotNull();
|
||||
ObjectId taggedCommit = null;
|
||||
if (tag instanceof PushOneCommit.AnnotatedTag) {
|
||||
@@ -273,7 +273,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
||||
} else {
|
||||
taggedCommit = tagRef.getObjectId();
|
||||
}
|
||||
ObjectId headCommit = repo.getRef(branch).getObjectId();
|
||||
ObjectId headCommit = repo.exactRef(branch).getObjectId();
|
||||
assertThat(taggedCommit).isNotNull();
|
||||
assertThat(taggedCommit).isEqualTo(headCommit);
|
||||
}
|
||||
|
||||
@@ -104,13 +104,13 @@ public class VisibleRefFilterIT extends AbstractDaemonTest {
|
||||
// master-tag -> master
|
||||
RefUpdate mtu = repo.updateRef("refs/tags/master-tag");
|
||||
mtu.setExpectedOldObjectId(ObjectId.zeroId());
|
||||
mtu.setNewObjectId(repo.getRef("refs/heads/master").getObjectId());
|
||||
mtu.setNewObjectId(repo.exactRef("refs/heads/master").getObjectId());
|
||||
assertThat(mtu.update()).isEqualTo(RefUpdate.Result.NEW);
|
||||
|
||||
// branch-tag -> branch
|
||||
RefUpdate btu = repo.updateRef("refs/tags/branch-tag");
|
||||
btu.setExpectedOldObjectId(ObjectId.zeroId());
|
||||
btu.setNewObjectId(repo.getRef("refs/heads/branch").getObjectId());
|
||||
btu.setNewObjectId(repo.exactRef("refs/heads/branch").getObjectId());
|
||||
assertThat(btu.update()).isEqualTo(RefUpdate.Result.NEW);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
repoManager.openRepository(new Project.NameKey(c.project))) {
|
||||
String refName = new PatchSet.Id(new Change.Id(c._number), expectedNum)
|
||||
.toRefName();
|
||||
Ref ref = repo.getRef(refName);
|
||||
Ref ref = repo.exactRef(refName);
|
||||
assertThat(ref).named(refName).isNotNull();
|
||||
assertThat(ref.getObjectId()).isEqualTo(expectedId);
|
||||
}
|
||||
@@ -347,7 +347,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
try (Repository repo = repoManager.openRepository(project);
|
||||
RevWalk rw = new RevWalk(repo)) {
|
||||
rw.markStart(rw.parseCommit(
|
||||
repo.getRef("refs/heads/" + branch).getObjectId()));
|
||||
repo.exactRef("refs/heads/" + branch).getObjectId()));
|
||||
return Lists.newArrayList(rw);
|
||||
}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
|
||||
private RevCommit getHead(Repository repo, String name) throws IOException {
|
||||
try (RevWalk rw = new RevWalk(repo)) {
|
||||
return rw.parseCommit(repo.getRef(name).getObjectId());
|
||||
return rw.parseCommit(repo.exactRef(name).getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
throws RepositoryNotFoundException, IOException {
|
||||
try (Repository repo =
|
||||
repoManager.openRepository(new Project.NameKey(projectName))) {
|
||||
assertThat(repo.getRef(Constants.HEAD).getTarget().getName())
|
||||
assertThat(repo.exactRef(Constants.HEAD).getTarget().getName())
|
||||
.isEqualTo(expectedRef);
|
||||
}
|
||||
}
|
||||
@@ -281,7 +281,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
RevWalk rw = new RevWalk(repo);
|
||||
TreeWalk tw = new TreeWalk(rw.getObjectReader())) {
|
||||
for (String ref : refs) {
|
||||
RevCommit commit = rw.lookupCommit(repo.getRef(ref).getObjectId());
|
||||
RevCommit commit = rw.lookupCommit(repo.exactRef(ref).getObjectId());
|
||||
rw.parseBody(commit);
|
||||
tw.addTree(commit.getTree());
|
||||
assertThat(tw.next()).isFalse();
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
||||
testRepo = new TestRepository<>(
|
||||
(InMemoryRepository) repoManager.openRepository(project));
|
||||
tip = testRepo.getRevWalk().parseCommit(
|
||||
testRepo.getRepository().getRef("HEAD").getObjectId());
|
||||
testRepo.getRepository().exactRef("HEAD").getObjectId());
|
||||
adminId = admin.getId();
|
||||
checker = checkerProvider.get();
|
||||
}
|
||||
@@ -180,7 +180,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
||||
assertThat(p.status).isEqualTo(ProblemInfo.Status.FIXED);
|
||||
assertThat(p.outcome).isEqualTo("Repaired patch set ref");
|
||||
|
||||
assertThat(testRepo.getRepository().getRef(refName).getObjectId().name())
|
||||
assertThat(testRepo.getRepository().exactRef(refName).getObjectId().name())
|
||||
.isEqualTo(ps.getRevision().get());
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
||||
public void missingDestRef() throws Exception {
|
||||
String ref = "refs/heads/master";
|
||||
// Detach head so we're allowed to delete ref.
|
||||
testRepo.reset(testRepo.getRepository().getRef(ref).getObjectId());
|
||||
testRepo.reset(testRepo.getRepository().exactRef(ref).getObjectId());
|
||||
RefUpdate ru = testRepo.getRepository().updateRef(ref);
|
||||
ru.setForceUpdate(true);
|
||||
assertThat(ru.delete()).isEqualTo(RefUpdate.Result.FORCED);
|
||||
|
||||
@@ -163,7 +163,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
||||
// 2,2---1,2---3,1
|
||||
|
||||
// Create two commits and push.
|
||||
ObjectId initial = repo().getRef("HEAD").getObjectId();
|
||||
ObjectId initial = repo().exactRef("HEAD").getObjectId();
|
||||
RevCommit c1_1 = commitBuilder()
|
||||
.add("a.txt", "1")
|
||||
.message("subject: 1")
|
||||
|
||||
@@ -194,7 +194,7 @@ public class SubmittedTogetherIT extends AbstractDaemonTest {
|
||||
private RevCommit getRemoteHead() throws IOException {
|
||||
try (Repository repo = repoManager.openRepository(project);
|
||||
RevWalk rw = new RevWalk(repo)) {
|
||||
return rw.parseCommit(repo.getRef("refs/heads/master").getObjectId());
|
||||
return rw.parseCommit(repo.exactRef("refs/heads/master").getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ public class LabelTypeIT extends AbstractDaemonTest {
|
||||
revision(r).review(ReviewInput.approve());
|
||||
revision(r).submit();
|
||||
try (Repository repo = repoManager.openRepository(project)) {
|
||||
assertThat(repo.getRef("refs/heads/master").getObjectId()).isEqualTo(
|
||||
assertThat(repo.exactRef("refs/heads/master").getObjectId()).isEqualTo(
|
||||
r.getCommitId());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user