List getCommitDiff()

in src/main/groovy/com/epam/esp/vcs/git/GitHelper.groovy [60:91]


    List<Commit> getCommitDiff(project, srcBranch, destBranch) {
        OS os = OS.getOs()
        List<String> params = ['git', 'log', '--pretty=format:"[%cD]-[%H]-@[%an]-%s"', "${srcBranch}..${destBranch}".toString()].asList()
        List<String> processOut = new ArrayList<String>()
        def result = os.execCommandLine(params, processOut, config.getPath(project), 600)
        def commitList = new ArrayList<Commit>()
        if (result == 0) {
            if (logger.isInfoEnabled()) {
                logger.info("Processing result. ${processOut.size()} lines to process.")
            }
            processOut.each {
                Matcher matcher = it =~ COMMIT_PATTERN
                if (matcher.matches()) {
                    def commit = new Commit()
                    commit.date = matcher.group(1)
                    commit.hash = matcher.group(2)
                    commit.author = matcher.group(3)
                    commit.comment = matcher.group(4)
                    commit.files = getCommitInfo(project, commit.hash)
                    if (commit.files.size() != 0) {
                        commitList.add(commit)
                    }
                } else {
                    logger.error("${it} doesn't match ${COMMIT_PATTERN}")
                }
            }
        } else {
            def output = processOut.join('\n')
            throw new GitException("Unable to execute git command:\n${output}")
        }
        return commitList
    }