Map<String, List<RepoProject>> m = new TreeMap<>(); for (RepoProject proj : projects) { List<RepoProject> l = m.get(proj.getName()); if (l == null) { l = new ArrayList<>(); m.put(proj.getName(), l); boolean nameConflict = ps.size() != 1; for (RepoProject proj : ps) { String name = proj.getName(); if (nameConflict) { name += SLASH + proj.getPath(); RepoProject p = new RepoProject(name, proj.getPath(), proj.getRevision(), null, proj.getGroups(), proj.getRecommendShallow()); p.setUrl(proj.getUrl()); p.addCopyFiles(proj.getCopyFiles()); p.addLinkFiles(proj.getLinkFiles()); ret.add(p);
throw new SAXException(RepoText.get().invalidManifest); currentProject = new RepoProject( attributes.getValue("name"), //$NON-NLS-1$ attributes.getValue("path"), //$NON-NLS-1$ attributes.getValue("remote"), //$NON-NLS-1$ attributes.getValue("groups")); //$NON-NLS-1$ currentProject.setRecommendShallow( attributes.getValue("clone-depth")); //$NON-NLS-1$ } else if ("remote".equals(qName)) { //$NON-NLS-1$ if (currentProject == null) throw new SAXException(RepoText.get().invalidManifest); currentProject.addCopyFile(new CopyFile( rootRepo, currentProject.getPath(), attributes.getValue("src"), //$NON-NLS-1$ attributes.getValue("dest"))); //$NON-NLS-1$ currentProject.addLinkFile(new LinkFile( rootRepo, currentProject.getPath(), attributes.getValue("src"), //$NON-NLS-1$ attributes.getValue("dest"))); //$NON-NLS-1$ projects.removeIf((p) -> p.getName().equals(name));
private void removeNestedCopyAndLinkfiles() { for (RepoProject proj : filteredProjects) { List<CopyFile> copyfiles = new ArrayList<>(proj.getCopyFiles()); proj.clearCopyFiles(); for (CopyFile copyfile : copyfiles) { if (!isNestedReferencefile(copyfile)) { proj.addCopyFile(copyfile); } } List<LinkFile> linkfiles = new ArrayList<>(proj.getLinkFiles()); proj.clearLinkFiles(); for (LinkFile linkfile : linkfiles) { if (!isNestedReferencefile(linkfile)) { proj.addLinkFile(linkfile); } } } }
/** * Check if this sub repo is the ancestor of given sub repo. * * @param that * non null * @return true if this sub repo is the ancestor of given sub repo. */ public boolean isAncestorOf(RepoProject that) { return isAncestorOf(that.getPathWithSlash()); }
private boolean isNestedReferencefile(ReferenceFile referencefile) { if (referencefile.dest.indexOf('/') == -1) { // If the referencefile is at root level then it won't be nested. return false; } for (RepoProject proj : filteredProjects) { if (proj.getPath().compareTo(referencefile.dest) > 0) { // Early return as remaining projects can't be ancestor of this // referencefile config (filteredProjects is sorted). return false; } if (proj.isAncestorOf(referencefile.dest)) { return true; } } return false; }
StringBuilder attributes = new StringBuilder(); for (RepoProject proj : renamedProjects) { String name = proj.getName(); String path = proj.getPath(); String url = proj.getUrl(); ObjectId objectId; if (ObjectId.isId(proj.getRevision())) { objectId = ObjectId.fromString(proj.getRevision()); } else { objectId = callback.sha1(url, proj.getRevision()); if (objectId == null && !ignoreRemoteFailures) { throw new RemoteUnavailableException(url); proj.getRevision()); if (recordShallowSubmodules && proj.getRecommendShallow() != null) { rec.append("/"); //$NON-NLS-1$ rec.append(path); for (String group : proj.getGroups()) { rec.append(" "); //$NON-NLS-1$ rec.append(group); for (CopyFile copyfile : proj.getCopyFiles()) { RemoteFile rf = callback.readFileWithMode( url, proj.getRevision(), copyfile.src); objectId = inserter.insert(Constants.OBJ_BLOB, rf.getContents());
String remote = proj.getRemote(); String revision = defaultRevision; if (remote == null) { remoteUrls.put(remote, remoteUrl); proj.setUrl(remoteUrl.resolve(proj.getName()).toString()) .setDefaultRevision(revision);
throw new SAXException(RepoText.get().invalidManifest); currentProject = new RepoProject( attributes.getValue("name"), //$NON-NLS-1$ attributes.getValue("path"), //$NON-NLS-1$ attributes.getValue("remote"), //$NON-NLS-1$ attributes.getValue("groups")); //$NON-NLS-1$ currentProject.setRecommendShallow( attributes.getValue("clone-depth")); //$NON-NLS-1$ } else if ("remote".equals(qName)) { //$NON-NLS-1$ if (currentProject == null) throw new SAXException(RepoText.get().invalidManifest); currentProject.addCopyFile(new CopyFile( rootRepo, currentProject.getPath(), attributes.getValue("src"), //$NON-NLS-1$ attributes.getValue("dest"))); //$NON-NLS-1$
/** Remove copyfiles that sit in a subdirectory of any other project. */ void removeNestedCopyfiles() { for (RepoProject proj : filteredProjects) { List<CopyFile> copyfiles = new ArrayList<>(proj.getCopyFiles()); proj.clearCopyFiles(); for (CopyFile copyfile : copyfiles) { if (!isNestedCopyfile(copyfile)) { proj.addCopyFile(copyfile); } } } }
/** {@inheritDoc} */ @Override public boolean equals(Object o) { if (o instanceof RepoProject) { RepoProject that = (RepoProject) o; return this.getPathWithSlash().equals(that.getPathWithSlash()); } return false; }
private void addSubmodule(String url, String name, String revision, List<CopyFile> copyfiles, Set<String> groups, String recommendShallow) throws GitAPIException, IOException { if (repo.isBare()) { RepoProject proj = new RepoProject(url, name, revision, null, groups, recommendShallow); proj.addCopyFiles(copyfiles); bareProjects.add(proj); } else { SubmoduleAddCommand add = git .submoduleAdd() .setPath(name) .setURI(url); if (monitor != null) add.setProgressMonitor(monitor); Repository subRepo = add.call(); if (revision != null) { try (Git sub = new Git(subRepo)) { sub.checkout().setName(findRef(revision, subRepo)) .call(); } subRepo.close(); git.add().addFilepattern(name).call(); } for (CopyFile copyfile : copyfiles) { copyfile.copy(); git.add().addFilepattern(copyfile.dest).call(); } } }
parser.read(inputStream); for (RepoProject proj : parser.getFilteredProjects()) { addSubmodule(proj.getUrl(), proj.getPath(), proj.getRevision(), proj.getCopyFiles(), proj.getGroups(), proj.getRecommendShallow()); StringBuilder attributes = new StringBuilder(); for (RepoProject proj : bareProjects) { String name = proj.getPath(); String nameUri = proj.getName(); ObjectId objectId; if (ObjectId.isId(proj.getRevision()) && !ignoreRemoteFailures) { objectId = ObjectId.fromString(proj.getRevision()); } else { objectId = callback.sha1(nameUri, proj.getRevision()); if (objectId == null) { if (ignoreRemoteFailures) { proj.getRevision()); if (recordShallowSubmodules && proj.getRecommendShallow() != null) { rec.append("/"); //$NON-NLS-1$ rec.append(name); for (String group : proj.getGroups()) {
String remote = proj.getRemote(); String revision = defaultRevision; if (remote == null) { remoteUrls.put(remote, remoteUrl); proj.setUrl(remoteUrl + proj.getName()) .setDefaultRevision(revision);
/** * Check if this sub repo is the ancestor of given sub repo. * * @param that * non null * @return true if this sub repo is the ancestor of given sub repo. */ public boolean isAncestorOf(RepoProject that) { return isAncestorOf(that.getPathWithSlash()); }
/** {@inheritDoc} */ @Override public int compareTo(RepoProject that) { return this.getPathWithSlash().compareTo(that.getPathWithSlash()); } }
private boolean isNestedReferencefile(ReferenceFile referencefile) { if (referencefile.dest.indexOf('/') == -1) { // If the referencefile is at root level then it won't be nested. return false; } for (RepoProject proj : filteredProjects) { if (proj.getPath().compareTo(referencefile.dest) > 0) { // Early return as remaining projects can't be ancestor of this // referencefile config (filteredProjects is sorted). return false; } if (proj.isAncestorOf(referencefile.dest)) { return true; } } return false; }
Map<String, List<RepoProject>> m = new TreeMap<>(); for (RepoProject proj : projects) { List<RepoProject> l = m.get(proj.getName()); if (l == null) { l = new ArrayList<>(); m.put(proj.getName(), l); boolean nameConflict = ps.size() != 1; for (RepoProject proj : ps) { String name = proj.getName(); if (nameConflict) { name += SLASH + proj.getPath(); RepoProject p = new RepoProject(name, proj.getPath(), proj.getRevision(), null, proj.getGroups(), proj.getRecommendShallow()); p.setUrl(proj.getUrl()); p.addCopyFiles(proj.getCopyFiles()); p.addLinkFiles(proj.getLinkFiles()); ret.add(p);
StringBuilder attributes = new StringBuilder(); for (RepoProject proj : renamedProjects) { String name = proj.getName(); String path = proj.getPath(); String url = proj.getUrl(); ObjectId objectId; if (ObjectId.isId(proj.getRevision())) { objectId = ObjectId.fromString(proj.getRevision()); } else { objectId = callback.sha1(url, proj.getRevision()); if (objectId == null && !ignoreRemoteFailures) { throw new RemoteUnavailableException(url); proj.getRevision()); if (recordShallowSubmodules && proj.getRecommendShallow() != null) { rec.append("/"); //$NON-NLS-1$ rec.append(path); for (String group : proj.getGroups()) { rec.append(" "); //$NON-NLS-1$ rec.append(group); for (CopyFile copyfile : proj.getCopyFiles()) { RemoteFile rf = callback.readFileWithMode( url, proj.getRevision(), copyfile.src); objectId = inserter.insert(Constants.OBJ_BLOB, rf.getContents());
throw new SAXException(RepoText.get().invalidManifest); currentProject = new RepoProject( attributes.getValue("name"), //$NON-NLS-1$ attributes.getValue("path"), //$NON-NLS-1$ attributes.getValue("remote"), //$NON-NLS-1$ attributes.getValue("groups")); //$NON-NLS-1$ currentProject.setRecommendShallow( attributes.getValue("clone-depth")); //$NON-NLS-1$ } else if ("remote".equals(qName)) { //$NON-NLS-1$ if (currentProject == null) throw new SAXException(RepoText.get().invalidManifest); currentProject.addCopyFile(new CopyFile( rootRepo, currentProject.getPath(), attributes.getValue("src"), //$NON-NLS-1$ attributes.getValue("dest"))); //$NON-NLS-1$ currentProject.addLinkFile(new LinkFile( rootRepo, currentProject.getPath(), attributes.getValue("src"), //$NON-NLS-1$ attributes.getValue("dest"))); //$NON-NLS-1$ projects.removeIf((p) -> p.getName().equals(name));
private void removeNestedCopyAndLinkfiles() { for (RepoProject proj : filteredProjects) { List<CopyFile> copyfiles = new ArrayList<>(proj.getCopyFiles()); proj.clearCopyFiles(); for (CopyFile copyfile : copyfiles) { if (!isNestedReferencefile(copyfile)) { proj.addCopyFile(copyfile); } } List<LinkFile> linkfiles = new ArrayList<>(proj.getLinkFiles()); proj.clearLinkFiles(); for (LinkFile linkfile : linkfiles) { if (!isNestedReferencefile(linkfile)) { proj.addLinkFile(linkfile); } } } }