Search in sources :

Example 16 with PersonIdent

use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.

the class AccountsUpdate method createInitialEmptyCommit.

private static ObjectId createInitialEmptyCommit(ObjectInserter oi, PersonIdent committerIdent, PersonIdent authorIdent, Timestamp registrationDate) throws IOException {
    CommitBuilder cb = new CommitBuilder();
    cb.setTreeId(emptyTree(oi));
    cb.setCommitter(new PersonIdent(committerIdent, registrationDate));
    cb.setAuthor(new PersonIdent(authorIdent, registrationDate));
    cb.setMessage("Create Account");
    ObjectId id = oi.insert(cb);
    oi.flush();
    return id;
}
Also used : PersonIdent(org.eclipse.jgit.lib.PersonIdent) GerritPersonIdent(com.google.gerrit.server.GerritPersonIdent) ObjectId(org.eclipse.jgit.lib.ObjectId) CommitBuilder(org.eclipse.jgit.lib.CommitBuilder)

Example 17 with PersonIdent

use of org.eclipse.jgit.lib.PersonIdent in project fabric8 by jboss-fuse.

the class FabricGitFacade method write.

@Override
public CommitInfo write(final String branch, final String path, final String commitMessage, final String authorName, final String authorEmail, final String contents) {
    assertValid();
    final PersonIdent personIdent = new PersonIdent(authorName, authorEmail);
    return gitWriteOperation(personIdent, new GitOperation<CommitInfo>() {

        public CommitInfo call(Git git, GitContext context) throws Exception {
            checkoutBranch(git, branch);
            File rootDir = getRootGitDirectory(git);
            byte[] data = contents.getBytes();
            CommitInfo answer = doWrite(git, rootDir, branch, path, data, personIdent, commitMessage);
            context.commitMessage(commitMessage);
            return answer;
        }
    });
}
Also used : Git(org.eclipse.jgit.api.Git) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GitContext(io.fabric8.api.GitContext) File(java.io.File) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException)

Example 18 with PersonIdent

use of org.eclipse.jgit.lib.PersonIdent in project fabric8 by jboss-fuse.

the class FabricGitFacade method revertTo.

@Override
public void revertTo(final String branch, final String objectId, final String blobPath, final String commitMessage, final String authorName, final String authorEmail) {
    assertValid();
    final PersonIdent personIdent = new PersonIdent(authorName, authorEmail);
    gitWriteOperation(personIdent, new GitOperation<Void>() {

        public Void call(Git git, GitContext context) throws Exception {
            checkoutBranch(git, branch);
            File rootDir = getRootGitDirectory(git);
            Void answer = doRevert(git, rootDir, branch, objectId, blobPath, commitMessage, personIdent);
            context.commitMessage(commitMessage);
            return answer;
        }
    });
}
Also used : Git(org.eclipse.jgit.api.Git) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GitContext(io.fabric8.api.GitContext) File(java.io.File) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException)

Example 19 with PersonIdent

use of org.eclipse.jgit.lib.PersonIdent in project fabric8 by jboss-fuse.

the class FabricGitFacade method writeBase64.

@Override
public CommitInfo writeBase64(final String branch, final String path, final String commitMessage, final String authorName, final String authorEmail, final String contents) {
    assertValid();
    final PersonIdent personIdent = new PersonIdent(authorName, authorEmail);
    return gitWriteOperation(personIdent, new GitOperation<CommitInfo>() {

        public CommitInfo call(Git git, GitContext context) throws Exception {
            checkoutBranch(git, branch);
            File rootDir = getRootGitDirectory(git);
            byte[] data = Base64.decode(contents);
            CommitInfo answer = doWrite(git, rootDir, branch, path, data, personIdent, commitMessage);
            context.commitMessage(commitMessage);
            return answer;
        }
    });
}
Also used : Git(org.eclipse.jgit.api.Git) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GitContext(io.fabric8.api.GitContext) File(java.io.File) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException)

Example 20 with PersonIdent

use of org.eclipse.jgit.lib.PersonIdent in project archi-modelrepository-plugin by archi-contribs.

the class CommitDialog method storeUserDetails.

/*
     * Store user name and email
     * If these are the same as those in .gitconfig don't store
     */
private void storeUserDetails(String name, String email) throws IOException, ConfigInvalidException {
    PersonIdent global = GraficoUtils.getGitConfigUserDetails();
    String globalName = global.getName();
    String globalEmail = global.getEmailAddress();
    if (!globalName.equals(name) || !globalEmail.equals(email)) {
        fRepository.saveUserDetails(name, email);
    }
}
Also used : PersonIdent(org.eclipse.jgit.lib.PersonIdent)

Aggregations

PersonIdent (org.eclipse.jgit.lib.PersonIdent)221 RevCommit (org.eclipse.jgit.revwalk.RevCommit)78 ObjectId (org.eclipse.jgit.lib.ObjectId)55 Test (org.junit.Test)55 Repository (org.eclipse.jgit.lib.Repository)48 IOException (java.io.IOException)41 CommitBuilder (org.eclipse.jgit.lib.CommitBuilder)41 RevWalk (org.eclipse.jgit.revwalk.RevWalk)38 ObjectInserter (org.eclipse.jgit.lib.ObjectInserter)31 Change (com.google.gerrit.entities.Change)28 GerritPersonIdent (com.google.gerrit.server.GerritPersonIdent)26 Ref (org.eclipse.jgit.lib.Ref)26 Git (org.eclipse.jgit.api.Git)25 Account (com.google.gerrit.entities.Account)22 Instant (java.time.Instant)21 TestRepository (org.eclipse.jgit.junit.TestRepository)20 ArrayList (java.util.ArrayList)18 File (java.io.File)17 Date (java.util.Date)17 RefUpdate (org.eclipse.jgit.lib.RefUpdate)17