Fetches and checkouts from remote if local branch doesn't exist.

@param branchName
Branch name to check.
@throws MojoFailureException
@throws CommandLineException
431875
protected void gitFetchRemoteAndCreate(final String branchName)
            throws MojoFailureException, CommandLineException {
        if (!gitCheckBranchExists(branchName)) {
            getLog().info(
                    "Local branch '"
                            + branchName
                            + "' doesn't exist. Trying to fetch and check it out from '"
                            + gitFlowConfig.getOrigin() + "'.");
            gitFetchRemote(branchName);
            gitCreateAndCheckout(branchName, gitFlowConfig.getOrigin() + "/"
                    + branchName);
        }
    }
1099466
@SuppressWarnings("unchecked")
    public void execute()
        throws MojoExecutionException, CompilationFailureException
    {
        // ----------------------------------------------------------------------
        // Look up the compiler. This is done before other code than can
        // cause the mojo to return before the lookup is done possibly resulting
        // in misconfigured POMs still building.
        // ----------------------------------------------------------------------

        Compiler compiler;

        getLog().debug( "Using compiler '" + compilerId + "'." );

        try
        {
            compiler = compilerManager.getCompiler( compilerId );
        }
        catch ( NoSuchCompilerException e )
        {
            throw new MojoExecutionException( "No such compiler '" + e.getCompilerId() + "'." );
        }

        // ----------------------------------------------------------------------
        //
        // ----------------------------------------------------------------------

        List compileSourceRoots = removeEmptyCompileSourceRoots( getCompileSourceRoots() );

        if ( compileSourceRoots.isEmpty() )
        {
            getLog().info( "No sources to compile" );

            return;
        }

        if ( getLog().isDebugEnabled() )
        {
            getLog().debug( "Source directories: " + compileSourceRoots.toString().replace( ',', '\n' ) );
            getLog().debug( "Classpath: " + getClasspathElements().toString().replace( ',', '\n' ) );
            getLog().debug( "Output directory: " + getOutputDirectory() );
        }

        // ----------------------------------------------------------------------
        // Create the compiler configuration
        // ----------------------------------------------------------------------

        CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

        compilerConfiguration.setOutputLocation( getOutputDirectory().getAbsolutePath() );

        compilerConfiguration.setClasspathEntries( getClasspathElements() );

        compilerConfiguration.setSourceLocations( compileSourceRoots );

        compilerConfiguration.setOptimize( optimize );

        compilerConfiguration.setDebug( debug );

        compilerConfiguration.setVerbose( verbose );

        compilerConfiguration.setShowWarnings( showWarnings );

        compilerConfiguration.setShowDeprecation( showDeprecation );

        compilerConfiguration.setSourceVersion( source );

        compilerConfiguration.setTargetVersion( target );

        compilerConfiguration.setSourceEncoding( encoding );

        if ( compilerArguments != null )
        {
            LinkedHashMap cplrArgsCopy = new LinkedHashMap();
            for (Object o : compilerArguments.entrySet()) {
                Map.Entry me = (Map.Entry) o;
                String key = (String) me.getKey();
                if (!key.startsWith("-")) {
                    key = "-" + key;
                }
                cplrArgsCopy.put(key, me.getValue());
            }
            compilerConfiguration.setCustomCompilerArguments( cplrArgsCopy );
        }

        compilerConfiguration.setFork( fork );

        compilerConfiguration.setExecutable( executable );

        compilerConfiguration.setWorkingDirectory( basedir );

        compilerConfiguration.setCompilerVersion( compilerVersion );

        compilerConfiguration.setBuildDirectory( buildDirectory );

        compilerConfiguration.setOutputFileName( outputFileName );

        Set staleSources;

        boolean canUpdateTarget;

        try
        {
            staleSources =
                computeStaleSources( compilerConfiguration, compiler, getSourceInclusionScanner( staleMillis ) );

            canUpdateTarget = compiler.canUpdateTarget( compilerConfiguration );

            if ( compiler.getCompilerOutputStyle().equals( CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES ) &&
                !canUpdateTarget )
            {
                getLog().info( "RESCANNING!" );
                String inputFileEnding = compiler.getInputFileEnding( compilerConfiguration );

                Set sources = computeStaleSources( compilerConfiguration, compiler,
                                                   getSourceInclusionScanner( inputFileEnding ) );

                compilerConfiguration.setSourceFiles( sources );
            }
            else
            {
                compilerConfiguration.setSourceFiles( staleSources );
            }
        }
        catch ( CompilerException e )
        {
            throw new MojoExecutionException( "Error while computing stale sources.", e );
        }

        if ( staleSources.isEmpty() )
        {
            getLog().info( "Nothing to compile - all classes are up to date" );

            return;
        }

        // ----------------------------------------------------------------------
        // Dump configuration
        // ----------------------------------------------------------------------

        if ( getLog().isDebugEnabled() )
        {
            getLog().debug( "Classpath:" );

            for (Object o : getClasspathElements()) {
                String s = (String) o;

                getLog().debug(" " + s);
            }

            getLog().debug( "Source roots:" );

            for (Object o : getCompileSourceRoots()) {
                String root = (String) o;

                getLog().debug(" " + root);
            }

            if ( fork )
            {
                try
                {
                    String[] cl = compiler.createCommandLine( compilerConfiguration );
                    if ( cl != null && cl.length > 0 )
                    {
                        StringBuffer sb = new StringBuffer();
                        sb.append( cl[0] );
                        for ( int i = 1; i < cl.length; i++ )
                        {
                            sb.append( " " );
                            sb.append( cl[i] );
                        }
                        getLog().debug( "Command line options:" );
                        getLog().debug( sb );
                    }
                }
                catch ( CompilerException ce )
                {
                    getLog().debug( ce );
                }
            }
        }

        // ----------------------------------------------------------------------
        // Compile!
        // ----------------------------------------------------------------------

        List<CompilerError> messages;

        try
        {
            messages = compiler.compile( compilerConfiguration );
        }
        catch ( Exception e )
        {
            throw new MojoExecutionException( "Fatal error compiling", e );
        }

        boolean compilationError = false;

        for ( CompilerError message : messages)
        {
            if ( message.isError() )
            {
                compilationError = true;
            }
        }

        if ( compilationError )
        {
            throw new CompilationFailureException( messages );
        }
        else
        {
            for (CompilerError message : messages) {
                getLog().warn(message.toString());
            }
        }
    }
82687
protected boolean validBranchName(final String branchName)
            throws MojoFailureException, CommandLineException {
        CommandResult r = executeGitCommandExitCode("check-ref-format",
                "--allow-onelevel", branchName);
        return r.getExitCode() == SUCCESS_EXIT_CODE;
    }
835283
def grab(branch, path = Dir.pwd, remote = 'origin')
      exit_status = 1
      error "no branch provided" if branch.nil?
      #remotes  = FalkorLib::Git.remotes(path)
      branches = FalkorLib::Git.list_branch(path)
      if branches.include? "remotes/#{remote}/#{branch}"
        info "Grab the branch '#{remote}/#{branch}'"
        exit_status = execute_in_dir(FalkorLib::Git.rootdir( path ), "git branch --track #{branch} #{remote}/#{branch}")
      else
        warning "the remote branch '#{remote}/#{branch}' cannot be found"
      end
      exit_status
    end
1087988
@Override
    public void doExecute() throws MojoExecutionException, MojoFailureException {
        if (!ignoreResultFailures && !scanResultsForFailedRequests) {
            getLog().warn(String.format(
                    "current value of scanResultsForFailedRequests(%s) is incompatible with ignoreResultFailures(%s), setting scanResultsForFailedRequests to true",
                    scanResultsForFailedRequests,
                    ignoreResultFailures
            ));
            scanResultsForFailedRequests = true;
        }
        if (scanResultsForSuccessfulRequests || scanResultsForFailedRequests) {
            getLog().info(" ");
            getLog().info(LINE_SEPARATOR);
            getLog().info("S C A N N I N G    F O R    R E S U L T S");
            getLog().info(LINE_SEPARATOR);
            getLog().info(" ");
            TestConfig testConfig = new TestConfig(new File(testConfigFile));
            String resultFormat = testConfig.getResultsOutputIsCSVFormat() ? "CSV" : "JTL";
            getLog().info(String.format("Will scan results using format: %s", resultFormat));
            ResultScanner resultScanner = new ResultScanner(
                    scanResultsForSuccessfulRequests,
                    scanResultsForFailedRequests,
                    testConfig.getResultsOutputIsCSVFormat()
            );
            for (String resultFileLocation : testConfig.getResultsFileLocations()) {
                resultScanner.parseResultFile(new File(resultFileLocation));
            }
            getLog().info(" ");
            getLog().info(LINE_SEPARATOR);
            getLog().info("P E R F O R M A N C E    T E S T    R E S U L T S");
            getLog().info(LINE_SEPARATOR);
            getLog().info(" ");
            getLog().info(String.format("Result (.%s) files scanned: %s", resultFormat.toLowerCase(), testConfig.getResultsFileLocations().size()));
            getLog().info(String.format("Successful requests:         %s", resultScanner.getSuccessCount()));
            getLog().info(String.format("Failed requests:             %s", resultScanner.getFailureCount()));
            TestFailureDecider decider = new TestFailureDecider(ignoreResultFailures, errorRateThresholdInPercent, resultScanner);
            decider.runChecks();
            getLog().info(String.format("Failures:                    %s%% (%s%% accepted)", decider.getErrorPercentage(), decider.getErrorPercentageThreshold()));
            getLog().info(" ");
            if (decider.failBuild()) {
                throw new MojoFailureException(String.format(
                        "Failing build because error percentage %s is above accepted threshold %s. JMeter logs are available at: '%s'",
                        logsDirectory.getAbsolutePath(),
                        decider.getErrorPercentage(),
                        decider.getErrorPercentageThreshold()
                ));
            }
        } else {
            getLog().info(" ");
            getLog().info("Results of Performance Test(s) have not been scanned.");
            getLog().info(" ");
        }
    }
1371938
@Override
    public void execute() throws MojoExecutionException {
        if (StringUtils.isBlank(this.refreshPort)) {
            this.refreshPort = "8080";
        }

        // Do a ping to see if the server is up, if not, log and just exit
        if (!ping()) {
            getLog().warn("Connection failed to " + this.refreshHost + ":" + this.refreshPort + ", " + getAbortedMsg());
            return;
        }

        executeRefresh();
    }
702316
protected void execute(CommandLine cmdLine)
            throws MojoFailureException, MojoExecutionException
        {
        try
            {
            DefaultExecutor executor = new DefaultExecutor();
            executor.setWorkingDirectory(workingDir);
            executor.setStreamHandler(new PumpStreamHandler(System.out, System.err, System.in));

            executor.execute(cmdLine);
            }
        catch (ExecuteException e)
            {
            throw new MojoFailureException("npm failure", e);
            }
        catch (IOException e)
            {
            throw new MojoExecutionException("Error executing NPM", e);
            }
        }
1049148
public PullResult pullFromRepository(Git git, String remote, String remoteBranch) {
        try {
            return git.pull()
                .setRemote(remote)
                .setRemoteBranchName(remoteBranch)
                .call();
        } catch (GitAPIException e) {
            throw new IllegalStateException(e);
        }
    }
22385
public void execute() throws MojoExecutionException, MojoFailureException {
        if (skip) {
            getLog().info("Not executing specifications.");
        } else {
            prepareReportsDir();
            prepareRunnerExecutors();
            printBanner();
            try {
                runAllTests();
            } finally {
                printFooter();
                for (TestResultsIndex testResultsIndex : testResultsIndexes.values()) {
                    testResultsIndex.dump();
                }
            }
            checkTestsResults();
        }
    }
70604
def checkout(repo, ref):
    """"""
    # Delete local branch if it exists, remote branch will be tracked
    # automatically. This prevents stale local branches from causing problems.
    # It also avoids problems with appending origin/ to refs as that doesn't
    # work with tags, SHAs, and upstreams not called origin.
    if ref in repo.branches:
        # eg delete master but leave origin/master
        log.warn("Removing local branch {b} for repo {r}".format(b=ref,
                                                                 r=repo))
        # Can't delete currently checked out branch, so make sure head is
        # detached before deleting.

        repo.head.reset(index=True, working_tree=True)
        repo.git.checkout(repo.head.commit.hexsha)
        repo.delete_head(ref, '--force')

    log.info("Checkout out repo {repo} to ref {ref}".format(repo=repo,
                                                            ref=ref))
    repo.head.reset(index=True, working_tree=True)
    repo.git.checkout(ref)
    repo.head.reset(index=True, working_tree=True)
    sha = repo.head.commit.hexsha
    log.info("Current SHA for repo {repo} is {sha}".format(repo=repo, sha=sha))
92140
def find_first_remote_branch(remotes, branch_name):
    """"""
    for remote in remotes:
        try:
            return remote.refs[branch_name]
        except IndexError:
            continue
        # END exception handling
    # END for remote
    raise InvalidGitRepositoryError("Didn't find remote branch '%r' in any of the given remotes" % branch_name)
1013605
protected void gitFetchRemoteAndCompare(final String branchName)
            throws MojoFailureException, CommandLineException {
        if (gitFetchRemote(branchName)) {
            getLog().info(
                    "Comparing local branch '" + branchName + "' with remote '"
                            + gitFlowConfig.getOrigin() + "/" + branchName
                            + "'.");
            String revlistout = executeGitCommandReturn("rev-list",
                    "--left-right", "--count", branchName + "..."
                            + gitFlowConfig.getOrigin() + "/" + branchName);

            String[] counts = org.apache.commons.lang3.StringUtils.split(
                    revlistout, '\t');
            if (counts != null && counts.length > 1) {
                if (!"0".equals(org.apache.commons.lang3.StringUtils
                        .deleteWhitespace(counts[1]))) {
                    throw new MojoFailureException("Remote branch '"
                            + gitFlowConfig.getOrigin() + "/" + branchName
                            + "' is ahead of the local branch '" + branchName
                            + "'. Execute git pull.");
                }
            }
        }
    }
1179929
protected void gitBranchDeleteForce(final String branchName)
            throws MojoFailureException, CommandLineException {
        getLog().info("Deleting (-D) '" + branchName + "' branch.");

        executeGitCommand("branch", "-D", branchName);
    }
470281
private void checkConfiguration()
            throws MojoExecutionException
    {
        checkDependencyFilenameStrategy();

        if ( CollectionUtils.isEmpty( jnlpFiles ) )
        {
            throw new MojoExecutionException(
                    "Configuration error: At least one <jnlpFile> element must be specified" );
        }

        if ( jnlpFiles.size() == 1 && StringUtils.isEmpty( jnlpFiles.get( 0 ).getOutputFilename() ) )
        {
            getLog().debug( "Jnlp output file name not specified in single set of jnlpFiles. " +
                                    "Using default output file name: launch.jnlp." );
            jnlpFiles.get( 0 ).setOutputFilename( "launch.jnlp" );
        }

        // ---
        // check Jnlp files configuration
        // ---

        Set<String> filenames = new LinkedHashSet<>( jnlpFiles.size() );

        for ( JnlpFile jnlpFile : jnlpFiles )
        {
            if ( !filenames.add( jnlpFile.getOutputFilename() ) )
            {
                throw new MojoExecutionException( "Configuration error: Unique JNLP filenames must be provided. " +
                                                          "The following file name appears more than once [" +
                                                          jnlpFile.getOutputFilename() + "]." );
            }

            checkJnlpFileConfiguration( jnlpFile );
        }

        if ( CollectionUtils.isNotEmpty( commonJarResources ) )
        {

            // ---
            // --- checkCommonJarResources();
            // ---

            for ( JarResource jarResource : commonJarResources )
            {
                checkMandatoryJarResourceFields( jarResource );

                if ( jarResource.getMainClass() != null )
                {
                    throw new MojoExecutionException( "Configuration Error: A mainClass must not be specified " +
                                                              "on a JarResource in the commonJarResources collection." );
                }
            }

            // ---
            // check for duplicate jar resources
            // Checks that any jarResources defined in the jnlpFile elements are not also defined in
            // commonJarResources.
            // ---

            for ( JnlpFile jnlpFile : jnlpFiles )
            {
                for ( JarResource jarResource : jnlpFile.getJarResources() )
                {
                    if ( commonJarResources.contains( jarResource ) )
                    {
                        String message = "Configuration Error: The jar resource element for artifact " + jarResource +
                                " defined in common jar resources is duplicated in the jar " +
                                "resources configuration of the jnlp file identified by the template file " +
                                jnlpFile.getInputTemplate() + ".";

                        throw new MojoExecutionException( message );
                    }
                }
            }
        }
    }
191107
def display_available_branches(self):
        """"""

        if not self.repo.remotes:
            remote_branches = False
        else:
            remote_branches = True
        branches = self.get_branches(local=True, remote_branches=remote_branches)

        if not branches:
            click.echo(crayons.red('No branches available'))
            return

        branch_col = len(max([b.name for b in branches], key=len)) + 1

        for branch in branches:

            try:
                branch_is_selected = (branch.name == self.get_current_branch_name())
            except TypeError:
                branch_is_selected = False

            marker = '*' if branch_is_selected else ' '
            color = colored.green if branch_is_selected else colored.yellow
            pub = '(published)' if branch.is_published else '(unpublished)'

            click.echo(columns(
                [colored.red(marker), 2],
                [color(branch.name, bold=True), branch_col],
                [black(pub), 14]
            ))
984873
public void execute()
        throws MojoExecutionException, MojoFailureException
    {
        if ( isSkipping() )
        {
            getLog().debug( "Skipping execution, as demanded by user." );
            return;
        }

        final ValidationErrorHandler errorHandler = new ValidationErrorHandler();
        if ( validationSets == null || validationSets.length == 0 )
        {
            throw new MojoFailureException( "No ValidationSets configured." );
        }
        checkCatalogHandling();

        Object oldProxySettings = activateProxy();
        try
        {
            Resolver resolver = getResolver();
            for ( int i = 0; i < validationSets.length; i++ )
            {
                ValidationSet validationSet = validationSets[i];
                resolver.setXincludeAware(validationSet.isValidating() );
                resolver.setValidating( validationSet.isValidating() );
                validate( resolver, validationSet ,errorHandler);
            }
            List<ValidationErrorHandler.ErrorRecord> errorRecords=errorHandler.getErrors();
            if (!errorRecords.isEmpty()){
                final StringBuffer message=new StringBuffer();
                for(ValidationErrorHandler.ErrorRecord error:errorRecords){
                    appendMessage(message,error);
                }
                if (errorHandler.getErrorCount()+errorHandler.getFatalCount()>0){
                    throw new MojoExecutionException( message.toString());
                }
                else{
                    getLog().warn(message.toString());
                }
            }
        }
        finally
        {
            passivateProxy( oldProxySettings );
        }
    }
1057413
def branch(self, branch):
        '''
        
        '''

        if not branch:
            branch = self.__mbranch
        tracking = (
            ''
            if branch in self._get_branch(remotes=True).get('out') else
            '-B'
        )
        self._checkout(treeish='%s %s' % (tracking, branch))