@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(); }
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()); } } }
@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(); } }
@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 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); } } });