当前位置: 首页>>代码示例>>Java>>正文


Java PersonIdent类代码示例

本文整理汇总了Java中org.eclipse.jgit.lib.PersonIdent的典型用法代码示例。如果您正苦于以下问题:Java PersonIdent类的具体用法?Java PersonIdent怎么用?Java PersonIdent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PersonIdent类属于org.eclipse.jgit.lib包,在下文中一共展示了PersonIdent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toCommit

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
private static Commit toCommit(RevCommit revCommit) {
    final Author author;
    final PersonIdent committerIdent = revCommit.getCommitterIdent();
    if (committerIdent == null) {
        author = Author.UNKNOWN;
    } else {
        author = new Author(committerIdent.getName(), committerIdent.getEmailAddress());
    }
    long when = committerIdent.getWhen().getTime();

    try {
        return CommitUtil.newCommit(author, when, revCommit.getFullMessage());
    } catch (Exception e) {
        throw new StorageException("failed to create a Commit", e);
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:17,代码来源:GitRepository.java

示例2: parsePersonIdent

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
/**
 * Parse the raw user information into PersonIdent object, the raw information
 * should be in format <code>[name] [<email>] [epoch timezone]</code>, for 
 * example:
 * 
 * Jacob Thornton <[email protected]> 1328060294 -0800
 * 
 * @param raw
 * @return
 */
public static @Nullable PersonIdent parsePersonIdent(String raw) {
	if (Strings.isNullOrEmpty(raw))
		return null;
	
	int pos1 = raw.indexOf('<');
	if (pos1 <= 0)
		throw new IllegalArgumentException("Raw " + raw);
	
	String name = raw.substring(0, pos1 - 1);
	
	int pos2 = raw.indexOf('>');
	if (pos2 <= 0)
		throw new IllegalArgumentException("Raw " + raw);
	
	String time = raw.substring(pos2 + 1).trim();
	Date when = parseRawDate(time);
	
	String email = raw.substring(pos1 + 1, pos2 - 1);
	
	return newPersonIdent(name, email, when);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:32,代码来源:GitUtils.java

示例3: build

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
public LogCommit build() {
	PersonIdent committer;
	if (StringUtils.isNotBlank(committerName) && StringUtils.isNotBlank(committerEmail) 
			&& committerDate != null) {
		committer = GitUtils.newPersonIdent(committerName, committerEmail, committerDate);
	} else {
		committer = null;
	}

	PersonIdent author;
	if (StringUtils.isNotBlank(authorName) && StringUtils.isNotBlank(authorEmail) 
			&& authorDate != null) {
		author = GitUtils.newPersonIdent(authorName, authorEmail, authorDate);
	} else {
		author = null;
	}
	
	return new LogCommit(hash, committer, author, parentHashes, changedFiles);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:20,代码来源:LogCommit.java

示例4: commit

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
/**
 * 
 * @param commitBuilder
 * @param treeId
 * @param repo
 * @return
 * @throws UnsupportedEncodingException
 * @throws IOException 
 */
public static ObjectId commit(CommitBuilder commitBuilder, ObjectId treeId, Repository repo) throws UnsupportedEncodingException, IOException {
    commitBuilder.setTreeId(treeId);
    commitBuilder.setMessage(System.currentTimeMillis() + ": My commit!\n");
    PersonIdent person = new PersonIdent("Alex", "[email protected]");
    commitBuilder.setAuthor(person);
    commitBuilder.setCommitter(person);

    commitBuilder.build();

    ObjectInserter commitInserter = repo.newObjectInserter();
    ObjectId commitId = commitInserter.insert(commitBuilder);
    commitInserter.flush();

    updateMasterRecord(repo, commitId);

    System.out.println("Commit Object ID: " + commitId.getName());

    return commitId;
}
 
开发者ID:alexmy21,项目名称:gmds,代码行数:29,代码来源:Commands.java

示例5: getAuthorName

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
@Override
public String getAuthorName( String commitId ) {
  if ( commitId.equals( IVCS.WORKINGTREE ) ) {
    Config config = git.getRepository().getConfig();
    return config.get( UserConfig.KEY ).getAuthorName()
        + " <" + config.get( UserConfig.KEY ).getAuthorEmail() + ">";
  } else {
    RevCommit commit = resolve( commitId );
    PersonIdent author = commit.getAuthorIdent();
    final StringBuilder r = new StringBuilder();
    r.append( author.getName() );
    r.append( " <" ); //$NON-NLS-1$
    r.append( author.getEmailAddress() );
    r.append( ">" ); //$NON-NLS-1$
    return r.toString();
  }
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:18,代码来源:UIGit.java

示例6: testCommit

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
@Test
public void testCommit() throws Exception {
  assertFalse( uiGit.hasStagedFiles() );

  writeTrashFile( "Test.txt", "Hello world" );
  uiGit.add( "Test.txt" );
  PersonIdent author = new PersonIdent( "author", "[email protected]" );
  String message = "Initial commit";

  assertTrue( uiGit.hasStagedFiles() );

  uiGit.commit( author.toExternalString(), message );
  String commitId = uiGit.getCommitId( Constants.HEAD );

  assertTrue( uiGit.isClean() );
  assertTrue( author.toExternalString().contains( uiGit.getAuthorName( commitId ) ) );
  assertEquals( message, uiGit.getCommitMessage( commitId ) );
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:19,代码来源:UIGitTest.java

示例7: createCommitInfo

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
public CommitInfo createCommitInfo(RevCommit entry) {
    final Date date = GitUtils.getCommitDate(entry);
    PersonIdent authorIdent = entry.getAuthorIdent();
    String author = null;
    String name = null;
    String email = null;
    String avatarUrl = null;
    if (authorIdent != null) {
        author = authorIdent.getName();
        name = authorIdent.getName();
        email = authorIdent.getEmailAddress();

        // lets try default the avatar
        if (Strings.isNotBlank(email)) {
            avatarUrl = getAvatarUrl(email);
        }
    }
    boolean merge = entry.getParentCount() > 1;
    String shortMessage = entry.getShortMessage();
    String sha = entry.getName();
    return new CommitInfo(sha, author, name, email, avatarUrl, date, merge, shortMessage);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:23,代码来源:RepositoryResource.java

示例8: getAuthors

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
/**
 * Gets a set of authors for a path in a given repository
 * @param repo The git repository
 * @param path The path to get commits for
 * @return An iterable of commits
 * @throws GitAPIException Any API errors which may occur
 * @throws URISyntaxException Error constructing mailto link
 */
public Set<HashableAgent> getAuthors(Git repo, String path) throws GitAPIException, URISyntaxException {
    Iterable<RevCommit> logs = repo.log().addPath(path).call();
    Set<HashableAgent> fileAuthors = new HashSet<>();
    for (RevCommit rev : logs) {
        // Use author first with backup of committer
        PersonIdent author = rev.getAuthorIdent();
        if (author == null) {
            author = rev.getCommitterIdent();
        }
        // Create a new agent and add as much detail as possible
        if (author != null) {
            HashableAgent newAgent = new HashableAgent();
            String name = author.getName();
            if (name != null && name.length() > 0) {
                newAgent.setName(author.getName());
            }
            String email = author.getEmailAddress();
            if (email != null && email.length() > 0) {
                newAgent.setUri(new URI("mailto:" + author.getEmailAddress()));
            }
            fileAuthors.add(newAgent);
        }
    }
    return fileAuthors;
}
 
开发者ID:common-workflow-language,项目名称:cwlviewer,代码行数:34,代码来源:GitService.java

示例9: create

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
public static AppRepo create(String name, File originDir) {
    try {
        InitCommand initCommand = Git.init();
        initCommand.setDirectory(originDir);
        Git origin = initCommand.call();

        origin.add().addFilepattern(".").call();
        origin.commit().setMessage("Initial commit")
            .setAuthor(new PersonIdent("Author Test", "[email protected]"))
            .call();

        return new AppRepo(name, originDir, origin);
    } catch (Exception e) {
        throw new RuntimeException("Error while creating git repo", e);
    }
}
 
开发者ID:danielflower,项目名称:app-runner-router,代码行数:17,代码来源:AppRepo.java

示例10: pushingAnEmptyRepoIsRejected

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
@Test
public void pushingAnEmptyRepoIsRejected() throws Exception {
    File dir = Photocopier.folderForSampleProject("empty-project");
    InitCommand initCommand = Git.init();
    initCommand.setDirectory(dir);
    Git origin = initCommand.call();

    ContentResponse resp = restClient.createApp(dir.toURI().toString(), "empty-project");
    assertThat(resp, equalTo(501, containsString("No suitable runner found for this app")));

    Photocopier.copySampleAppToDir("maven", dir);
    origin.add().addFilepattern(".").call();
    origin.commit().setMessage("Initial commit")
        .setAuthor(new PersonIdent("Author Test", "[email protected]"))
        .call();

    resp = restClient.createApp(dir.toURI().toString(), "empty-project");
    assertThat(resp, equalTo(201, containsString("empty-project")));
    assertThat(new JSONObject(resp.getContentAsString()).get("name"), Matchers.equalTo("empty-project"));
    assertThat(restClient.deleteApp("empty-project"), equalTo(200, containsString("{")));
}
 
开发者ID:danielflower,项目名称:app-runner,代码行数:22,代码来源:SystemTest.java

示例11: returnsCurrentCommitForNonEmptyRepos

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
@Test
public void returnsCurrentCommitForNonEmptyRepos() throws Exception {
    Git git = emptyRepo();
    FileRepository repository = (FileRepository) git.getRepository();
    File dir = repository.getDirectory();
    FileUtils.writeStringToFile(new File(dir, "file1"), "Hello", "UTF-8");
    git.add().addFilepattern(".").call();
    git.commit().setMessage("Initial commit")
        .setAuthor(new PersonIdent("Author Test", "[email protected]"))
        .call();

    FileUtils.writeStringToFile(new File(dir, "file2"), "Hello too", "UTF-8");
    git.add().addFilepattern(".").call();
    git.commit().setMessage("Second commit")
        .setAuthor(new PersonIdent("Second contributor", "[email protected]"))
        .call();

    JSONObject actual = GitCommit.fromHEAD(git).toJSON();
    JSONAssert.assertEquals("{" +
        "author: 'Second contributor', message: 'Second commit'" +
        "}", actual, JSONCompareMode.LENIENT);

    assertThat(actual.getLong("date"), Matchers.greaterThanOrEqualTo(System.currentTimeMillis() - 1000));
    assertThat(actual.getString("id"), actual.getString("id").length(), is("3688d7063d2d647e3989d62d9770d0dfd0ce3c25".length()));

}
 
开发者ID:danielflower,项目名称:app-runner,代码行数:27,代码来源:GitCommitTest.java

示例12: create

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
public static AppRepo create(String name) {
    try {
        File originDir = copySampleAppToTempDir(name);

        InitCommand initCommand = Git.init();
        initCommand.setDirectory(originDir);
        Git origin = initCommand.call();

        origin.add().addFilepattern(".").call();
        origin.commit().setMessage("Initial commit")
            .setAuthor(new PersonIdent("Author Test", "[email protected]"))
            .call();

        return new AppRepo(name, originDir, origin);
    } catch (Exception e) {
        throw new RuntimeException("Error while creating git repo", e);
    }
}
 
开发者ID:danielflower,项目名称:app-runner,代码行数:19,代码来源:AppRepo.java

示例13: getCommitInfo

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
/**
 * Does not fetch.
 */
public CommitInfo getCommitInfo(String path) throws Exception {
    Iterator<RevCommit> revCommits = git.log().addPath(path).setMaxCount(1).call().iterator();
    if (revCommits.hasNext()) {
        RevCommit revCommit = revCommits.next();
        CommitInfo commitInfo = new CommitInfo(revCommit.getId().name());
        PersonIdent committerIdent = revCommit.getCommitterIdent();
        commitInfo.setCommitter(committerIdent.getName());
        commitInfo.setEmail(committerIdent.getEmailAddress());
        if ((commitInfo.getCommitter() == null || commitInfo.getCommitter().isEmpty()) && commitInfo.getEmail() != null)
            commitInfo.setCommitter(commitInfo.getEmail());
        commitInfo.setDate(committerIdent.getWhen());
        commitInfo.setMessage(revCommit.getShortMessage());
        return commitInfo;
    }
    return null;
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:20,代码来源:VersionControlGit.java

示例14: AbstractChangeUpdate

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
protected AbstractChangeUpdate(
    Config cfg,
    NotesMigration migration,
    ChangeNotes notes,
    CurrentUser user,
    PersonIdent serverIdent,
    String anonymousCowardName,
    ChangeNoteUtil noteUtil,
    Date when) {
  this.migration = migration;
  this.noteUtil = noteUtil;
  this.serverIdent = new PersonIdent(serverIdent, when);
  this.anonymousCowardName = anonymousCowardName;
  this.notes = notes;
  this.change = notes.getChange();
  this.accountId = accountId(user);
  Account.Id realAccountId = accountId(user.getRealUser());
  this.realAccountId = realAccountId != null ? realAccountId : accountId;
  this.authorIdent = ident(noteUtil, serverIdent, anonymousCowardName, user, when);
  this.when = when;
  this.readOnlySkewMs = NoteDbChangeState.getReadOnlySkew(cfg);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:AbstractChangeUpdate.java

示例15: addNoteDbCommit

import org.eclipse.jgit.lib.PersonIdent; //导入依赖的package包/类
private void addNoteDbCommit(Change.Id id, String commitMessage) throws Exception {
  if (!notesMigration.commitChangeWrites()) {
    return;
  }
  PersonIdent committer = serverIdent.get();
  PersonIdent author =
      noteUtil.newIdent(
          accountCache.get(admin.getId()).getAccount(),
          committer.getWhen(),
          committer,
          anonymousCowardName);
  testRepo
      .branch(RefNames.changeMetaRef(id))
      .commit()
      .author(author)
      .committer(committer)
      .message(commitMessage)
      .create();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:ConsistencyCheckerIT.java


注:本文中的org.eclipse.jgit.lib.PersonIdent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。