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:
@@ -397,7 +397,7 @@ public abstract class AbstractDaemonTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected TestRepository<?>.CommitBuilder amendBuilder() throws Exception {
|
protected TestRepository<?>.CommitBuilder amendBuilder() throws Exception {
|
||||||
ObjectId head = repo().getRef("HEAD").getObjectId();
|
ObjectId head = repo().exactRef("HEAD").getObjectId();
|
||||||
TestRepository<?>.CommitBuilder b = testRepo.amendRef("HEAD");
|
TestRepository<?>.CommitBuilder b = testRepo.amendRef("HEAD");
|
||||||
Optional<String> id = GitUtil.getChangeId(testRepo, head);
|
Optional<String> id = GitUtil.getChangeId(testRepo, head);
|
||||||
// TestRepository behaves like "git commit --amend -m foo", which does not
|
// TestRepository behaves like "git commit --amend -m foo", which does not
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ public class PushOneCommit {
|
|||||||
}
|
}
|
||||||
commitBuilder.message(subject)
|
commitBuilder.message(subject)
|
||||||
.author(i)
|
.author(i)
|
||||||
.committer(new PersonIdent(i, testRepo.getClock()));
|
.committer(new PersonIdent(i, testRepo.getDate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result to(String ref) throws Exception {
|
public Result to(String ref) throws Exception {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class AccountIT extends AbstractDaemonTest {
|
|||||||
@After
|
@After
|
||||||
public void clearPublicKeyStore() throws Exception {
|
public void clearPublicKeyStore() throws Exception {
|
||||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||||
Ref ref = repo.getRef(REFS_GPG_KEYS);
|
Ref ref = repo.exactRef(REFS_GPG_KEYS);
|
||||||
if (ref != null) {
|
if (ref != null) {
|
||||||
RefUpdate ru = repo.updateRef(REFS_GPG_KEYS);
|
RefUpdate ru = repo.updateRef(REFS_GPG_KEYS);
|
||||||
ru.setForceUpdate(true);
|
ru.setForceUpdate(true);
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||||||
gApi.changes().id(changeId).get();
|
gApi.changes().id(changeId).get();
|
||||||
|
|
||||||
BranchInput b = new BranchInput();
|
BranchInput b = new BranchInput();
|
||||||
b.revision = repo().getRef("HEAD").getObjectId().name();
|
b.revision = repo().exactRef("HEAD").getObjectId().name();
|
||||||
gApi.projects()
|
gApi.projects()
|
||||||
.name(project.get())
|
.name(project.get())
|
||||||
.branch("other")
|
.branch("other")
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ public class RevisionIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mergeable() throws Exception {
|
public void mergeable() throws Exception {
|
||||||
ObjectId initial = repo().getRef(HEAD).getLeaf().getObjectId();
|
ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
|
||||||
|
|
||||||
PushOneCommit push1 =
|
PushOneCommit push1 =
|
||||||
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
|
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class ForcePushIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void forcePushNotAllowed() throws Exception {
|
public void forcePushNotAllowed() throws Exception {
|
||||||
ObjectId initial = repo().getRef(HEAD).getLeaf().getObjectId();
|
ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
|
||||||
PushOneCommit push1 =
|
PushOneCommit push1 =
|
||||||
pushFactory.create(db, admin.getIdent(), testRepo, "change1", "a.txt", "content");
|
pushFactory.create(db, admin.getIdent(), testRepo, "change1", "a.txt", "content");
|
||||||
PushOneCommit.Result r1 = push1.to("refs/heads/master");
|
PushOneCommit.Result r1 = push1.to("refs/heads/master");
|
||||||
@@ -49,7 +49,7 @@ public class ForcePushIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void forcePushAllowed() throws Exception {
|
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);
|
grant(Permission.PUSH, project, "refs/*", true);
|
||||||
PushOneCommit push1 =
|
PushOneCommit push1 =
|
||||||
pushFactory.create(db, admin.getIdent(), testRepo, "change1", "a.txt", "content");
|
pushFactory.create(db, admin.getIdent(), testRepo, "change1", "a.txt", "content");
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void submitOnPushMergeConflict() throws Exception {
|
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");
|
push("refs/heads/master", "one change", "a.txt", "some content");
|
||||||
testRepo.reset(objectId);
|
testRepo.reset(objectId);
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void submitOnPushSuccessfulMerge() throws Exception {
|
public void submitOnPushSuccessfulMerge() throws Exception {
|
||||||
String master = "refs/heads/master";
|
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");
|
push(master, "one change", "a.txt", "some content");
|
||||||
testRepo.reset(objectId);
|
testRepo.reset(objectId);
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
|||||||
private void assertCommit(Project.NameKey project, String branch) throws IOException {
|
private void assertCommit(Project.NameKey project, String branch) throws IOException {
|
||||||
try (Repository r = repoManager.openRepository(project);
|
try (Repository r = repoManager.openRepository(project);
|
||||||
RevWalk rw = new RevWalk(r)) {
|
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.getShortMessage()).isEqualTo(PushOneCommit.SUBJECT);
|
||||||
assertThat(c.getAuthorIdent().getEmailAddress()).isEqualTo(admin.email);
|
assertThat(c.getAuthorIdent().getEmailAddress()).isEqualTo(admin.email);
|
||||||
assertThat(c.getCommitterIdent().getEmailAddress()).isEqualTo(
|
assertThat(c.getCommitterIdent().getEmailAddress()).isEqualTo(
|
||||||
@@ -244,7 +244,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
|||||||
private void assertMergeCommit(String branch, String subject) throws IOException {
|
private void assertMergeCommit(String branch, String subject) throws IOException {
|
||||||
try (Repository r = repoManager.openRepository(project);
|
try (Repository r = repoManager.openRepository(project);
|
||||||
RevWalk rw = new RevWalk(r)) {
|
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.getParentCount()).isEqualTo(2);
|
||||||
assertThat(c.getShortMessage()).isEqualTo("Merge \"" + subject + "\"");
|
assertThat(c.getShortMessage()).isEqualTo("Merge \"" + subject + "\"");
|
||||||
assertThat(c.getAuthorIdent().getEmailAddress()).isEqualTo(admin.email);
|
assertThat(c.getAuthorIdent().getEmailAddress()).isEqualTo(admin.email);
|
||||||
@@ -256,7 +256,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
|||||||
private void assertTag(Project.NameKey project, String branch,
|
private void assertTag(Project.NameKey project, String branch,
|
||||||
PushOneCommit.Tag tag) throws IOException {
|
PushOneCommit.Tag tag) throws IOException {
|
||||||
try (Repository repo = repoManager.openRepository(project)) {
|
try (Repository repo = repoManager.openRepository(project)) {
|
||||||
Ref tagRef = repo.getRef(tag.name);
|
Ref tagRef = repo.findRef(tag.name);
|
||||||
assertThat(tagRef).isNotNull();
|
assertThat(tagRef).isNotNull();
|
||||||
ObjectId taggedCommit = null;
|
ObjectId taggedCommit = null;
|
||||||
if (tag instanceof PushOneCommit.AnnotatedTag) {
|
if (tag instanceof PushOneCommit.AnnotatedTag) {
|
||||||
@@ -273,7 +273,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
|||||||
} else {
|
} else {
|
||||||
taggedCommit = tagRef.getObjectId();
|
taggedCommit = tagRef.getObjectId();
|
||||||
}
|
}
|
||||||
ObjectId headCommit = repo.getRef(branch).getObjectId();
|
ObjectId headCommit = repo.exactRef(branch).getObjectId();
|
||||||
assertThat(taggedCommit).isNotNull();
|
assertThat(taggedCommit).isNotNull();
|
||||||
assertThat(taggedCommit).isEqualTo(headCommit);
|
assertThat(taggedCommit).isEqualTo(headCommit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,13 +104,13 @@ public class VisibleRefFilterIT extends AbstractDaemonTest {
|
|||||||
// master-tag -> master
|
// master-tag -> master
|
||||||
RefUpdate mtu = repo.updateRef("refs/tags/master-tag");
|
RefUpdate mtu = repo.updateRef("refs/tags/master-tag");
|
||||||
mtu.setExpectedOldObjectId(ObjectId.zeroId());
|
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);
|
assertThat(mtu.update()).isEqualTo(RefUpdate.Result.NEW);
|
||||||
|
|
||||||
// branch-tag -> branch
|
// branch-tag -> branch
|
||||||
RefUpdate btu = repo.updateRef("refs/tags/branch-tag");
|
RefUpdate btu = repo.updateRef("refs/tags/branch-tag");
|
||||||
btu.setExpectedOldObjectId(ObjectId.zeroId());
|
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);
|
assertThat(btu.update()).isEqualTo(RefUpdate.Result.NEW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
|||||||
repoManager.openRepository(new Project.NameKey(c.project))) {
|
repoManager.openRepository(new Project.NameKey(c.project))) {
|
||||||
String refName = new PatchSet.Id(new Change.Id(c._number), expectedNum)
|
String refName = new PatchSet.Id(new Change.Id(c._number), expectedNum)
|
||||||
.toRefName();
|
.toRefName();
|
||||||
Ref ref = repo.getRef(refName);
|
Ref ref = repo.exactRef(refName);
|
||||||
assertThat(ref).named(refName).isNotNull();
|
assertThat(ref).named(refName).isNotNull();
|
||||||
assertThat(ref.getObjectId()).isEqualTo(expectedId);
|
assertThat(ref.getObjectId()).isEqualTo(expectedId);
|
||||||
}
|
}
|
||||||
@@ -347,7 +347,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
|||||||
try (Repository repo = repoManager.openRepository(project);
|
try (Repository repo = repoManager.openRepository(project);
|
||||||
RevWalk rw = new RevWalk(repo)) {
|
RevWalk rw = new RevWalk(repo)) {
|
||||||
rw.markStart(rw.parseCommit(
|
rw.markStart(rw.parseCommit(
|
||||||
repo.getRef("refs/heads/" + branch).getObjectId()));
|
repo.exactRef("refs/heads/" + branch).getObjectId()));
|
||||||
return Lists.newArrayList(rw);
|
return Lists.newArrayList(rw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -358,7 +358,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
|||||||
|
|
||||||
private RevCommit getHead(Repository repo, String name) throws IOException {
|
private RevCommit getHead(Repository repo, String name) throws IOException {
|
||||||
try (RevWalk rw = new RevWalk(repo)) {
|
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 {
|
throws RepositoryNotFoundException, IOException {
|
||||||
try (Repository repo =
|
try (Repository repo =
|
||||||
repoManager.openRepository(new Project.NameKey(projectName))) {
|
repoManager.openRepository(new Project.NameKey(projectName))) {
|
||||||
assertThat(repo.getRef(Constants.HEAD).getTarget().getName())
|
assertThat(repo.exactRef(Constants.HEAD).getTarget().getName())
|
||||||
.isEqualTo(expectedRef);
|
.isEqualTo(expectedRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,7 +281,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
RevWalk rw = new RevWalk(repo);
|
RevWalk rw = new RevWalk(repo);
|
||||||
TreeWalk tw = new TreeWalk(rw.getObjectReader())) {
|
TreeWalk tw = new TreeWalk(rw.getObjectReader())) {
|
||||||
for (String ref : refs) {
|
for (String ref : refs) {
|
||||||
RevCommit commit = rw.lookupCommit(repo.getRef(ref).getObjectId());
|
RevCommit commit = rw.lookupCommit(repo.exactRef(ref).getObjectId());
|
||||||
rw.parseBody(commit);
|
rw.parseBody(commit);
|
||||||
tw.addTree(commit.getTree());
|
tw.addTree(commit.getTree());
|
||||||
assertThat(tw.next()).isFalse();
|
assertThat(tw.next()).isFalse();
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
|||||||
testRepo = new TestRepository<>(
|
testRepo = new TestRepository<>(
|
||||||
(InMemoryRepository) repoManager.openRepository(project));
|
(InMemoryRepository) repoManager.openRepository(project));
|
||||||
tip = testRepo.getRevWalk().parseCommit(
|
tip = testRepo.getRevWalk().parseCommit(
|
||||||
testRepo.getRepository().getRef("HEAD").getObjectId());
|
testRepo.getRepository().exactRef("HEAD").getObjectId());
|
||||||
adminId = admin.getId();
|
adminId = admin.getId();
|
||||||
checker = checkerProvider.get();
|
checker = checkerProvider.get();
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
|||||||
assertThat(p.status).isEqualTo(ProblemInfo.Status.FIXED);
|
assertThat(p.status).isEqualTo(ProblemInfo.Status.FIXED);
|
||||||
assertThat(p.outcome).isEqualTo("Repaired patch set ref");
|
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());
|
.isEqualTo(ps.getRevision().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +310,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
|||||||
public void missingDestRef() throws Exception {
|
public void missingDestRef() throws Exception {
|
||||||
String ref = "refs/heads/master";
|
String ref = "refs/heads/master";
|
||||||
// Detach head so we're allowed to delete ref.
|
// 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);
|
RefUpdate ru = testRepo.getRepository().updateRef(ref);
|
||||||
ru.setForceUpdate(true);
|
ru.setForceUpdate(true);
|
||||||
assertThat(ru.delete()).isEqualTo(RefUpdate.Result.FORCED);
|
assertThat(ru.delete()).isEqualTo(RefUpdate.Result.FORCED);
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
|||||||
// 2,2---1,2---3,1
|
// 2,2---1,2---3,1
|
||||||
|
|
||||||
// Create two commits and push.
|
// Create two commits and push.
|
||||||
ObjectId initial = repo().getRef("HEAD").getObjectId();
|
ObjectId initial = repo().exactRef("HEAD").getObjectId();
|
||||||
RevCommit c1_1 = commitBuilder()
|
RevCommit c1_1 = commitBuilder()
|
||||||
.add("a.txt", "1")
|
.add("a.txt", "1")
|
||||||
.message("subject: 1")
|
.message("subject: 1")
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ public class SubmittedTogetherIT extends AbstractDaemonTest {
|
|||||||
private RevCommit getRemoteHead() throws IOException {
|
private RevCommit getRemoteHead() throws IOException {
|
||||||
try (Repository repo = repoManager.openRepository(project);
|
try (Repository repo = repoManager.openRepository(project);
|
||||||
RevWalk rw = new RevWalk(repo)) {
|
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).review(ReviewInput.approve());
|
||||||
revision(r).submit();
|
revision(r).submit();
|
||||||
try (Repository repo = repoManager.openRepository(project)) {
|
try (Repository repo = repoManager.openRepository(project)) {
|
||||||
assertThat(repo.getRef("refs/heads/master").getObjectId()).isEqualTo(
|
assertThat(repo.exactRef("refs/heads/master").getObjectId()).isEqualTo(
|
||||||
r.getCommitId());
|
r.getCommitId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public class PublicKeyStoreTest {
|
|||||||
RevWalk rw = new RevWalk(reader)) {
|
RevWalk rw = new RevWalk(reader)) {
|
||||||
NoteMap notes = NoteMap.read(
|
NoteMap notes = NoteMap.read(
|
||||||
reader, tr.getRevWalk().parseCommit(
|
reader, tr.getRevWalk().parseCommit(
|
||||||
tr.getRepository().getRef(REFS_GPG_KEYS).getObjectId()));
|
tr.getRepository().exactRef(REFS_GPG_KEYS).getObjectId()));
|
||||||
String contents = new String(
|
String contents = new String(
|
||||||
reader.open(notes.get(keyObjectId(key1.getKeyId()))).getBytes(),
|
reader.open(notes.get(keyObjectId(key1.getKeyId()))).getBytes(),
|
||||||
UTF_8);
|
UTF_8);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
|||||||
import com.google.gwtorm.schema.java.JavaSchemaModel;
|
import com.google.gwtorm.schema.java.JavaSchemaModel;
|
||||||
|
|
||||||
import org.eclipse.jgit.internal.storage.file.LockFile;
|
import org.eclipse.jgit.internal.storage.file.LockFile;
|
||||||
import org.eclipse.jgit.util.FS;
|
|
||||||
import org.eclipse.jgit.util.IO;
|
import org.eclipse.jgit.util.IO;
|
||||||
import org.kohsuke.args4j.Option;
|
import org.kohsuke.args4j.Option;
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ public class ProtoGen extends AbstractProgram {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int run() throws Exception {
|
public int run() throws Exception {
|
||||||
LockFile lock = new LockFile(file.getAbsoluteFile(), FS.DETECTED);
|
LockFile lock = new LockFile(file.getAbsoluteFile());
|
||||||
if (!lock.lock()) {
|
if (!lock.lock()) {
|
||||||
throw die("Cannot lock " + file);
|
throw die("Cannot lock " + file);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import com.google.inject.Inject;
|
|||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.eclipse.jgit.internal.storage.file.LockFile;
|
import org.eclipse.jgit.internal.storage.file.LockFile;
|
||||||
import org.eclipse.jgit.util.FS;
|
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -96,7 +95,7 @@ class InitContainer implements InitStep {
|
|||||||
try (InputStream in = Files.newInputStream(myWar)) {
|
try (InputStream in = Files.newInputStream(myWar)) {
|
||||||
Files.createDirectories(siteWar.getParent());
|
Files.createDirectories(siteWar.getParent());
|
||||||
|
|
||||||
LockFile lf = new LockFile(siteWar.toFile(), FS.DETECTED);
|
LockFile lf = new LockFile(siteWar.toFile());
|
||||||
if (!lf.lock()) {
|
if (!lf.lock()) {
|
||||||
throw new IOException("Cannot lock " + siteWar);
|
throw new IOException("Cannot lock " + siteWar);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import com.google.gerrit.common.Die;
|
|||||||
|
|
||||||
import org.eclipse.jgit.internal.storage.file.LockFile;
|
import org.eclipse.jgit.internal.storage.file.LockFile;
|
||||||
import org.eclipse.jgit.storage.file.FileBasedConfig;
|
import org.eclipse.jgit.storage.file.FileBasedConfig;
|
||||||
import org.eclipse.jgit.util.FS;
|
|
||||||
import org.eclipse.jgit.util.SystemReader;
|
import org.eclipse.jgit.util.SystemReader;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@@ -162,7 +161,7 @@ public class InitUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Files.createDirectories(dst.getParent());
|
Files.createDirectories(dst.getParent());
|
||||||
LockFile lf = new LockFile(dst.toFile(), FS.DETECTED);
|
LockFile lf = new LockFile(dst.toFile());
|
||||||
if (!lf.lock()) {
|
if (!lf.lock()) {
|
||||||
throw new IOException("Cannot lock " + dst);
|
throw new IOException("Cannot lock " + dst);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -316,18 +316,17 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setProjectDescription(final Project.NameKey name,
|
public void setProjectDescription(Project.NameKey name, String description) {
|
||||||
final String description) {
|
|
||||||
// Update git's description file, in case gitweb is being used
|
// Update git's description file, in case gitweb is being used
|
||||||
//
|
//
|
||||||
try (Repository e = openRepository(name)) {
|
try (Repository e = openRepository(name)) {
|
||||||
final String old = getProjectDescription(e);
|
String old = getProjectDescription(e);
|
||||||
if ((old == null && description == null)
|
if ((old == null && description == null)
|
||||||
|| (old != null && old.equals(description))) {
|
|| (old != null && old.equals(description))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final LockFile f = new LockFile(new File(e.getDirectory(), "description"), FS.DETECTED);
|
LockFile f = new LockFile(new File(e.getDirectory(), "description"));
|
||||||
if (f.lock()) {
|
if (f.lock()) {
|
||||||
String d = description;
|
String d = description;
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
|
|||||||
@@ -229,12 +229,12 @@ public class SubmoduleOp {
|
|||||||
boolean sameAuthorForAll = true;
|
boolean sameAuthorForAll = true;
|
||||||
|
|
||||||
try (Repository pdb = repoManager.openRepository(subscriber.getParentKey())) {
|
try (Repository pdb = repoManager.openRepository(subscriber.getParentKey())) {
|
||||||
if (pdb.getRef(subscriber.get()) == null) {
|
if (pdb.exactRef(subscriber.get()) == null) {
|
||||||
throw new SubmoduleException(
|
throw new SubmoduleException(
|
||||||
"The branch was probably deleted from the subscriber repository");
|
"The branch was probably deleted from the subscriber repository");
|
||||||
}
|
}
|
||||||
|
|
||||||
DirCache dc = readTree(pdb, pdb.getRef(subscriber.get()));
|
DirCache dc = readTree(pdb, pdb.exactRef(subscriber.get()));
|
||||||
DirCacheEditor ed = dc.editor();
|
DirCacheEditor ed = dc.editor();
|
||||||
|
|
||||||
for (SubmoduleSubscription s : updates) {
|
for (SubmoduleSubscription s : updates) {
|
||||||
@@ -308,7 +308,7 @@ public class SubmoduleOp {
|
|||||||
ObjectId tree = dc.writeTree(oi);
|
ObjectId tree = dc.writeTree(oi);
|
||||||
|
|
||||||
ObjectId currentCommitId =
|
ObjectId currentCommitId =
|
||||||
pdb.getRef(subscriber.get()).getObjectId();
|
pdb.exactRef(subscriber.get()).getObjectId();
|
||||||
|
|
||||||
CommitBuilder commit = new CommitBuilder();
|
CommitBuilder commit = new CommitBuilder();
|
||||||
commit.setTreeId(tree);
|
commit.setTreeId(tree);
|
||||||
|
|||||||
@@ -507,7 +507,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
|||||||
Ref[] result = new Ref[showBranch.size()];
|
Ref[] result = new Ref[showBranch.size()];
|
||||||
try (Repository git = repoManager.openRepository(projectName)) {
|
try (Repository git = repoManager.openRepository(projectName)) {
|
||||||
for (int i = 0; i < showBranch.size(); i++) {
|
for (int i = 0; i < showBranch.size(); i++) {
|
||||||
Ref ref = git.getRef(showBranch.get(i));
|
Ref ref = git.findRef(showBranch.get(i));
|
||||||
if (ref != null
|
if (ref != null
|
||||||
&& ref.getObjectId() != null
|
&& ref.getObjectId() != null
|
||||||
&& (projectControl.controlForRef(ref.getLeaf().getName()).isVisible())
|
&& (projectControl.controlForRef(ref.getLeaf().getName()).isVisible())
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class DefaultSecureStore extends SecureStore {
|
|||||||
if (FileUtil.modified(sec)) {
|
if (FileUtil.modified(sec)) {
|
||||||
final byte[] out = Constants.encode(sec.toText());
|
final byte[] out = Constants.encode(sec.toText());
|
||||||
final File path = sec.getFile();
|
final File path = sec.getFile();
|
||||||
final LockFile lf = new LockFile(path, FS.DETECTED);
|
final LockFile lf = new LockFile(path);
|
||||||
if (!lf.lock()) {
|
if (!lf.lock()) {
|
||||||
throw new IOException("Cannot lock " + path);
|
throw new IOException("Cannot lock " + path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ public class ProjectConfigTest extends LocalDiskRepositoryTestCase {
|
|||||||
md.setMessage("Edit\n");
|
md.setMessage("Edit\n");
|
||||||
cfg.commit(md);
|
cfg.commit(md);
|
||||||
|
|
||||||
Ref ref = db.getRef(RefNames.REFS_CONFIG);
|
Ref ref = db.exactRef(RefNames.REFS_CONFIG);
|
||||||
return util.getRevWalk().parseCommit(ref.getObjectId());
|
return util.getRevWalk().parseCommit(ref.getObjectId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -559,12 +559,12 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
|||||||
batch1 = update1.openUpdateInBatch(bru);
|
batch1 = update1.openUpdateInBatch(bru);
|
||||||
batch1.write(update1, new CommitBuilder());
|
batch1.write(update1, new CommitBuilder());
|
||||||
batch1.commit();
|
batch1.commit();
|
||||||
assertThat(repo.getRef(update1.getRefName())).isNull();
|
assertThat(repo.exactRef(update1.getRefName())).isNull();
|
||||||
|
|
||||||
batch2 = update2.openUpdateInBatch(bru);
|
batch2 = update2.openUpdateInBatch(bru);
|
||||||
batch2.write(update2, new CommitBuilder());
|
batch2.write(update2, new CommitBuilder());
|
||||||
batch2.commit();
|
batch2.commit();
|
||||||
assertThat(repo.getRef(update2.getRefName())).isNull();
|
assertThat(repo.exactRef(update2.getRefName())).isNull();
|
||||||
} finally {
|
} finally {
|
||||||
if (batch1 != null) {
|
if (batch1 != null) {
|
||||||
batch1.close();
|
batch1.close();
|
||||||
@@ -586,8 +586,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
|||||||
assertThat(cmds.get(0).getResult()).isEqualTo(ReceiveCommand.Result.OK);
|
assertThat(cmds.get(0).getResult()).isEqualTo(ReceiveCommand.Result.OK);
|
||||||
assertThat(cmds.get(1).getResult()).isEqualTo(ReceiveCommand.Result.OK);
|
assertThat(cmds.get(1).getResult()).isEqualTo(ReceiveCommand.Result.OK);
|
||||||
|
|
||||||
assertThat(repo.getRef(update1.getRefName())).isNotNull();
|
assertThat(repo.exactRef(update1.getRefName())).isNotNull();
|
||||||
assertThat(repo.getRef(update2.getRefName())).isNotNull();
|
assertThat(repo.exactRef(update2.getRefName())).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Submodule plugins/replication updated: 4ab29b755a...e4aa03008f
Reference in New Issue
Block a user