private Set<String> localChanges(Set<ScmFileStatus> statusToInclude, ScmRepository repository, File scmRoot) throws ScmException { final StatusScmResult status = this.manager.status(repository, new ScmFileSet(scmRoot)); Set<String> affected = new LinkedHashSet<>(); for (final ScmFile file : status.getChangedFiles()) { if (statusToInclude.contains(file.getStatus())) { affected.add(file.getPath()); } } return affected; }
/** {@inheritDoc} */ public boolean equals( Object other ) { if ( !( other instanceof ScmFile ) ) { return false; } return ( (ScmFile) other ).getPath().equals( path ); }
/** {@inheritDoc} */ public int compareTo( ScmFile other ) { return other.getPath().compareTo( path ); }
/** {@inheritDoc} */ public int compareTo( ScmFile other ) { return other.getPath().compareTo( path ); }
/** {@inheritDoc} */ public boolean equals( Object other ) { if ( !( other instanceof ScmFile ) ) { return false; } return ( (ScmFile) other ).getPath().equals( path ); }
protected List<ScmFile> getFiles() { if ( !filtered ) { for ( Iterator<ScmFile> it = files.iterator(); it.hasNext(); ) { if ( !new File( workingDirectory, it.next().getPath() ).isFile() ) { it.remove(); } } filtered = true; } return files; }
protected List<ScmFile> getFiles() { if ( !filtered ) { for ( Iterator<ScmFile> it = files.iterator(); it.hasNext(); ) { if ( !new File( workingDirectory, it.next().getPath() ).isFile() ) { it.remove(); } } filtered = true; } return files; }
protected List<ScmFile> getFiles() { if ( !filtered ) { for ( Iterator<ScmFile> ite = files.iterator(); ite.hasNext(); ) { ScmFile file = ite.next(); if ( !file.getStatus().equals( ScmFileStatus.DELETED ) && !new File( workingDirectory, file.getPath() ).isFile() ) { ite.remove(); } } filtered = true; } return files; }
protected List<ScmFile> getFiles() { if ( !filtered ) { for ( Iterator<ScmFile> ite = files.iterator(); ite.hasNext(); ) { ScmFile file = ite.next(); if ( !file.getStatus().equals( ScmFileStatus.DELETED ) && !new File( workingDirectory, file.getPath() ).isFile() ) { ite.remove(); } } filtered = true; } return files; }
private List<File> refineUpdatedFilesInScmResult(List<?> updatedFiles){ List<File> refinedUpdatedFiles = new ArrayList<File>(); // Cannot use directly a List<ScmFile> or List<File> here, since result type will depend upon // current scm api version for (Object scmFile :updatedFiles) { if(scmFile instanceof File){ String checkoutScmDir = ScmSyncConfigurationBusiness.getCheckoutScmDirectoryAbsolutePath(); String scmPath = ((File) scmFile).getAbsolutePath(); if(scmPath.startsWith(checkoutScmDir)){ scmPath = scmPath.substring(checkoutScmDir.length() + 1); } refinedUpdatedFiles.add(new File(scmPath)); } else if(scmFile instanceof ScmFile){ refinedUpdatedFiles.add(new File(((ScmFile)scmFile).getPath())); } else { LOGGER.severe("Unhandled AddScmResult.addedFiles type : " + scmFile.getClass().getName()); } } return refinedUpdatedFiles; }
protected List<ScmFile> getFiles() { List<ScmFile> onlyFiles = new ArrayList<ScmFile>(); for ( ScmFile file : files ) { // second part is for svn 1.7 as the co output is now relative not a full path as for svn 1.7- if ( !( !file.getStatus().equals( ScmFileStatus.DELETED ) && !new File( getWorkingDirectory(), file.getPath() ).isFile() ) || !( !file.getStatus().equals( ScmFileStatus.DELETED ) && !new File( getWorkingDirectory().getParent(), file.getPath() ).isFile() ) ) { onlyFiles.add( file ); } } return onlyFiles; }
protected List<ScmFile> getFiles() { List<ScmFile> onlyFiles = new ArrayList<ScmFile>(); for ( ScmFile file : files ) { // second part is for svn 1.7 as the co output is now relative not a full path as for svn 1.7- if ( !( !file.getStatus().equals( ScmFileStatus.DELETED ) && !new File( getWorkingDirectory(), file.getPath() ).isFile() ) || !( !file.getStatus().equals( ScmFileStatus.DELETED ) && !new File( getWorkingDirectory().getParent(), file.getPath() ).isFile() ) ) { onlyFiles.add( file ); } } return onlyFiles; }
private Set<String> localChanges(Set<ScmFileStatus> statusToInclude, ScmRepository repository, File scmRoot) throws ScmException { final StatusScmResult status = this.manager.status(repository, new ScmFileSet(scmRoot)); Set<String> affected = new LinkedHashSet<>(); for (final ScmFile file : status.getChangedFiles()) { if (statusToInclude.contains(file.getStatus())) { affected.add(file.getPath()); } } return affected; }
private File assertCheckedOutFile( List<ScmFile> files, int i, String fileName, ScmFileStatus status ) throws Exception { File file = new File( getWorkingDirectory(), fileName ); assertTrue( file.getAbsolutePath() + " file doesn't exist.", file.exists() ); ScmFile coFile = files.get( i ); assertSame( status, coFile.getStatus() ); assertPath( fileName, coFile.getPath() ); return file; } }
private Set<File> filterUnchangedFiles(Set<File> originalFiles) throws MojoExecutionException { MavenProject topLevelProject = session.getTopLevelProject(); try { String connectionUrl = MoreObjects.firstNonNull( topLevelProject.getScm().getConnection(), topLevelProject.getScm().getDeveloperConnection()); ScmRepository repository = scmManager.makeScmRepository(connectionUrl); ScmFileSet scmFileSet = new ScmFileSet(topLevelProject.getBasedir()); String basePath = topLevelProject.getBasedir().getAbsoluteFile().getPath(); List<String> changedFiles = scmManager.status(repository, scmFileSet).getChangedFiles().stream() .map(f -> String.format("%s/%s", basePath, f.getPath())) .collect(Collectors.toList()); return originalFiles.stream() .filter(f -> changedFiles.contains(f.getPath())) .collect(Collectors.toSet()); } catch (ScmException e) { throw new MojoExecutionException(e.getMessage(), e); } }
private static ChangeSet convertScmFileSetToChangeSet( List files ) { ChangeSet changeSet = null; if ( files != null && !files.isEmpty() ) { changeSet = new ChangeSet(); // TODO: author, etc. for ( Iterator it = files.iterator(); it.hasNext(); ) { ScmFile scmFile = (ScmFile) it.next(); ChangeFile file = new ChangeFile(); file.setName( scmFile.getPath() ); // TODO: revision? file.setStatus( scmFile.getStatus().toString() ); changeSet.addFile( file ); } } return changeSet; }
private static ChangeSet convertScmFileSetToChangeSet( List<ScmFile> files ) { ChangeSet changeSet = null; if ( files != null && !files.isEmpty() ) { changeSet = new ChangeSet(); // TODO: author, etc. for ( ScmFile scmFile : files ) { ChangeFile file = new ChangeFile(); file.setName( scmFile.getPath() ); // TODO: revision? file.setStatus( scmFile.getStatus().toString() ); changeSet.addFile( file ); } } return changeSet; }
private static ChangeSet convertScmFileSetToChangeSet( List<ScmFile> files ) { ChangeSet changeSet = null; if ( files != null && !files.isEmpty() ) { changeSet = new ChangeSet(); // TODO: author, etc. for ( ScmFile scmFile : files ) { ChangeFile file = new ChangeFile(); file.setName( scmFile.getPath() ); // TODO: revision? file.setStatus( scmFile.getStatus().toString() ); changeSet.addFile( file ); } } return changeSet; }
protected StatusScmResult executeStatusCommand( ScmProviderRepository r, ScmFileSet f ) throws ScmException { TfsScmProviderRepository tfsRepo = (TfsScmProviderRepository) r; TfsCommand command = createCommand( tfsRepo, f ); ChangedFileConsumer out = new ChangedFileConsumer( getLogger() ); ErrorStreamConsumer err = new ErrorStreamConsumer(); int status = command.execute( out, err ); if ( status != 0 || err.hasBeenFed() ) { return new StatusScmResult( command.getCommandString(), "Error code for TFS status command - " + status, err.getOutput(), false ); } Iterator<ScmFile> iter = out.getChangedFiles().iterator(); getLogger().debug( "Iterating" ); while ( iter.hasNext() ) { ScmFile file = (ScmFile) iter.next(); getLogger().debug( file.getPath() + ":" + file.getStatus() ); } return new StatusScmResult( command.getCommandString(), out.getChangedFiles() ); }
protected StatusScmResult executeStatusCommand( ScmProviderRepository r, ScmFileSet f ) throws ScmException { TfsScmProviderRepository tfsRepo = (TfsScmProviderRepository) r; TfsCommand command = createCommand( tfsRepo, f ); ChangedFileConsumer out = new ChangedFileConsumer( getLogger() ); ErrorStreamConsumer err = new ErrorStreamConsumer(); int status = command.execute( out, err ); if ( status != 0 || err.hasBeenFed() ) { return new StatusScmResult( command.getCommandString(), "Error code for TFS status command - " + status, err.getOutput(), false ); } Iterator<ScmFile> iter = out.getChangedFiles().iterator(); getLogger().debug( "Iterating" ); while ( iter.hasNext() ) { ScmFile file = (ScmFile) iter.next(); getLogger().debug( file.getPath() + ":" + file.getStatus() ); } return new StatusScmResult( command.getCommandString(), out.getChangedFiles() ); }