• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Note类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getRevisionGitNotes

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
/**
 * Storing revisions in Git Notes causes object hash computation, which is expensive.
 */
public AssetRevision getRevisionGitNotes(File file) throws IOException {
    AssetRevision rev = file2rev.get(file);
    if (rev == null) {
        ObjectId workingId = getObjectId(file);

        try (RevWalk walk = new RevWalk(localRepo)) {
            Ref ref = localRepo.findRef(NOTES_REF);
            if (ref != null) {
                RevCommit notesCommit = walk.parseCommit(ref.getObjectId());
                NoteMap notes = NoteMap.read(walk.getObjectReader(), notesCommit);
                Note note = notes.getNote(workingId);
                if (note != null) {
                    ObjectLoader loader = localRepo.open(note.getData());
                    String noteStr = new String(loader.getBytes()).trim();
                    rev = parseAssetRevision(noteStr);
                    file2rev.put(file, rev);
                    return rev;
                }
            }
        }
    }

    return rev;
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:28,代码来源:VersionControlGit.java


示例2: listReviews

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
/**
 * Retrieves all the reviews in the current project's repository by commit hash.
 */
public Map<String, Review> listReviews() throws GitClientException {
  // Get the most up-to-date list of reviews.
  syncCommentsAndReviews();

  Map<String, Review> reviews = new LinkedHashMap<>();

  Git git = new Git(repo);
  try {
    ListNotesCommand cmd = git.notesList();
    cmd.setNotesRef(REVIEWS_REF);
    List<Note> notes = cmd.call();
    for (Note note : notes) {
      String rawNoteDataStr = noteToString(repo, note);
      Review latest = extractLatestReviewFromNotes(rawNoteDataStr);
      if (latest != null) {
        reviews.put(note.getName(), latest);
      }
    }
  } catch (Exception e) {
    throw new GitClientException(e);
  } finally {
    git.close();
  }
  return reviews;
}
 
开发者ID:google,项目名称:git-appraise-eclipse,代码行数:29,代码来源:AppraiseGitReviewClient.java


示例3: readOneNote

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:google,项目名称:git-appraise-eclipse,代码行数:21,代码来源:AppraiseGitReviewClient.java


示例4: merge

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
@Override
public Note merge(Note base, Note ours, Note theirs, ObjectReader reader, ObjectInserter inserter)
    throws IOException {
  if (ours == null) {
    return theirs;
  }
  if (theirs == null) {
    return ours;
  }
  if (ours.getData().equals(theirs.getData())) {
    return ours;
  }

  ObjectLoader lo = reader.open(ours.getData());
  byte[] sep = new byte[] {'\n'};
  ObjectLoader lt = reader.open(theirs.getData());
  try (ObjectStream os = lo.openStream();
      ByteArrayInputStream b = new ByteArrayInputStream(sep);
      ObjectStream ts = lt.openStream();
      UnionInputStream union = new UnionInputStream(os, b, ts)) {
    ObjectId noteData =
        inserter.insert(Constants.OBJ_BLOB, lo.getSize() + sep.length + lt.getSize(), union);
    return new Note(ours, noteData);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:ReviewNoteMerger.java


示例5: parse

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
static RevisionNoteMap<ChangeRevisionNote> parse(
    ChangeNoteUtil noteUtil,
    Change.Id changeId,
    ObjectReader reader,
    NoteMap noteMap,
    PatchLineComment.Status status)
    throws ConfigInvalidException, IOException {
  Map<RevId, ChangeRevisionNote> result = new HashMap<>();
  for (Note note : noteMap) {
    ChangeRevisionNote rn =
        new ChangeRevisionNote(noteUtil, changeId, reader, note.getData(), status);
    rn.parse();
    result.put(new RevId(note.name()), rn);
  }
  return new RevisionNoteMap<>(noteMap, ImmutableMap.copyOf(result));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:RevisionNoteMap.java


示例6: all

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
/** Reads and returns all external IDs. */
private Set<ExternalId> all(Repository repo, ObjectId rev) throws IOException {
  if (rev.equals(ObjectId.zeroId())) {
    return ImmutableSet.of();
  }

  try (Timer0.Context ctx = readAllLatency.start();
      RevWalk rw = new RevWalk(repo)) {
    NoteMap noteMap = readNoteMap(rw, rev);
    Set<ExternalId> extIds = new HashSet<>();
    for (Note note : noteMap) {
      byte[] raw =
          rw.getObjectReader().open(note.getData(), OBJ_BLOB).getCachedBytes(MAX_NOTE_SZ);
      try {
        extIds.add(ExternalId.parse(note.getName(), raw, note.getData()));
      } catch (Exception e) {
        log.error(String.format("Ignoring invalid external ID note %s", note.getName()), e);
      }
    }
    return extIds;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:ExternalIdReader.java


示例7: getBugIds

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
/**
 * Parse the git note containing SDR numbers associated with the note.
 *
 * @param  note   Git note
 * @return List of bug IDs, or null if none found
 */
private List<String> getBugIds(Note note) {
    List<String> bugs = new ArrayList<String>();

    ObjectId noteObj = note.getData();
    String noteId = noteObj.getName();
    String noteText = noteObj.toString();
    if (noteText != null) {
        // Parse the delimited list of bug IDs from the note data
        noteText = noteText.trim();
        StringTokenizer st = new StringTokenizer(noteText);
        while (st.hasMoreTokens()) {
            bugs.add(st.nextToken());
        }
    }

    return bugs;
}
 
开发者ID:ModelN,项目名称:build-management,代码行数:24,代码来源:CMnGitServer.java


示例8: appendNote

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
/** {@inheritDoc} */
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);
    }
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:27,代码来源:JGitAPIImpl.java


示例9: getNote

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
/**  커밋에 붙어있는 GIT 노트를 가져옴
 * @param commit
 * @return
 */
public String getNote(String commit){
	String str = new String();
	try{
		Note note = git.notesShow().setObjectId(CommitUtils.getCommit(git.getRepository(), commit)).call();
		ObjectLoader loader = this.localRepo.open(note.getData());
		str = new String(loader.getBytes());
	}finally{
		return str;
	}
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:15,代码来源:GitUtil.java


示例10: noteToString

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
/**
 * Utility method that converts a note to a string (assuming it's UTF-8).
 */
private String noteToString(Repository repo, Note note)
    throws MissingObjectException, IOException, UnsupportedEncodingException {
  ObjectLoader loader = repo.open(note.getData());
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  loader.copyTo(baos);
  return new String(baos.toByteArray(), "UTF-8");
}
 
开发者ID:google,项目名称:git-appraise-eclipse,代码行数:11,代码来源:AppraiseGitReviewClient.java


示例11: add

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
private void add(T noteRecord)
    throws MissingObjectException, IncorrectObjectTypeException, IOException, RuntimeException {
  ObjectId noteContent = createNoteContent(noteRecord);
  if (ours.contains(reviewCommit)) {
    // merge the existing and the new note as if they are both new
    // means: base == null
    // there is not really a common ancestry for these two note revisions
    // use the same NoteMerger that is used from the NoteMapMerger
    NoteMerger noteMerger = new DefaultNoteMerger();
    Note newNote = new Note(reviewCommit, noteContent);
    noteContent =
        noteMerger.merge(null, newNote, ours.getNote(reviewCommit), reader, inserter).getData();
  }
  ours.set(reviewCommit, noteContent);
}
 
开发者ID:google,项目名称:git-appraise-eclipse,代码行数:16,代码来源:GitNoteWriter.java


示例12: get

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
private List<PGPPublicKeyRing> get(long keyId, byte[] fp) throws IOException {
  if (reader == null) {
    load();
  }
  if (notes == null) {
    return Collections.emptyList();
  }
  Note note = notes.getNote(keyObjectId(keyId));
  if (note == null) {
    return Collections.emptyList();
  }

  List<PGPPublicKeyRing> keys = new ArrayList<>();
  try (InputStream in = reader.open(note.getData(), OBJ_BLOB).openStream()) {
    while (true) {
      @SuppressWarnings("unchecked")
      Iterator<Object> it = new BcPGPObjectFactory(new ArmoredInputStream(in)).iterator();
      if (!it.hasNext()) {
        break;
      }
      Object obj = it.next();
      if (obj instanceof PGPPublicKeyRing) {
        PGPPublicKeyRing kr = (PGPPublicKeyRing) obj;
        if (fp == null || Arrays.equals(fp, kr.getPublicKey().getFingerprint())) {
          keys.add(kr);
        }
      }
      checkState(!it.hasNext(), "expected one PGP object per ArmoredInputStream");
    }
    return keys;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:33,代码来源:PublicKeyStore.java


示例13: addNewNotes

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
private void addNewNotes(NoteMap notes) throws IOException {
  for (Note n : notes) {
    if (!ours.contains(n)) {
      ours.set(n, n.getData());
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:NotesBranchUtil.java


示例14: addAllNotes

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
private void addAllNotes(NoteMap notes) throws IOException {
  for (Note n : notes) {
    if (ours.contains(n)) {
      // Merge the existing and the new note as if they are both new,
      // means: base == null
      // There is no really a common ancestry for these two note revisions
      ObjectId noteContent =
          getNoteMerger().merge(null, n, ours.getNote(n), reader, inserter).getData();
      ours.set(n, noteContent);
    } else {
      ours.set(n, n.getData());
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:NotesBranchUtil.java


示例15: parseRobotComments

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
static RevisionNoteMap<RobotCommentsRevisionNote> parseRobotComments(
    ChangeNoteUtil noteUtil, ObjectReader reader, NoteMap noteMap)
    throws ConfigInvalidException, IOException {
  Map<RevId, RobotCommentsRevisionNote> result = new HashMap<>();
  for (Note note : noteMap) {
    RobotCommentsRevisionNote rn =
        new RobotCommentsRevisionNote(noteUtil, reader, note.getData());
    rn.parse();
    result.put(new RevId(note.name()), rn);
  }
  return new RevisionNoteMap<>(noteMap, ImmutableMap.copyOf(result));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:13,代码来源:RevisionNoteMap.java


示例16: getCheckInMap

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
/**
 * Return a list of all check-ins and their corresponding bug IDs.
 *
 * @param   branch     Branch name
 * @param   start      Starting check-in from which the branch was created
 * @return  List of check-in IDs and their corresponding bug IDs
 */
public HashMap<String, List<String>> getCheckInMap(String branch, String start) throws Exception {
    HashMap<String, List<String>> checkins = new HashMap<String, List<String>>();
    Date startDate = new Date();

    // Determine the start and end point of the current branch for walking the object tree
    RevCommit head = revWalk.lookupCommit(repository.getRepository().resolve(branch));
    RevCommit branchPoint = revWalk.lookupCommit(repository.getRepository().resolve(start));
    revWalk.markStart(head);

    logger.info("Creating RevWalk from " + branchPoint.getName() + " to " + head.getName());

    // Iterate through each commit, working backward from the head of the branch
    RevCommit currentCommit = head;
    while (!currentCommit.equals(branchPoint)) {
        // Get the note associated with the current commit
        currentCommit = revWalk.next();
        ShowNoteCommand noteCmd = repository.notesShow();
        noteCmd.setNotesRef(DEFECT_NOTE_REF);
        noteCmd.setObjectId(currentCommit);
        Note note = noteCmd.call();

        // Get the list of bugs associated with the current note
        List<String> bugIds = null;
        if (note != null) {
            bugIds = getBugIds(note);
        }

        // Associate the list of bugs with the commit
        if ((bugIds != null) && (bugIds.size() > 0)) {
            checkins.put(currentCommit.getName(), bugIds);
        }
    }

    // Display the elapsed time for this operation
    CMnCmdLineTool.logElapsedTime(logger, startDate, new Date(), "Get check-in map: ");

    return checkins;
}
 
开发者ID:ModelN,项目名称:build-management,代码行数:46,代码来源:CMnGitServer.java


示例17: addMergeNote

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
/**
 * Create a new git note and associate it with the specified commit.
 *
 * @param  namespace Git notes namespace
 * @param  commit    Commit object to attach the note to
 * @param  msg       Note text
 */
private void addMergeNote(String namespace, RevObject commit, String msg) throws GitAPIException {
    AddNoteCommand addCmd = repository.notesAdd();
    addCmd.setObjectId(commit);
    addCmd.setMessage(msg);
    addCmd.setNotesRef(namespace);
    Note note = addCmd.call();
    if (note != null) {
        logger.info("Merge note has been created: " + note.toString());
    } else {
        logger.severe("Failed to add note to commit: " + commit.getName());
    }

}
 
开发者ID:ModelN,项目名称:build-management,代码行数:21,代码来源:CMnGitServer.java


示例18: main

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
public static void main(String[] args) throws IOException, GitAPIException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
        try (Git git = new Git(repository)) {
            List<Note> call = git.notesList().call();
            System.out.println("Listing " + call.size() + " notes");
            for (Note note : call) {
                System.out.println("Note: " + note + " " + note.getName() + " " + note.getData().getName() + "\nContent: ");

                // displaying the contents of the note is done via a simple blob-read
                ObjectLoader loader = repository.open(note.getData());
                loader.copyTo(System.out);
            }
        }
    }
}
 
开发者ID:centic9,项目名称:jgit-cookbook,代码行数:16,代码来源:ListNotes.java


示例19: check

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
private List<ConsistencyProblemInfo> check(Repository repo, ObjectId commit) throws IOException {
  List<ConsistencyProblemInfo> problems = new ArrayList<>();

  ListMultimap<String, ExternalId.Key> emails =
      MultimapBuilder.hashKeys().arrayListValues().build();

  try (RevWalk rw = new RevWalk(repo)) {
    NoteMap noteMap = ExternalIdReader.readNoteMap(rw, commit);
    for (Note note : noteMap) {
      byte[] raw =
          rw.getObjectReader()
              .open(note.getData(), OBJ_BLOB)
              .getCachedBytes(ExternalIdReader.MAX_NOTE_SZ);
      try {
        ExternalId extId = ExternalId.parse(note.getName(), raw, note.getData());
        problems.addAll(validateExternalId(extId));

        if (extId.email() != null) {
          emails.put(extId.email(), extId.key());
        }
      } catch (ConfigInvalidException e) {
        addError(String.format(e.getMessage()), problems);
      }
    }
  }

  emails
      .asMap()
      .entrySet()
      .stream()
      .filter(e -> e.getValue().size() > 1)
      .forEach(
          e ->
              addError(
                  String.format(
                      "Email '%s' is not unique, it's used by the following external IDs: %s",
                      e.getKey(),
                      e.getValue()
                          .stream()
                          .map(k -> "'" + k.get() + "'")
                          .sorted()
                          .collect(joining(", "))),
                  problems));

  return problems;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:47,代码来源:ExternalIdsConsistencyChecker.java


示例20: patchLineCommentNotesFormatRealAuthor

import org.eclipse.jgit.notes.Note; //导入依赖的package包/类
@Test
public void patchLineCommentNotesFormatRealAuthor() throws Exception {
  Change c = newChange();
  CurrentUser ownerAsOtherUser = userFactory.runAs(null, otherUserId, changeOwner);
  ChangeUpdate update = newUpdate(c, ownerAsOtherUser);
  String uuid = "uuid";
  String message = "comment";
  CommentRange range = new CommentRange(1, 1, 2, 1);
  Timestamp time = TimeUtil.nowTs();
  PatchSet.Id psId = c.currentPatchSetId();
  RevId revId = new RevId("abcd1234abcd1234abcd1234abcd1234abcd1234");

  Comment comment =
      newComment(
          psId,
          "file",
          uuid,
          range,
          range.getEndLine(),
          otherUser,
          null,
          time,
          message,
          (short) 1,
          revId.get(),
          false);
  comment.setRealAuthor(changeOwner.getAccountId());
  update.setPatchSetId(psId);
  update.putComment(Status.PUBLISHED, comment);
  update.commit();

  ChangeNotes notes = newNotes(c);

  try (RevWalk walk = new RevWalk(repo)) {
    ArrayList<Note> notesInTree = Lists.newArrayList(notes.revisionNoteMap.noteMap.iterator());
    Note note = Iterables.getOnlyElement(notesInTree);

    byte[] bytes = walk.getObjectReader().open(note.getData(), Constants.OBJ_BLOB).getBytes();
    String noteString = new String(bytes, UTF_8);

    if (!testJson()) {
      assertThat(noteString)
          .isEqualTo(
              "Revision: abcd1234abcd1234abcd1234abcd1234abcd1234\n"
                  + "Patch-set: 1\n"
                  + "File: file\n"
                  + "\n"
                  + "1:1-2:1\n"
                  + ChangeNoteUtil.formatTime(serverIdent, time)
                  + "\n"
                  + "Author: Other Account <[email protected]>\n"
                  + "Real-author: Change Owner <[email protected]>\n"
                  + "Unresolved: false\n"
                  + "UUID: uuid\n"
                  + "Bytes: 7\n"
                  + "comment\n"
                  + "\n");
    }
  }
  assertThat(notes.getComments()).isEqualTo(ImmutableListMultimap.of(revId, comment));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:62,代码来源:ChangeNotesTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BlockStorageLocation类代码示例发布时间:2022-05-22
下一篇:
Java HealthMonitor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap