@Override public boolean matches(Pride pride, Module module) throws IOException { String branch = module.getVcs().getSupport().getBranch(pride.getModuleDirectory(module.getName())); if (Strings.isNullOrEmpty(branch)) { branch = module.getVcs().getSupport().getDefaultBranch(); } return branchPattern.matcher(branch).matches(); }
@Override public String formatModule(Module module) throws Exception { File moduleDirectory = pride.getModuleDirectory(module.getName()); // MM module-name (git) VcsStatus status = module.getVcs().getSupport().getStatus(moduleDirectory); String branch = status.getBranch(); StringBuilder line = new StringBuilder(); line.append(status.hasUnpublishedChanges() ? 'M' : ' '); line.append(status.hasUncommittedChanges() ? 'M' : ' '); line.append(' ').append(module.getName()); line.append(Strings.repeat(" ", this.moduleMaxLength + 2 - module.getName().length())); if (!Strings.isNullOrEmpty(branch)) { line.append(branch); line.append(Strings.repeat(" ", this.branchMaxLength + 2 - branch.length())); line.append('@'); } line.append(status.getRevision()); line.append(" (").append(module.getVcs().getType()).append(")"); return line.toString(); } }
public Vcs getVcs(final String type, Configuration configuration) { VcsSupportFactory vcsFactory = vcss.get(type); if (vcsFactory == null) { throw new PrideException("No support for VCS type \"" + type + "\""); } return new Vcs(type, vcsFactory.createVcsSupport(configuration)); }
private static SortedMap<String, Module> loadModules(File rootDirectory, Collection<Module> modules) throws IOException { SortedMap<String, Module> modulesMap = Maps.newTreeMap(); for (Module module : modules) { String moduleName = module.getName(); File moduleDir = new File(rootDirectory, moduleName); if (!moduleDir.isDirectory()) { throw new PrideException("Module \"" + moduleName + "\" is missing (" + moduleDir + ")"); } if (!isValidModuleDirectory(moduleDir)) { throw new PrideException("No module found in \"" + moduleDir + "\""); } logger.debug("Found {} module {}", module.getVcs().getType(), moduleName); modulesMap.put(module.getName(), module); } return modulesMap; }
@Override protected void saveModule(Configuration config, String prefix, Module module) { config.setProperty(prefix + ".name", module.getName()); config.setProperty(prefix + ".vcs", module.getVcs().getType()); } }
private StatusFormatter(Pride pride) throws IOException { this.pride = pride; Collection<Module> modules = pride.getModules(); for (Module module : modules) { String name = module.getName(); this.moduleMaxLength = Math.max(this.moduleMaxLength, name.length()); String branch = module.getVcs().getSupport().getStatus(pride.getModuleDirectory(name)).getBranch(); if (!Strings.isNullOrEmpty(branch)) { this.branchMaxLength = Math.max(this.branchMaxLength, branch.length()); } } }
continue; logger.info("Adding existing {} module in {}", vcs.getType(), dir); pride.addModule(moduleName, vcs); prideModified = true;
public Vcs findSupportingVcs(File directory, Configuration configuration) { for (VcsSupportFactory factory : vcss.values()) { if (factory.canSupport(directory)) { return new Vcs(factory.getType(), factory.createVcsSupport(configuration)); } } throw new PrideException("No VCS support found for local repository in directory \"" + directory + "\""); }
@Override public boolean apply(Module module) { File moduleDir = pride.getModuleDirectory(module.getName()); try { return module.getVcs().getSupport().hasChanges(moduleDir); } catch (Exception e) { throw Throwables.propagate(e); } } });
@Override protected void saveModule(Configuration config, String prefix, ExportedModule module) { config.setProperty(prefix + ".name", module.getName()); config.setProperty(prefix + ".remote", module.getRemote()); config.setProperty(prefix + ".revision", module.getRevision()); config.setProperty(prefix + ".vcs", module.getVcs().getType()); } }
@Override protected void execute(Pride pride, Module module) throws IOException { File moduleDir = pride.getModuleDirectory(module.getName()); String moduleBranch = explicitSwitchToBranch; if (Strings.isNullOrEmpty(moduleBranch)) { moduleBranch = module.getVcs().getSupport().getBranch(pride.getModuleDirectory(module.getName())); } module.getVcs().getSupport().update(moduleDir, moduleBranch, recursive, false); }
private Collection<ExportedModule> getModulesToAdd(RuntimeConfiguration config) { String repoType = config.override(REPO_TYPE_DEFAULT, explicitRepoType); final String repoBaseUrl = config.override(REPO_BASE_URL, explicitRepoBaseUrl); final String branch = config.override(REPO_BRANCH, explicitBranch); final Vcs vcs = getVcsManager().getVcs(repoType, config); final VcsSupport vcsSupport = vcs.getSupport(); return Collections2.transform(modules, new Function<String, ExportedModule>() { @Override public ExportedModule apply(String module) { String moduleName = vcsSupport.resolveRepositoryName(module); String repoUrl; if (!StringUtils.isEmpty(moduleName)) { repoUrl = module; } else { moduleName = module; repoUrl = getRepoUrl(repoBaseUrl, moduleName); } return new ExportedModule(moduleName, repoUrl, branch, vcs); } }); }
String repoUrl = moduleEntry.getRemote(); Vcs vcs = moduleEntry.getVcs(); VcsSupport vcsSupport = vcs.getSupport(); String revision = moduleEntry.getRevision(); if (Strings.isNullOrEmpty(revision)) {
@Override public boolean matches(Pride pride, Module module) throws IOException { VcsStatus status = module.getVcs().getSupport().getStatus(pride.getModuleDirectory(module.getName())); return (uncommittedChanges && status.hasUncommittedChanges()) || (unpublishedChanges && status.hasUnpublishedChanges()); }
@Override public ExportedModule apply(Module module) { try { VcsSupport vcsSupport = module.getVcs().getSupport(); File moduleDirectory = pride.getModuleDirectory(module.getName()); VcsStatus vcsStatus = vcsSupport.getStatus(moduleDirectory); String revision; if (explicit || Strings.isNullOrEmpty(vcsStatus.getBranch())) { revision = vcsStatus.getRevision(); } else { revision = vcsStatus.getBranch(); } return new ExportedModule(module.getName(), vcsSupport.getRepositoryUrl(moduleDirectory), revision, module.getVcs()); } catch (IOException e) { throw Throwables.propagate(e); } } });