diff options
author | Han-Wen Nienhuys <hanwen@google.com> | 2018-02-14 20:34:03 +0100 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2018-02-19 20:24:07 +0900 |
commit | 3214171decf596f003c154685638b01faba31ff3 (patch) | |
tree | 3fafe82a7714f4aee9319d3a75d52a320e4b4b9e /org.eclipse.jgit.test | |
parent | 446a7096ef01c0e3bb56736403d91b125b2ee6ba (diff) | |
download | jgit-3214171decf596f003c154685638b01faba31ff3.tar.gz jgit-3214171decf596f003c154685638b01faba31ff3.zip |
RepoCommand: don't record new commit if tree did not change
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: Ib6509e816684256d723558d5e8f3c37de58a2ff8
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java index 2df34df30f..f4b86e0ce6 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java @@ -186,6 +186,59 @@ public class RepoCommandTest extends RepositoryTestCase { } @Test + public void runTwiceIsNOP() throws Exception { + Repository child = Git.cloneRepository() + .setURI(groupADb.getDirectory().toURI().toString()) + .setDirectory(createUniqueTestGitDir(true)).setBare(true).call() + .getRepository(); + + Repository dest = Git.cloneRepository() + .setURI(db.getDirectory().toURI().toString()) + .setDirectory(createUniqueTestGitDir(true)).setBare(true).call() + .getRepository(); + + assertTrue(dest.isBare()); + assertTrue(child.isBare()); + + StringBuilder xmlContent = new StringBuilder(); + xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") + .append("<manifest>") + .append("<remote name=\"remote1\" fetch=\"..\" />") + .append("<default revision=\"master\" remote=\"remote1\" />") + .append("<project path=\"base\" name=\"platform/base\" />") + .append("</manifest>"); + RepoCommand cmd = new RepoCommand(dest); + + IndexedRepos repos = new IndexedRepos(); + repos.put("platform/base", child); + + RevCommit commit = cmd + .setInputStream(new ByteArrayInputStream( + xmlContent.toString().getBytes(UTF_8))) + .setRemoteReader(repos) + .setURI("platform/") + .setTargetURI("platform/superproject") + .setRecordRemoteBranch(true) + .setRecordSubmoduleLabels(true) + .call(); + + String firstIdStr = commit.getId().name() + ":" + ".gitmodules"; + commit = new RepoCommand(dest) + .setInputStream(new ByteArrayInputStream( + xmlContent.toString().getBytes(UTF_8))) + .setRemoteReader(repos) + .setURI("platform/") + .setTargetURI("platform/superproject") + .setRecordRemoteBranch(true) + .setRecordSubmoduleLabels(true) + .call(); + String idStr = commit.getId().name() + ":" + ".gitmodules"; + assertEquals(firstIdStr, idStr); + child.close(); + dest.close(); + } + + @Test public void androidSetup() throws Exception { Repository child = Git.cloneRepository() .setURI(groupADb.getDirectory().toURI().toString()) @@ -235,6 +288,7 @@ public class RepoCommandTest extends RepositoryTestCase { child.close(); dest.close(); } + @Test public void recordUnreachableRemotes() throws Exception { StringBuilder xmlContent = new StringBuilder(); @@ -277,8 +331,6 @@ public class RepoCommandTest extends RepositoryTestCase { dest.close(); } - - @Test public void gerritSetup() throws Exception { Repository child = |