|
|
@@ -46,6 +46,8 @@ import org.eclipse.jgit.revwalk.RevCommit; |
|
|
|
import org.eclipse.jgit.storage.file.FileBasedConfig; |
|
|
|
import org.eclipse.jgit.treewalk.TreeWalk; |
|
|
|
import org.eclipse.jgit.util.FS; |
|
|
|
import org.eclipse.jgit.util.IO; |
|
|
|
import org.eclipse.jgit.util.RawParseUtils; |
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
public class RepoCommandTest extends RepositoryTestCase { |
|
|
@@ -749,7 +751,53 @@ public class RepoCommandTest extends RepositoryTestCase { |
|
|
|
String gitlink = localDb.resolve(Constants.HEAD + ":foo").name(); |
|
|
|
assertEquals("The gitlink is same as remote head", |
|
|
|
oldCommitId.name(), gitlink); |
|
|
|
|
|
|
|
File dotmodules = new File(localDb.getWorkTree(), |
|
|
|
Constants.DOT_GIT_MODULES); |
|
|
|
assertTrue(dotmodules.exists()); |
|
|
|
// The .gitmodules file should have "branch" lines |
|
|
|
String gitModulesContents = RawParseUtils |
|
|
|
.decode(IO.readFully(dotmodules)); |
|
|
|
assertTrue(gitModulesContents.contains("branch = branch")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testRevisionBare_ignoreTags() throws Exception { |
|
|
|
Repository remoteDb = createBareRepository(); |
|
|
|
Repository tempDb = createWorkRepository(); |
|
|
|
|
|
|
|
StringBuilder xmlContent = new StringBuilder(); |
|
|
|
xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") |
|
|
|
.append("<manifest>") |
|
|
|
.append("<remote name=\"remote1\" fetch=\".\" />") |
|
|
|
.append("<default revision=\"").append("refs/tags/" + TAG) |
|
|
|
.append("\" remote=\"remote1\" />") |
|
|
|
.append("<project path=\"foo\" name=\"") |
|
|
|
.append(defaultUri) |
|
|
|
.append("\" />").append("</manifest>"); |
|
|
|
JGitTestUtil.writeTrashFile(tempDb, "manifest.xml", |
|
|
|
xmlContent.toString()); |
|
|
|
RepoCommand command = new RepoCommand(remoteDb); |
|
|
|
command.setPath( |
|
|
|
tempDb.getWorkTree().getAbsolutePath() + "/manifest.xml") |
|
|
|
.setURI(rootUri).call(); |
|
|
|
// Clone it |
|
|
|
File directory = createTempDirectory("testReplaceManifestBare"); |
|
|
|
File dotmodules; |
|
|
|
try (Repository localDb = Git.cloneRepository().setDirectory(directory) |
|
|
|
.setURI(remoteDb.getDirectory().toURI().toString()).call() |
|
|
|
.getRepository()) { |
|
|
|
dotmodules = new File(localDb.getWorkTree(), |
|
|
|
Constants.DOT_GIT_MODULES); |
|
|
|
assertTrue(dotmodules.exists()); |
|
|
|
} |
|
|
|
|
|
|
|
// The .gitmodules file should not have "branch" lines |
|
|
|
String gitModulesContents = RawParseUtils |
|
|
|
.decode(IO.readFully(dotmodules)); |
|
|
|
assertFalse(gitModulesContents.contains("branch")); |
|
|
|
assertTrue(gitModulesContents.contains("ref = refs/tags/" + TAG)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |