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


Java RefUpdate.setRefLogIdent方法代码示例

本文整理汇总了Java中org.eclipse.jgit.lib.RefUpdate.setRefLogIdent方法的典型用法代码示例。如果您正苦于以下问题:Java RefUpdate.setRefLogIdent方法的具体用法?Java RefUpdate.setRefLogIdent怎么用?Java RefUpdate.setRefLogIdent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.lib.RefUpdate的用法示例。


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

示例1: updateReference

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void updateReference(
    Repository repository,
    String refName,
    ObjectId currentObjectId,
    ObjectId targetObjectId,
    Timestamp timestamp)
    throws IOException {
  RefUpdate ru = repository.updateRef(refName);
  ru.setExpectedOldObjectId(currentObjectId);
  ru.setNewObjectId(targetObjectId);
  ru.setRefLogIdent(getRefLogIdent(timestamp));
  ru.setRefLogMessage("inline edit (amend)", false);
  ru.setForceUpdate(true);
  try (RevWalk revWalk = new RevWalk(repository)) {
    RefUpdate.Result res = ru.update(revWalk);
    if (res != RefUpdate.Result.NEW && res != RefUpdate.Result.FORCED) {
      throw new IOException(
          "cannot update "
              + ru.getName()
              + " in "
              + repository.getDirectory()
              + ": "
              + ru.getResult());
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:ChangeEditModifier.java

示例2: deleteUserBranch

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public static void deleteUserBranch(
    Repository repo,
    Project.NameKey project,
    GitReferenceUpdated gitRefUpdated,
    @Nullable IdentifiedUser user,
    PersonIdent refLogIdent,
    Account.Id accountId)
    throws IOException {
  String refName = RefNames.refsUsers(accountId);
  Ref ref = repo.exactRef(refName);
  if (ref == null) {
    return;
  }

  RefUpdate ru = repo.updateRef(refName);
  ru.setExpectedOldObjectId(ref.getObjectId());
  ru.setNewObjectId(ObjectId.zeroId());
  ru.setForceUpdate(true);
  ru.setRefLogIdent(refLogIdent);
  ru.setRefLogMessage("Delete Account", true);
  Result result = ru.delete();
  if (result != Result.FORCED) {
    throw new IOException(String.format("Failed to delete ref %s: %s", refName, result.name()));
  }
  gitRefUpdated.fire(project, ru, user != null ? user.getAccount() : null);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:AccountsUpdate.java

示例3: createUserBranch

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public void createUserBranch(
    Repository repo,
    ObjectInserter oi,
    ObjectId emptyTree,
    Account.Id accountId,
    Timestamp registeredOn)
    throws IOException {
  ObjectId id = createInitialEmptyCommit(oi, emptyTree, registeredOn);

  String refName = RefNames.refsUsers(accountId);
  RefUpdate ru = repo.updateRef(refName);
  ru.setExpectedOldObjectId(ObjectId.zeroId());
  ru.setNewObjectId(id);
  ru.setRefLogIdent(serverIdent);
  ru.setRefLogMessage(CREATE_ACCOUNT_MSG, false);
  Result result = ru.update();
  if (result != Result.NEW) {
    throw new IOException(String.format("Failed to update ref %s: %s", refName, result.name()));
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:Schema_146.java

示例4: updateRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
protected void updateRef(String refName, String newValue, @Nullable String oldValue) {
	try {
		RefUpdate update = git.getRepository().updateRef(refName);
		update.setNewObjectId(git.getRepository().resolve(newValue));
		if (oldValue != null)
			update.setExpectedOldObjectId(git.getRepository().resolve(oldValue));
		update.setRefLogIdent(user);
		update.setRefLogMessage("update ref", false);
		GitUtils.updateRef(update);
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:14,代码来源:AbstractGitTest.java

示例5: updateRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void updateRef(Repository repo, PersonIdent ident, ObjectId newRevision, String refLogMsg)
    throws IOException {
  RefUpdate ru = repo.updateRef(getRefName());
  ru.setRefLogIdent(ident);
  ru.setNewObjectId(newRevision);
  ru.setExpectedOldObjectId(revision);
  ru.setRefLogMessage(refLogMsg, false);
  RefUpdate.Result r = ru.update();
  switch (r) {
    case FAST_FORWARD:
    case NEW:
    case NO_CHANGE:
      break;
    case FORCED:
    case IO_FAILURE:
    case LOCK_FAILURE:
    case NOT_ATTEMPTED:
    case REJECTED:
    case REJECTED_CURRENT_BRANCH:
    case RENAMED:
    case REJECTED_MISSING_OBJECT:
    case REJECTED_OTHER_REASON:
    default:
      throw new IOException(
          "Failed to update " + getRefName() + " of " + project + ": " + r.name());
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:28,代码来源:VersionedMetaDataOnInit.java

示例6: updateLabels

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void updateLabels(
    Repository repo, String refName, ObjectId oldObjectId, Collection<String> labels)
    throws IOException, OrmException, InvalidLabelsException {
  try (RevWalk rw = new RevWalk(repo)) {
    RefUpdate u = repo.updateRef(refName);
    u.setExpectedOldObjectId(oldObjectId);
    u.setForceUpdate(true);
    u.setNewObjectId(writeLabels(repo, labels));
    u.setRefLogIdent(serverIdent);
    u.setRefLogMessage("Update star labels", true);
    RefUpdate.Result result = u.update(rw);
    switch (result) {
      case NEW:
      case FORCED:
      case NO_CHANGE:
      case FAST_FORWARD:
        gitRefUpdated.fire(allUsers, u, null);
        return;
      case IO_FAILURE:
      case LOCK_FAILURE:
      case NOT_ATTEMPTED:
      case REJECTED:
      case REJECTED_CURRENT_BRANCH:
      case RENAMED:
      case REJECTED_MISSING_OBJECT:
      case REJECTED_OTHER_REASON:
      default:
        throw new OrmException(
            String.format("Update star labels on ref %s failed: %s", refName, result.name()));
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:33,代码来源:StarredChangesUtil.java

示例7: deleteRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void deleteRef(Repository repo, String refName, ObjectId oldObjectId)
    throws IOException, OrmException {
  RefUpdate u = repo.updateRef(refName);
  u.setForceUpdate(true);
  u.setExpectedOldObjectId(oldObjectId);
  u.setRefLogIdent(serverIdent);
  u.setRefLogMessage("Unstar change", true);
  RefUpdate.Result result = u.delete();
  switch (result) {
    case FORCED:
      gitRefUpdated.fire(allUsers, u, null);
      return;
    case NEW:
    case NO_CHANGE:
    case FAST_FORWARD:
    case IO_FAILURE:
    case LOCK_FAILURE:
    case NOT_ATTEMPTED:
    case REJECTED:
    case REJECTED_CURRENT_BRANCH:
    case RENAMED:
    case REJECTED_MISSING_OBJECT:
    case REJECTED_OTHER_REASON:
    default:
      throw new OrmException(
          String.format("Delete star ref %s failed: %s", refName, result.name()));
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:29,代码来源:StarredChangesUtil.java

示例8: fixPatchSetRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void fixPatchSetRef(ProblemInfo p, PatchSet ps) {
  try {
    RefUpdate ru = repo.updateRef(ps.getId().toRefName());
    ru.setForceUpdate(true);
    ru.setNewObjectId(ObjectId.fromString(ps.getRevision().get()));
    ru.setRefLogIdent(newRefLogIdent());
    ru.setRefLogMessage("Repair patch set ref", true);
    RefUpdate.Result result = ru.update();
    switch (result) {
      case NEW:
      case FORCED:
      case FAST_FORWARD:
      case NO_CHANGE:
        p.status = Status.FIXED;
        p.outcome = "Repaired patch set ref";
        return;
      case IO_FAILURE:
      case LOCK_FAILURE:
      case NOT_ATTEMPTED:
      case REJECTED:
      case REJECTED_CURRENT_BRANCH:
      case RENAMED:
      case REJECTED_MISSING_OBJECT:
      case REJECTED_OTHER_REASON:
      default:
        p.status = Status.FIX_FAILED;
        p.outcome = "Failed to update patch set ref: " + result;
        return;
    }
  } catch (IOException e) {
    String msg = "Error fixing patch set ref";
    log.warn(msg + ' ' + ps.getId().toRefName(), e);
    p.status = Status.FIX_FAILED;
    p.outcome = msg;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:37,代码来源:ConsistencyChecker.java

示例9: save

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
/**
 * Save pending keys to the store.
 *
 * <p>One commit is created and the ref updated. The pending list is cleared if and only if the
 * ref update succeeds, which allows for easy retries in case of lock failure.
 *
 * @param cb commit builder with at least author and identity populated; tree and parent are
 *     ignored.
 * @return result of the ref update.
 */
public RefUpdate.Result save(CommitBuilder cb) throws PGPException, IOException {
  if (toAdd.isEmpty() && toRemove.isEmpty()) {
    return RefUpdate.Result.NO_CHANGE;
  }
  if (reader == null) {
    load();
  }
  if (notes == null) {
    notes = NoteMap.newEmptyMap();
  }
  ObjectId newTip;
  try (ObjectInserter ins = repo.newObjectInserter()) {
    for (PGPPublicKeyRing keyRing : toAdd.values()) {
      saveToNotes(ins, keyRing);
    }
    for (Fingerprint fp : toRemove) {
      deleteFromNotes(ins, fp);
    }
    cb.setTreeId(notes.writeTree(ins));
    if (cb.getTreeId().equals(tip != null ? tip.getTree() : EMPTY_TREE)) {
      return RefUpdate.Result.NO_CHANGE;
    }

    if (tip != null) {
      cb.setParentId(tip);
    }
    if (cb.getMessage() == null) {
      int n = toAdd.size() + toRemove.size();
      cb.setMessage(String.format("Update %d public key%s", n, n != 1 ? "s" : ""));
    }
    newTip = ins.insert(cb);
    ins.flush();
  }

  RefUpdate ru = repo.updateRef(PublicKeyStore.REFS_GPG_KEYS);
  ru.setExpectedOldObjectId(tip);
  ru.setNewObjectId(newTip);
  ru.setRefLogIdent(cb.getCommitter());
  ru.setRefLogMessage("Store public keys", true);
  RefUpdate.Result result = ru.update();
  reset();
  switch (result) {
    case FAST_FORWARD:
    case NEW:
    case NO_CHANGE:
      toAdd.clear();
      toRemove.clear();
      break;
    case FORCED:
    case IO_FAILURE:
    case LOCK_FAILURE:
    case NOT_ATTEMPTED:
    case REJECTED:
    case REJECTED_CURRENT_BRANCH:
    case RENAMED:
    case REJECTED_MISSING_OBJECT:
    case REJECTED_OTHER_REASON:
    default:
      break;
  }
  return result;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:73,代码来源:PublicKeyStore.java

示例10: insert

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public void insert(Account account) throws IOException {
  File path = getPath();
  if (path != null) {
    try (Repository repo = new FileRepository(path);
        ObjectInserter oi = repo.newObjectInserter()) {
      PersonIdent ident =
          new PersonIdent(
              new GerritPersonIdentProvider(flags.cfg).get(), account.getRegisteredOn());

      Config accountConfig = new Config();
      AccountConfig.writeToConfig(account, accountConfig);

      DirCache newTree = DirCache.newInCore();
      DirCacheEditor editor = newTree.editor();
      final ObjectId blobId =
          oi.insert(Constants.OBJ_BLOB, accountConfig.toText().getBytes(UTF_8));
      editor.add(
          new PathEdit(AccountConfig.ACCOUNT_CONFIG) {
            @Override
            public void apply(DirCacheEntry ent) {
              ent.setFileMode(FileMode.REGULAR_FILE);
              ent.setObjectId(blobId);
            }
          });
      editor.finish();

      ObjectId treeId = newTree.writeTree(oi);

      CommitBuilder cb = new CommitBuilder();
      cb.setTreeId(treeId);
      cb.setCommitter(ident);
      cb.setAuthor(ident);
      cb.setMessage("Create Account");
      ObjectId id = oi.insert(cb);
      oi.flush();

      String refName = RefNames.refsUsers(account.getId());
      RefUpdate ru = repo.updateRef(refName);
      ru.setExpectedOldObjectId(ObjectId.zeroId());
      ru.setNewObjectId(id);
      ru.setRefLogIdent(ident);
      ru.setRefLogMessage("Create Account", false);
      Result result = ru.update();
      if (result != Result.NEW) {
        throw new IOException(
            String.format("Failed to update ref %s: %s", refName, result.name()));
      }
      account.setMetaId(id.name());
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:52,代码来源:AccountsOnInit.java

示例11: commit

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
/** Commits updates to the external IDs. */
public static ObjectId commit(
    Project.NameKey project,
    Repository repo,
    RevWalk rw,
    ObjectInserter ins,
    ObjectId rev,
    NoteMap noteMap,
    String commitMessage,
    PersonIdent committerIdent,
    PersonIdent authorIdent,
    @Nullable IdentifiedUser user,
    GitReferenceUpdated gitRefUpdated)
    throws IOException {
  CommitBuilder cb = new CommitBuilder();
  cb.setMessage(commitMessage);
  cb.setTreeId(noteMap.writeTree(ins));
  cb.setAuthor(authorIdent);
  cb.setCommitter(committerIdent);
  if (!rev.equals(ObjectId.zeroId())) {
    cb.setParentId(rev);
  } else {
    cb.setParentIds(); // Ref is currently nonexistent, commit has no parents.
  }
  if (cb.getTreeId() == null) {
    if (rev.equals(ObjectId.zeroId())) {
      cb.setTreeId(emptyTree(ins)); // No parent, assume empty tree.
    } else {
      RevCommit p = rw.parseCommit(rev);
      cb.setTreeId(p.getTree()); // Copy tree from parent.
    }
  }
  ObjectId commitId = ins.insert(cb);
  ins.flush();

  RefUpdate u = repo.updateRef(RefNames.REFS_EXTERNAL_IDS);
  u.setRefLogIdent(committerIdent);
  u.setRefLogMessage("Update external IDs", false);
  u.setExpectedOldObjectId(rev);
  u.setNewObjectId(commitId);
  RefUpdate.Result res = u.update();
  switch (res) {
    case NEW:
    case FAST_FORWARD:
    case NO_CHANGE:
    case RENAMED:
    case FORCED:
      break;
    case LOCK_FAILURE:
      throw new LockFailureException("Updating external IDs failed with " + res, u);
    case IO_FAILURE:
    case NOT_ATTEMPTED:
    case REJECTED:
    case REJECTED_CURRENT_BRANCH:
    case REJECTED_MISSING_OBJECT:
    case REJECTED_OTHER_REASON:
    default:
      throw new IOException("Updating external IDs failed with " + res);
  }
  gitRefUpdated.fire(project, u, user != null ? user.getAccount() : null);
  return rw.parseCommit(commitId);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:63,代码来源:ExternalIdsUpdate.java

示例12: rewriteUserBranch

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private void rewriteUserBranch(
    Repository repo,
    RevWalk rw,
    ObjectInserter oi,
    ObjectId emptyTree,
    Ref ref,
    Timestamp registeredOn)
    throws IOException {
  ObjectId current = createInitialEmptyCommit(oi, emptyTree, registeredOn);

  rw.reset();
  rw.sort(RevSort.TOPO);
  rw.sort(RevSort.REVERSE, true);
  rw.markStart(rw.parseCommit(ref.getObjectId()));

  RevCommit c;
  while ((c = rw.next()) != null) {
    if (isInitialEmptyCommit(emptyTree, c)) {
      return;
    }

    CommitBuilder cb = new CommitBuilder();
    cb.setParentId(current);
    cb.setTreeId(c.getTree());
    cb.setAuthor(c.getAuthorIdent());
    cb.setCommitter(c.getCommitterIdent());
    cb.setMessage(c.getFullMessage());
    cb.setEncoding(c.getEncoding());
    current = oi.insert(cb);
  }

  oi.flush();

  RefUpdate ru = repo.updateRef(ref.getName());
  ru.setExpectedOldObjectId(ref.getObjectId());
  ru.setNewObjectId(current);
  ru.setForceUpdate(true);
  ru.setRefLogIdent(serverIdent);
  ru.setRefLogMessage(getClass().getSimpleName(), true);
  Result result = ru.update();
  if (result != Result.FORCED) {
    throw new IOException(
        String.format("Failed to update ref %s: %s", ref.getName(), result.name()));
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:46,代码来源:Schema_146.java

示例13: merge

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public boolean merge(String baseBranchName, IssuePK issuePK, String message, LoginContext loginContext) {
  String mergeMessage = PullRequest.getMergeMessage(issuePK, new PullRequestEndpoint(issuePK.getRepositoryPK(), baseBranchName))
      + "\n\n" + message;
  try (RepositoryReader reader = new RepositoryReader(issuePK.getRepositoryPK())) {
    Repository repository = reader.getRepository();

    String pullBranch = Constants.R_REFS + "pull/" + issuePK.getIssueId() + "/head";
    String baseBranchRefName = Constants.R_HEADS + baseBranchName;

    ThreeWayMerger merger = MergeStrategy.RECURSIVE.newMerger(repository, true);
    ObjectInserter inserter = repository.newObjectInserter();

    try {
      ObjectId baseObjectId = repository.resolve(baseBranchRefName);
      ObjectId pullBranchObjectId = repository.resolve(pullBranch);

      boolean noError = merger.merge(baseObjectId, pullBranchObjectId);
      if (!noError) {
        throw new RuntimeException("cannot merge!!");
      }

      ObjectId resultTreeId = merger.getResultTreeId();

      PersonIdent personIdent = new PersonIdent(loginContext.getName(), loginContext.getEmail());
      CommitBuilder commit = new CommitBuilder();
      commit.setCommitter(personIdent);
      commit.setAuthor(personIdent);
      commit.setMessage(mergeMessage);
      commit.setParentIds(baseObjectId, pullBranchObjectId);
      commit.setTreeId(resultTreeId);
      ObjectId mergedCommitId = inserter.insert(commit);
      inserter.flush();

      RefUpdate refUpdate = repository.updateRef(baseBranchRefName);
      refUpdate.setNewObjectId(mergedCommitId);
      refUpdate.setForceUpdate(false);
      refUpdate.setRefLogIdent(personIdent);
      refUpdate.setRefLogMessage("merged", false);
      refUpdate.update();

      return true;
    } catch (RevisionSyntaxException | IOException e) {
      return false;
    } finally {
      inserter.release();
    }
  }
}
 
开发者ID:kamegu,项目名称:git-webapp,代码行数:49,代码来源:GitOperation.java


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