Executes git for-each-ref to get the last tag.

@return Last tag.
@throws MojoFailureException
@throws CommandLineException
193706
protected String gitFindLastTag() throws MojoFailureException, CommandLineException {
        String tag = executeGitCommandReturn("for-each-ref", "--sort=-*authordate", "--count=1",
                "--format=\"%(refname:short)\"", "refs/tags/");
        // https://github.com/aleksandr-m/gitflow-maven-plugin/issues/3
        tag = removeQuotes(tag);
        tag = tag.replaceAll("\\r?\\n", "");
        return tag;
    }
632986
public static function execute()
    {
        $release = null;

        // Get release-name from branch
        $input = \Deployer\input();
        if ($input->hasOption('branch')) {
            $branch = $input->getOption('branch');
            if (!empty($branch)) {
                $release = $branch;
            }
        }

        if ($release !== null) {
            return $release;
        }

        // Get release-name from tag
        $input = \Deployer\input();
        if ($input->hasOption('tag')) {
            $tag = $input->getOption('tag');
            if (!empty($tag)) {
                $release = $tag;
            }
        }

        if ($release !== null) {
            return $release;
        }

        $release = date('Ymdhis');

        return $release;
    }
807778
public function getLast()
    {
        $last = null;

        if (count($this->objects) > 0) {
            $last = end($this->objects);
        }

        return $last;
    }
786253
public void execute()
        throws MojoExecutionException, MojoFailureException
    {
        Collection<ResourceFile> files = getAllResourceFiles();
        for ( ResourceFile file : files )
        {
            File f = new File( file.basedir, file.fileRelativeName );
            File target = new File( outputDirectory, file.fileRelativeName );
            try
            {
                getLog().debug( "copy " + f + " to outputDirectory" );
                if ( !target.getParentFile().exists() )
                {
                    if ( !target.getParentFile().mkdirs() )
                    {
                        throw new MojoExecutionException( "Failed to create destination directory "
                            + target.getParentFile() );
                    }
                }
                FileUtils.copyFile( f, target );
            }
            catch ( IOException e )
            {
                throw new MojoExecutionException( "Failed to copy GWT source " + f, e );
            }
        }
    }
367033
public function last()
    {
        $last = null;
        foreach ($this->each() as $v) {
            $last = $v;
        }
        return $last;
    }
232389
private function getReleaseChangelog($lastVersionTag)
    {
        $filename = CLI_ROOT . '/release-changelog.md';
        if (file_exists($filename)) {
            $mTime = filemtime($filename);
            $lastVersionDate = $this->getTagDate($lastVersionTag);
            if (!$lastVersionDate || !$mTime || $mTime > $lastVersionDate) {
                $contents = file_get_contents($filename);
                if ($contents === false) {
                    throw new \RuntimeException('Failed to read file: ' . $filename);
                }
                $changelog = trim($contents);
            }
        }
        if (empty($changelog)) {
            $changelog = $this->getGitChangelog($lastVersionTag);
            (new Filesystem())->dumpFile($filename, $changelog);
        }

        return $changelog;
    }
888463
public function getLastLine(): string
  {
    if (empty($this->lines))
    {
      throw new \LogicException('No code in code store');
    }

    return $this->lines[count($this->lines) - 1];
  }
1201712
private String executeGitCommandReturn(final String... args)
            throws CommandLineException, MojoFailureException {
        return executeCommand(cmdGit, true, null, args).getOut();
    }
543518
public function getCurrentRemote()
    {
        /** @var $result CallResult */
        $result = $this->getGit()->{'remote'}($this->getRepositoryPath(), array(
             '-v'
        ));
        $result->assertSuccess(sprintf('Cannot remote "%s"', $this->getRepositoryPath()));

        $tmp = $result->getStdOut();

        preg_match_all('/([a-z]*)\h(.*)\h\((.*)\)/', $tmp, $matches);

        $retVar = array();
        foreach($matches[0] as $key => $value)
            $retVar[$matches[1][$key]][$matches[3][$key]] = $matches[2][$key];

        return $retVar;
    }
541073
private boolean executeGitHasUncommitted() throws MojoFailureException,
            CommandLineException {
        boolean uncommited = false;

        // 1 if there were differences and 0 means no differences

        // git diff --no-ext-diff --ignore-submodules --quiet --exit-code
        final CommandResult diffCommandResult = executeGitCommandExitCode(
                "diff", "--no-ext-diff", "--ignore-submodules", "--quiet",
                "--exit-code");

        String error = null;

        if (diffCommandResult.getExitCode() == SUCCESS_EXIT_CODE) {
            // git diff-index --cached --quiet --ignore-submodules HEAD --
            final CommandResult diffIndexCommandResult = executeGitCommandExitCode(
                    "diff-index", "--cached", "--quiet", "--ignore-submodules",
                    "HEAD", "--");
            if (diffIndexCommandResult.getExitCode() != SUCCESS_EXIT_CODE) {
                error = diffIndexCommandResult.getError();
                uncommited = true;
            }
        } else {
            error = diffCommandResult.getError();
            uncommited = true;
        }

        if (StringUtils.isNotBlank(error)) {
            throw new MojoFailureException(error);
        }

        return uncommited;
    }
1011577
public void execute() throws MojoFailureException, MojoExecutionException {
        // Validate
        validateArtifactInformation();

        Artifact artifact =
                artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, packaging, classifier );

        File existingFile = getLocalRepoFile(artifact);
        if (existingFile != null && existingFile.exists()) {
            System.out.println("Using cached remapped artifact "+ existingFile.getPath()); // delete file to reinstall
            return; // success
        }

        // Remap
        File outJar = null;
        try {
            // load input jar(s), as one combined jar (for jarmods)
            List<File> files = new ArrayList<File>();
            for (String filename : inJars) {
                files.add(FileLocator.getFile(filename));
            }
            Jar inJar = Jar.init(files);

            // temporary output file
            outJar = File.createTempFile(groupId + "." + artifactId + "-" + version, "." + packaging);

            // mappings
            JarMapping mapping = new JarMapping();
            if (excludedPackages != null) {
                for (String packageName : excludedPackages) {
                    mapping.addExcludedPackage(packageName);
                }
            }
            mapping.loadMappings(srgIn, reverse, numeric, inShadeRelocation, outShadeRelocation);
            mapping.setFallbackInheritanceProvider(new JarProvider(inJar));


            // access transformers
            RemapperProcessor preprocessor = null;
            if (accessTransformers != null) {
                AccessMap accessMap = new AccessMap();

                for (String filename : accessTransformers) {
                    if (filename != null && filename.length() != 0) {
                        accessMap.loadAccessTransformer(filename);
                    }
                }

                preprocessor = new RemapperProcessor(null, null, accessMap);
            }

            // Do the remap
            JarRemapper remapper = new JarRemapper(preprocessor, mapping);
            remapper.setGenerateAPI(generateAPI);
            remapper.remapJar(inJar, outJar);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MojoExecutionException("Error creating remapped jar at "+outJar+": " + ex.getMessage(), ex);
        }

        // Replace main artifact with this remapped artifact
        if (replaceMainArtifact) {
            getLog().info("Replacing original artifact with remapped artifact.");
            File originalArtifact = project.getArtifact().getFile();
            originalArtifact.delete();
            if (!outJar.renameTo(originalArtifact)) {
                throw new MojoExecutionException("Error replacing remapped jar at "+originalArtifact+" with "+outJar);
            }
        }

        // Attach output artifact to this project
        if (attachArtifact) {
            if (attachArtifactClassifier == null || attachArtifactClassifier.equals("")) {
                attachArtifactClassifier = null;
            }

            getLog().info("Attaching artifact " + outJar.getPath());
            projectHelper.attachArtifact(project, attachArtifactType, attachArtifactClassifier, outJar);
        }

        // Install output artifact to local repository
        if (installArtifact) {
            installArtifact(artifact, outJar);
        }
    }
650576
public function last()
    {
        $this->executeBeforeCallback();

        return count($this->items) > 0 ? end($this->items) : null;
    }
628673
public Command undoLast() {
        Command lastCommand = undoStack.pop();
        redoStack.push(lastCommand);
        lastCommand.undo();
        return lastCommand;
    }
438423
protected void gitTag(final String tagName, String message, boolean gpgSignTag, Map<String, String> messageProperties)
            throws MojoFailureException, CommandLineException {
        message = replaceProperties(message, messageProperties);

        if (gpgSignTag) {
            getLog().info("Creating GPG-signed '" + tagName + "' tag.");

            executeGitCommand("tag", "-a", "-s", tagName, "-m", message);
        } else {
            getLog().info("Creating '" + tagName + "' tag.");

            executeGitCommand("tag", "-a", tagName, "-m", message);
        }
    }
438632
private List<String> extractTagsAndResetLastTagsLineField() {
        String tags = lastTagsLine;
        List<String> result = extractTags(tags);
        resetLastTagsLine();
        return result;
    }
327889
public function getLastCommit($ref = 'master')
    {
        if ($this->isRoot()) {
            return $this->getRepository()->getCommit($ref);
        }
        $log = $this->repository->getObjectLog($this->getObject(), $ref);

        return $log[0];
    }
391021
public function make()
    {
        if ($this->closeMode === self::CLOSE_ONLY)
            return '</' . $this->tag . '>';

        $join = function($tag, $last = null) {
            if ($last)
                $tag[] = $last;
            return join('', $tag);
        };

        $tag = [];
        $tag[] = '<' . $this->tag;

        foreach ($this->attributes as $name => $values)
        {
            if ($values === [null])
                continue;

            $tag[] = ' ' . $this->makeAttribute($name, $values);
        }

        if ($this->closeMode === self::SELF_CLOSE)
            return $join($tag, ' />');
        else
            $tag[] = '>';

        if ($this->closeMode === self::DONT_CLOSE)
            return $join($tag);

        foreach ($this->contents as $content)
        {
            if ($content instanceof Tag)
                $tag[] = $content->make();
            else
                $tag[] = $content;
        }

        return $join($tag, '</' . $this->tag . '>');
    }