private Set<String> lastCommitChanges(Set<ScmFileStatus> statusToInclude, ScmRepository repository, File scmRoot) throws ScmException { ChangeLogScmRequest scmRequest = new ChangeLogScmRequest(repository, new ScmFileSet(scmRoot)); scmRequest.setLimit(1); return pathsAffectedByChange(scmRequest, statusToInclude, 1); }
public static Commandline createCommandLine( ScmFileSet scmFileSet ) { Commandline command = new Commandline(); File workingDirectory = scmFileSet.getBasedir(); command.setWorkingDirectory( workingDirectory.getAbsolutePath() ); command.setExecutable( "cleartool" ); command.createArg().setValue( "update" ); command.createArg().setValue( "-f" ); return command; } }
public static Commandline createCommandLine( ScmLogger logger, ScmFileSet scmFileSet ) { Commandline command = new Commandline(); File workingDirectory = scmFileSet.getBasedir(); command.setWorkingDirectory( workingDirectory.getAbsolutePath() ); command.setExecutable( "cleartool" ); command.createArg().setValue( "co" ); command.createArg().setValue( "-nc" ); List<File> files = scmFileSet.getFileList(); for ( File file : files ) { if ( logger.isInfoEnabled() ) { logger.info( "edit file: " + file.getAbsolutePath() ); } command.createArg().setValue( file.getAbsolutePath() ); } return command; }
public void addArgument( ScmFileSet f ) { info( "files: " + f.getBasedir().getAbsolutePath() ); Iterator<File> iter = f.getFileList().iterator(); while ( iter.hasNext() ) { command.createArg().setValue( ( (File) iter.next() ).getPath() ); } }
throws ScmException Commandline shell = new Commandline(); shell.setWorkingDirectory( workingDirectory.getBasedir() ); shell.setExecutable( "si" ); shell.createArg().setValue( "connect" ); shell.createArg().setValue( "--hostname=" + iRepo.getHost() ); shell.createArg().setValue( "--port=" + iRepo.getPort() ); shell.createArg().setValue( "--user=" + iRepo.getUser() ); shell.createArg().setValue( "--batch" ); shell.createArg().setValue( "--password=" + iRepo.getPassword() ); CommandLineUtils.StringStreamConsumer shellConsumer = new CommandLineUtils.StringStreamConsumer(); getLogger().debug( "Executing: " + CommandLineUtils.toString( shell.getCommandline() ) ); int exitCode = CommandLineUtils.executeCommandLine( shell, shellConsumer, shellConsumer ); if ( exitCode != 0 ) throw new ScmException( "Can't login to integrity. Message : " + shellConsumer.toString() ); getLogger().error( "Command Line Connect Exception: " + cle.getMessage() ); throw new ScmException( "Can't login to integrity. Message : " + cle.getMessage() );
/** {@inheritDoc} */ protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException { if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } if ( fileSet.getFileList().size() != 0 ) { throw new ScmException( "This provider doesn't support checking status of a subsets of a directory" ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamStatusConsumer consumer = new StarteamStatusConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cl = createCommandLine( repository, fileSet ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new StatusScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); }
/** {@inheritDoc} */ protected ScmResult executeRemoveCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message ) throws ScmException { CvsScmProviderRepository repository = (CvsScmProviderRepository) repo; Commandline cl = CvsCommandUtils.getBaseCommand( "remove", repository, fileSet ); cl.createArg().setValue( "-f" ); cl.createArg().setValue( "-l" ); List<File> files = fileSet.getFileList(); List<ScmFile> removedFiles = new ArrayList<ScmFile>(); for ( File file : files ) { String path = file.getPath().replace( '\\', '/' ); cl.createArg().setValue( path ); removedFiles.add( new ScmFile( path, ScmFileStatus.DELETED ) ); } if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } return executeCvsCommand( cl, removedFiles ); }
public static Commandline createSpecificPushCommandLine(ScmLogger logger, GitScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException { Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "push"); String branch = GitBranchCommand.getCurrentBranch(logger, repository, fileSet); if (branch == null || branch.length() == 0) { throw new ScmException("Could not detect the current branch. Don't know where I should push to!"); } // Overloaded branch name here : if repository.getUrl() is kept, during checkin(), current *local* branch // reference is not updated, whereas by using origin, it will be done ! cl.createArg().setValue("origin"); cl.createArg().setValue(branch + ":" + branch); return cl; }
public static void addFiles( Commandline cl, ScmFileSet fileSet ) { Iterator<File> it = fileSet.getFileList().iterator(); while ( it.hasNext() ) { File file = it.next(); cl.createArg().setValue( file.getPath().replace( '\\', '/' ) ); } }
throw new ScmException( "tag must be specified" ); if ( !fileSet.getFileList().isEmpty() ) throw new ScmException( "This provider doesn't support tagging subsets of a directory" ); Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tag, messageFile, scmTagParameters ); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); if ( getLogger().isInfoEnabled() ) getLogger().info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); if ( StringUtils.isNotEmpty( fileSet.getExcludes() ) ) FileUtils.getFiles( fileSet.getBasedir(), ( StringUtils.isEmpty( fileSet.getIncludes() ) ? "**" : fileSet.getIncludes() ), fileSet.getExcludes() + ",**/.svn/**", false ); files = list; FileUtils.getFiles( fileSet.getBasedir(), ( StringUtils.isEmpty( fileSet.getIncludes() ) ? "**" : fileSet.getIncludes() ), "**/.svn/**", false ); files = list;
createCommandLine( (SvnScmProviderRepository) repo, fileSet.getBasedir(), startVersion, endVersion ); SvnDiffConsumer consumer = new SvnDiffConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); if ( getLogger().isInfoEnabled() ) getLogger().info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); throw new ScmException( "Error while executing command.", ex ); return new DiffScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); return new DiffScmResult( cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() );
public static Commandline createCommandLine( SvnScmProviderRepository repository, ScmFileSet fileSet ) { Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( fileSet.getBasedir(), repository ); cl.createArg().setValue( "status" ); return cl; } }
throws ScmException Commandline cl = createCommandLine( fileSet.getBasedir(), startRevision, endRevision ); CvsDiffConsumer consumer = new CvsDiffConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); getLogger().debug( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); getLogger().debug( "Command line: " + cl ); throw new ScmException( "Error while executing command.", ex ); return new DiffScmResult( cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() );
/** {@inheritDoc} */ protected ScmResult executeAddCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary ) throws ScmException { VssScmProviderRepository repo = (VssScmProviderRepository) repository; if ( fileSet.getFileList().isEmpty() ) { throw new ScmException( "You must provide at least one file/directory to add" ); } Commandline cl = buildCmdLine( repo, fileSet ); VssAddConsumer consumer = new VssAddConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } int exitCode = VssCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new ChangeLogScmResult( cl.toString(), "The vss command failed.", stderr.getOutput(), false ); } return new AddScmResult( cl.toString(), consumer.getAddedFiles() ); }
public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, String filename ) throws ScmException { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "executing blame command..." ); } Commandline cl = createCommandLine( workingDirectory.getBasedir(), filename ); ClearCaseBlameConsumer consumer = new ClearCaseBlameConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString() ); } exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing cvs command.", ex ); } if ( exitCode != 0 ) { return new BlameScmResult( cl.toString(), "The cleartool command failed.", stderr.getOutput(), false ); } return new BlameScmResult( cl.toString(), consumer.getLines() ); }
@Override protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException { Commandline cl = createCommandLine( (GitScmProviderRepository) repo, fileSet ); File repoRootDirectory = ScmSyncGitUtils.getRepositoryRootDirectory(fileSet.getBasedir(), getLogger()); FixedGitStatusConsumer consumer = new FixedGitStatusConsumer(getLogger(), fileSet.getBasedir(), repoRootDirectory); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode = GitCommandLineUtils.execute( cl, consumer, stderr, getLogger() ); if (exitCode != 0) { if (getLogger().isInfoEnabled()) { getLogger().info( "nothing added to commit but untracked files present (use \"git add\" to track)" ); } } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); }
@Override protected ScmResult executeRemoveCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message) throws ScmException { if (fileSet.getFileList().isEmpty()) { throw new ScmException("You must provide at least one file/directory to remove"); } Commandline cl = createCommandLine(fileSet.getBasedir(), fileSet.getFileList()); GitRemoveConsumer consumer = new GitRemoveConsumer(getLogger()); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; exitCode = GitCommandLineUtils.execute(cl, consumer, stderr, getLogger()); if (exitCode != 0) { return new RemoveScmResult(cl.toString(), "The git command failed.", stderr.getOutput(), false); } return new RemoveScmResult(cl.toString(), consumer.getRemovedFiles()); }
if ( files.getFileList().isEmpty() && StringUtils.isBlank( files.getIncludes() ) ) files = new ScmFileSet( files.getBasedir(), "**", files.getExcludes() ); if ( getLogger().isErrorEnabled() ) getLogger().error( e ); throw new ScmException( e.getLocalizedMessage(), e );
getLogger().info( "Status of files changed in sandbox " + fileSet.getBasedir().getAbsolutePath() ); try String excludes = Sandbox.formatFilePatterns( fileSet.getExcludes() ); String includes = Sandbox.formatFilePatterns( fileSet.getIncludes() ); scmFileList.add( new ScmFile( memberFile.getAbsolutePath(), ScmFileStatus.UPDATED ) ); scmFileList.add( new ScmFile( memberFile.getAbsolutePath(), ScmFileStatus.DELETED ) ); getLogger().info( "No local changes found!" ); getLogger().error( "MKS API Exception: " + eh.getMessage() ); getLogger().debug( eh.getCommand() + " exited with return code " + eh.getExitCode() ); result = new StatusScmResult( eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false );
try git = JGitUtils.openRepo( fileSet.getBasedir() ); CredentialsProvider credentials = JGitUtils.prepareSession( getLogger(), git, (GitScmProviderRepository) repo ); for ( Ref ref : lsResult ) getLogger().debug( ref.getObjectId().getName() + " " + ref.getTarget().getName() ); list.add( new ScmFile( ref.getName(), ScmFileStatus.CHECKED_IN ) ); throw new ScmException( "JGit ls-remote failure!", e );