Example usage for org.eclipse.jgit.api CommitCommand setReflogComment

List of usage examples for org.eclipse.jgit.api CommitCommand setReflogComment

Introduction

In this page you can find the example usage for org.eclipse.jgit.api CommitCommand setReflogComment.

Prototype

public CommitCommand setReflogComment(String reflogComment) 

Source Link

Document

Override the message written to the reflog

Usage

From source file:com.rimerosolutions.ant.git.tasks.CommitTask.java

License:Apache License

@Override
protected void doExecute() throws BuildException {
    try {//ww  w .  j av a 2 s .  c  o m
        setFailOnError(true);
        CommitCommand cmd = git.commit();

        if (!GitTaskUtils.isNullOrBlankString(message)) {
            cmd.setMessage(brandedMessage ? GitTaskUtils.BRANDING_MESSAGE + " " : "" + message);
        } else {
            cmd.setMessage(GitTaskUtils.BRANDING_MESSAGE);
        }

        String prefix = getDirectory().getCanonicalPath();
        String[] allFiles = getPath().list();

        if (!GitTaskUtils.isNullOrBlankString(only)) {
            cmd.setOnly(only);
        } else if (allFiles.length > 0) {
            for (String file : allFiles) {
                String modifiedFile = translateFilePathUsingPrefix(file, prefix);
                log("Will commit " + modifiedFile);
                cmd.setOnly(modifiedFile);
            }
        } else {
            cmd.setAll(true);
        }

        GitSettings gitSettings = lookupSettings();

        if (gitSettings == null) {
            throw new MissingRequiredGitSettingsException();
        }

        cmd.setAmend(amend).setAuthor(gitSettings.getIdentity()).setCommitter(gitSettings.getIdentity());

        if (reflogComment != null) {
            cmd.setReflogComment(reflogComment);
        }

        RevCommit revCommit = cmd.call();

        if (revCommitIdProperty != null) {
            String revisionId = ObjectId.toString(revCommit.getId());
            getProject().setProperty(revCommitIdProperty, revisionId);
        }

        log(revCommit.getFullMessage());
    } catch (IOException ioe) {
        throw new GitBuildException(MESSAGE_COMMIT_FAILED, ioe);
    } catch (GitAPIException ex) {
        throw new GitBuildException(MESSAGE_COMMIT_FAILED, ex);
    }
}