@Override public boolean hasChanges(File targetDirectory) throws IOException { VcsStatus.Builder builder = VcsStatus.builder(""); getStatusInternal(targetDirectory, builder); VcsStatus status = builder.build(); return status.hasUncommittedChanges() || status.hasUnpublishedChanges(); }
protected VcsManager getVcsManager() { if (vcsManager == null) { vcsManager = new VcsManager(); } return vcsManager; }
@Override public VcsStatus getStatus(File targetDirectory) throws IOException { VcsStatus.Builder status = VcsStatus.builder(getRevision(targetDirectory)); status.withUncommittedChanges(hasChanges(targetDirectory)); status.withBranch(getBranch(targetDirectory)); return status.build(); }
@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 VcsStatus getStatus(File targetDirectory) throws IOException { final VcsStatus.Builder status = VcsStatus.builder(getRevision(targetDirectory)); status.withBranch(getBranch(targetDirectory)); getStatusInternal(targetDirectory, status); return status.build(); }
@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); } } });
@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 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 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(); }
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, Module module) { config.setProperty(prefix + ".name", module.getName()); config.setProperty(prefix + ".vcs", module.getVcs().getType()); } }
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)); }
public static Builder builder(String revision) { return new Builder(revision); }
public VcsStatus build() { return new VcsStatus(revision, branch, hasUnpublishedChanges, hasUncommittedChanges); }
public RepoCache(File cacheDirectory) throws IOException { this.cacheDirectory = cacheDirectory; this.mappingFile = new File(cacheDirectory, CACHE_MAPPING_FILE); this.cacheMapping = loadCacheMapping(mappingFile); }
@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); } });
@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()); } }