本文整理了Java中org.eclipse.jgit.api.Git.notesShow()
方法的一些代码示例,展示了Git.notesShow()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Git.notesShow()
方法的具体详情如下:
包路径:org.eclipse.jgit.api.Git
类名称:Git
方法名:notesShow
[英]Return a command to show notes on an object
[中]
代码示例来源:origin: org.apereo.cas/cas-mgmt-support-version-control
/**
* Returns the Note attached to the passed commit.
*
* @param com - RevObject of the commit.
* @return - Returns Note from the commit.
* @throws GitAPIException - failed.
*/
public Note note(final RevObject com) throws GitAPIException {
return git.notesShow()
.setObjectId(com)
.call();
}
代码示例来源:origin: io.fabric8/gitective-core
@Override
public CommitFilter setRepository(final Repository repository) {
super.setRepository(repository);
if (repository != null) {
show = Git.wrap(repository).notesShow();
noteRefs = getNoteRefs(repository);
} else {
show = null;
noteRefs = null;
}
return this;
}
代码示例来源:origin: io.fabric8/gitective-core
@Override
public CommitFilter setRepository(final Repository repository) {
super.setRepository(repository);
if (repository != null) {
show = Git.wrap(repository).notesShow();
noteRefs = getNoteRefs(repository);
} else {
show = null;
noteRefs = null;
}
return this;
}
代码示例来源:origin: org.walkmod/junit4git
protected String getNotes() throws IOException {
try (Git git = open()) {
fetchNotesRef(git);
RevWalk walk = new RevWalk(git.getRepository());
RevCommit commit = walk.parseCommit(getBaseObjectId(git));
Note note = git.notesShow().setNotesRef(GIT_NOTES_REF)
.setObjectId(commit).call();
if (note != null) {
log.debug(String.format("Git Notes found at %s for the commit %s", GIT_NOTES_REF,
commit.getName()));
return new String(git.getRepository().open(note.getData()).getCachedBytes(),
StandardCharsets.UTF_8);
} else {
log.debug(String.format("Ops! Git Notes are not found at %s for the commit %s", GIT_NOTES_REF,
commit.getName()));
return "";
}
} catch (GitAPIException e) {
log.error("Error reading Git notes", e);
throw new IOException("Error reading Git notes", e);
}
}
代码示例来源:origin: org.eclipse.egit/ui
/**
* Get notes for this commit.
*
* @return non-null but possibly empty array of {@link RepositoryCommitNote}
* instances.
*/
public RepositoryCommitNote[] getNotes() {
if (notes == null) {
List<RepositoryCommitNote> noteList = new ArrayList<RepositoryCommitNote>();
try {
Repository repo = getRepository();
Git git = Git.wrap(repo);
RevCommit revCommit = getRevCommit();
for (Ref ref : repo.getRefDatabase().getRefs(Constants.R_NOTES)
.values()) {
Note note = git.notesShow().setNotesRef(ref.getName())
.setObjectId(revCommit).call();
if (note != null)
noteList.add(new RepositoryCommitNote(this, ref, note));
}
notes = noteList.toArray(new RepositoryCommitNote[noteList
.size()]);
} catch (Exception e) {
Activator.logError("Error showing notes", e); //$NON-NLS-1$
notes = new RepositoryCommitNote[0];
}
}
return notes;
}
代码示例来源:origin: jenkinsci/git-client-plugin
/** {@inheritDoc} */
@Override
public void appendNote(String note, String namespace) throws GitException {
try (Repository repo = getRepository()) {
ObjectId head = repo.resolve(HEAD); // commit to put a note on
ShowNoteCommand cmd = git(repo).notesShow();
cmd.setNotesRef(qualifyNotesNamespace(namespace));
try (ObjectReader or = repo.newObjectReader();
RevWalk walk = new RevWalk(or)) {
cmd.setObjectId(walk.parseAny(head));
Note n = cmd.call();
if (n==null) {
addNote(note,namespace);
} else {
ObjectLoader ol = or.open(n.getData());
StringWriter sw = new StringWriter();
IOUtils.copy(new InputStreamReader(ol.openStream(),CHARSET),sw);
sw.write("\n");
addNote(sw.toString() + normalizeNote(note), namespace);
}
}
} catch (GitAPIException | IOException e) {
throw new GitException(e);
}
}
代码示例来源:origin: google/git-appraise-eclipse
/**
* Reads a single note out as a string from the given commit hash.
* Returns null if the note isn't found.
*/
private String readOneNote(Git git, String notesRef, String hash) throws GitClientException {
try (RevWalk walker = new RevWalk(git.getRepository())) {
ShowNoteCommand cmd = git.notesShow();
cmd.setNotesRef(notesRef);
ObjectId ref = git.getRepository().resolve(hash);
RevCommit commit = walker.parseCommit(ref);
cmd.setObjectId(commit);
Note note = cmd.call();
if (note == null) {
return null;
}
return noteToString(repo, note);
} catch (Exception e) {
throw new GitClientException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!