public Commandline buildCmdLine( VssScmProviderRepository repo, ScmFileSet fileSet, String tagName, String message ) throws ScmException { Commandline command = new Commandline(); command.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() ); try { command.addSystemEnvironment(); } catch ( Exception e ) { throw new ScmException( "Can't add system environment.", e ); } command.addEnvironment( "SSDIR", repo.getVssdir() ); String ssDir = VssCommandLineUtils.getSsDir(); command.setExecutable( ssDir + VssConstants.SS_EXE ); command.createArg().setValue( VssConstants.COMMAND_LABEL ); command.createArg().setValue( VssConstants.PROJECT_PREFIX + repo.getProject() ); // User identification to get access to vss repository if ( repo.getUserPassword() != null ) { command.createArg().setValue( VssConstants.FLAG_LOGIN + repo.getUserPassword() ); } // Ignore: Do not ask for input under any circumstances. command.createArg().setValue( VssConstants.FLAG_AUTORESPONSE_DEF ); command.createArg().setValue( VssConstants.FLAG_LABEL + tagName ); return command; }
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() );
private static Commandline createCommandLine( File workingDirectory, List<File> files ) throws ScmException { // Base command line doesn't make sense here - username/password not needed, and non-interactive/non-recusive is // not valid Commandline cl = new Commandline(); cl.setExecutable( "svn" ); cl.setWorkingDirectory( workingDirectory.getAbsolutePath() ); cl.createArg().setValue( "remove" ); try { SvnCommandLineUtils.addTarget( cl, files ); } catch ( IOException e ) { throw new ScmException( "Can't create the targets file", e ); } return cl; }
public UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag ) throws ScmException Commandline cl = new Commandline(); cl.setExecutable( "cvs" ); cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() ); cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc 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 ); exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); throw new ScmException( "Error while executing command.", ex ); return new UpdateScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false );
public static Commandline createCommandLine( ScmFileSet scmFileSet, String message ) throws ScmException Commandline command = new Commandline(); File workingDirectory = scmFileSet.getBasedir(); command.setWorkingDirectory( workingDirectory.getAbsolutePath() ); command.setExecutable( "cleartool" ); command.createArg().setValue( "ci" ); command.createArg().setValue( "-c" ); command.createArg().setLine( "\"" + message + "\"" ); List<File> files = scmFileSet.getFileList(); if ( files.isEmpty() ) throw new ScmException( "There are no files in the fileset to check in!" );
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() ); }
public static boolean isCvsNT() throws ScmException { Commandline cl = new Commandline(); cl.setExecutable( "cvs" ); cl.createArg().setValue( "-v" ); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); try { CommandLineUtils.executeCommandLine( cl, stdout, stderr ); } catch ( CommandLineException e ) { throw new ScmException( "Error while executing command.", e ); } return stdout.getOutput().indexOf( "CVSNT" ) >= 0; }
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; }
/** {@inheritDoc} */ protected ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters ) throws ScmException { if ( !fileSet.getFileList().isEmpty() ) { throw new ScmException( "This provider doesn't support tagging subsets of a directory" ); } if ( tag == null || tag.trim().length() == 0 ) { throw new ScmException( "tag must be specified" ); } if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamTagConsumer consumer = new StarteamTagConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tag ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new TagScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } return new TagScmResult( cl.toString(), consumer.getTaggedFiles() ); }
public Commandline buildSetCurrentProjectCmdLine( VssScmProviderRepository repo ) throws ScmException { Commandline command = new Commandline(); try { command.addSystemEnvironment(); } catch ( Exception e ) { throw new ScmException( "Can't add system environment.", e ); } command.addEnvironment( "SSDIR", repo.getVssdir() ); String ssDir = VssCommandLineUtils.getSsDir(); command.setExecutable( ssDir + VssConstants.SS_EXE ); command.createArg().setValue( VssConstants.COMMAND_CP ); command.createArg().setValue( VssConstants.PROJECT_PREFIX + repo.getProject() ); //User identification to get access to vss repository if ( repo.getUserPassword() != null ) { command.createArg().setValue( VssConstants.FLAG_LOGIN + repo.getUserPassword() ); } //Ignore: Do not ask for input under any circumstances. command.createArg().setValue( VssConstants.FLAG_AUTORESPONSE_DEF ); return command; }
throws ScmException if ( fileSet.getFileList().isEmpty() ) throw new ScmException( "You must provide at least one file/directory to add" ); Commandline cl = createCommandLine( fileSet.getBasedir(), fileSet.getFileList() ); cl.createArg().setValue( "--config-option" ); cl.createArg().setValue( "config:miscellany:enable-auto-props=no" ); 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 AddScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false );
public static int execute( Commandline cl, CommandLineUtils.StringStreamConsumer stdout, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws ScmException { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + cl ); logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, stdout, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } return exitCode; }
protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException { Commandline cl = createCommandLine( fileSet ); CvsStatusConsumer consumer = new CvsStatusConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); int exitCode; getLogger().debug( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); getLogger().debug( "Command line: " + cl ); try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new StatusScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); }
public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, String filename ) throws ScmException { Commandline cl = createCommandLine( workingDirectory.getBasedir(), filename ); TfsBlameConsumer consumer = new TfsBlameConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new BlameScmResult( cl.toString(), "The tfs command failed.", stderr.getOutput(), false ); } return new BlameScmResult( cl.toString(), consumer.getLines() ); }
/** * {@inheritDoc} */ protected ScmResult executeRemoveCommand( ScmProviderRepository repo, ScmFileSet files, String message ) throws ScmException { Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files ); PerforceRemoveConsumer consumer = new PerforceRemoveConsumer(); try { CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, err ); if ( exitCode != 0 ) { String cmdLine = CommandLineUtils.toString( cl.getCommandline() ); StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() ); msg.append( '\n' ); msg.append( "Command line was:" + cmdLine ); throw new CommandLineException( msg.toString() ); } } catch ( CommandLineException e ) { throw new ScmException( "CommandLineException " + e.getMessage(), e ); } return new RemoveScmResult( cl.toString(), consumer.getRemovals() ); }
/** {@inheritDoc} */ protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException { Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet ); SvnStatusConsumer consumer = new SvnStatusConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } } int exitCode; try { exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr, getLogger() ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new StatusScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); }
if ( logger.isInfoEnabled() ) logger.info( "EXECUTING: " + cmd ); + " failed with exit code: " + exitCode + "." + "\n Working directory was: " + "\n " + workingDir.getAbsolutePath() + config.toString( workingDir ) + "\n"; if ( logger.isErrorEnabled() ) logger.error( providerMsg ); return new ScmResult( cmd.toString(), providerMsg, consumer.getStdErr(), success ); + "\n " + se.getMessage(); if ( se.getCause() != null ) msg += "\n Nested exception:" + "\n " + se.getCause().getMessage();
/** {@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() ); }
@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()); }
/** {@inheritDoc} */ protected UpdateScmResult executeCvsCommand( Commandline cl ) throws ScmException { CvsUpdateConsumer consumer = new CvsUpdateConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new UpdateScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new UpdateScmResult( cl.toString(), consumer.getUpdatedFiles() ); }