Support remote aliases in repo manifest.
Change-Id: Icbe5761b9d8a4ae5305bfe45b2d042f214156fc8 Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
This commit is contained in:
parent
5a26c538b3
commit
66fc834530
|
@ -641,6 +641,30 @@ public void testNonDefaultRemotes() throws Exception {
|
|||
assertTrue("We should have bar", file.exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoteAlias() throws Exception {
|
||||
StringBuilder xmlContent = new StringBuilder();
|
||||
xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
|
||||
.append("<manifest>")
|
||||
.append("<remote name=\"remote1\" fetch=\".\" alias=\"remote2\" />")
|
||||
.append("<default revision=\"master\" remote=\"remote2\" />")
|
||||
.append("<project path=\"foo\" name=\"")
|
||||
.append(defaultUri)
|
||||
.append("\" />")
|
||||
.append("</manifest>");
|
||||
|
||||
Repository localDb = createWorkRepository();
|
||||
JGitTestUtil.writeTrashFile(
|
||||
localDb, "manifest.xml", xmlContent.toString());
|
||||
RepoCommand command = new RepoCommand(localDb);
|
||||
command
|
||||
.setPath(localDb.getWorkTree().getAbsolutePath() + "/manifest.xml")
|
||||
.setURI(rootUri)
|
||||
.call();
|
||||
File file = new File(localDb.getWorkTree(), "foo/hello.txt");
|
||||
assertTrue("We should have foo", file.exists());
|
||||
}
|
||||
|
||||
private void resolveRelativeUris() {
|
||||
// Find the longest common prefix ends with "/" as rootUri.
|
||||
defaultUri = defaultDb.getDirectory().toURI().toString();
|
||||
|
|
|
@ -407,8 +407,11 @@ public void startElement(
|
|||
attributes.getValue("remote"), //$NON-NLS-1$
|
||||
attributes.getValue("groups")); //$NON-NLS-1$
|
||||
} else if ("remote".equals(qName)) { //$NON-NLS-1$
|
||||
remotes.put(attributes.getValue("name"), //$NON-NLS-1$
|
||||
attributes.getValue("fetch")); //$NON-NLS-1$
|
||||
String alias = attributes.getValue("alias"); //$NON-NLS-1$
|
||||
String fetch = attributes.getValue("fetch"); //$NON-NLS-1$
|
||||
remotes.put(attributes.getValue("name"), fetch); //$NON-NLS-1$
|
||||
if (alias != null)
|
||||
remotes.put(alias, fetch);
|
||||
} else if ("default".equals(qName)) { //$NON-NLS-1$
|
||||
defaultRemote = attributes.getValue("remote"); //$NON-NLS-1$
|
||||
defaultRevision = attributes.getValue("revision"); //$NON-NLS-1$
|
||||
|
|
Loading…
Reference in New Issue