Browse Source

ReflogConfigTest: refactor commit method to avoid variable hiding

The author and committer parameters were hiding class members of
the same name.

Since the passed in PersonIdent instances were being created from
the class members anyway, remove the parameters and instead create
the PersonIdent instances inline in the method.

Change-Id: I66b057df388835d57f332fdcbadb8a9f4e1094a4
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
tags/v4.3.0.201603230630-rc1
David Pursehouse 8 years ago
parent
commit
964da41d52

+ 7
- 10
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java View File



// do one commit and check that reflog size is 0: no reflogs should be // do one commit and check that reflog size is 0: no reflogs should be
// written // written
commit("A Commit\n", new PersonIdent(author, commitTime, tz),
new PersonIdent(committer, commitTime, tz));
commit("A Commit\n", commitTime, tz);
commitTime += 60 * 1000; commitTime += 60 * 1000;
assertTrue( assertTrue(
"Reflog for HEAD still contain no entry", "Reflog for HEAD still contain no entry",
assertTrue(cfg.get(CoreConfig.KEY).isLogAllRefUpdates()); assertTrue(cfg.get(CoreConfig.KEY).isLogAllRefUpdates());


// do one commit and check that reflog size is increased to 1 // do one commit and check that reflog size is increased to 1
commit("A Commit\n", new PersonIdent(author, commitTime, tz),
new PersonIdent(committer, commitTime, tz));
commit("A Commit\n", commitTime, tz);
commitTime += 60 * 1000; commitTime += 60 * 1000;
assertTrue( assertTrue(
"Reflog for HEAD should contain one entry", "Reflog for HEAD should contain one entry",
assertFalse(cfg.get(CoreConfig.KEY).isLogAllRefUpdates()); assertFalse(cfg.get(CoreConfig.KEY).isLogAllRefUpdates());


// do one commit and check that reflog size is 2 // do one commit and check that reflog size is 2
commit("A Commit\n", new PersonIdent(author, commitTime, tz),
new PersonIdent(committer, commitTime, tz));
commit("A Commit\n", commitTime, tz);
assertTrue( assertTrue(
"Reflog for HEAD should contain two entries", "Reflog for HEAD should contain two entries",
db.getReflogReader(Constants.HEAD).getReverseEntries().size() == 2); db.getReflogReader(Constants.HEAD).getReverseEntries().size() == 2);
} }


private void commit(String commitMsg, PersonIdent author,
PersonIdent committer) throws IOException {
private void commit(String commitMsg, long commitTime, int tz)
throws IOException {
final CommitBuilder commit = new CommitBuilder(); final CommitBuilder commit = new CommitBuilder();
commit.setAuthor(author);
commit.setCommitter(committer);
commit.setAuthor(new PersonIdent(author, commitTime, tz));
commit.setCommitter(new PersonIdent(committer, commitTime, tz));
commit.setMessage(commitMsg); commit.setMessage(commitMsg);
ObjectId id; ObjectId id;
try (ObjectInserter inserter = db.newObjectInserter()) { try (ObjectInserter inserter = db.newObjectInserter()) {

Loading…
Cancel
Save