Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.RefUpdate$Store


    final Repository r = repoManager.openRepository(projectName);
    try {
      for (final Branch.NameKey branchKey : toRemove) {
        final String refname = branchKey.get();
        final RefUpdate.Result result;
        final RefUpdate u;
        try {
          u = r.updateRef(refname);
          u.setForceUpdate(true);
          result = u.delete();
        } catch (IOException e) {
          log.error("Cannot delete " + branchKey, e);
          continue;
        }
View Full Code Here


                    ChangeUtil.updated(change);
                    return change;
                  }
                });

        final RefUpdate ru = git.updateRef(rebasedPatchSet.getRefName());
        ru.setNewObjectId(rebasedCommitId);
        ru.disableRefLog();
        if (ru.update(revWalk) != RefUpdate.Result.NEW) {
          throw new IOException("Failed to create ref "
              + rebasedPatchSet.getRefName() + " in " + git.getDirectory()
              + ": " + ru.getResult());
        }

        replication.fire(change.getProject(), ru.getName());

        List<PatchSetApproval> patchSetApprovals = approvalsUtil.copyVetosToLatestPatchSet(change);

        final Set<Account.Id> oldReviewers = new HashSet<Account.Id>();
        final Set<Account.Id> oldCC = new HashSet<Account.Id>();
View Full Code Here

          patchSetInfoFactory.get(revWalk.parseCommit(id), ps.getId());
      change.setCurrentPatchSet(info);
      ChangeUtil.updated(change);
      db.changes().insert(Collections.singleton(change));

      final RefUpdate ru = git.updateRef(ps.getRefName());
      ru.setNewObjectId(id);
      ru.disableRefLog();
      if (ru.update(revWalk) != RefUpdate.Result.NEW) {
        throw new IOException("Failed to create ref " + ps.getRefName()
            + " in " + git.getDirectory() + ": " + ru.getResult());
      }
      replication.fire(db.changes().get(changeId).getProject(),
          ru.getName());

      final ChangeMessage cmsg =
          new ChangeMessage(new ChangeMessage.Key(changeId,
              ChangeUtil.messageUUID(db)), user.getAccountId(), patchSetId);
      final StringBuilder msgBuf =
View Full Code Here

      throw new NoSuchChangeException(patchSetId.getParentKey());
    }

    Repository repo = gitManager.openRepository(change.getProject());
    try {
      RefUpdate update = repo.updateRef(patch.getRefName());
      update.setForceUpdate(true);
      update.disableRefLog();
      switch (update.delete()) {
        case NEW:
        case FAST_FORWARD:
        case FORCED:
        case NO_CHANGE:
          // Successful deletion.
          break;
        default:
          throw new IOException("Failed to delete ref " + patch.getRefName() +
              " in " + repo.getDirectory() + ": " + update.getResult());
      }
      replication.fire(change.getProject(), update.getName());
    } finally {
      repo.close();
    }

    db.accountPatchReviews().delete(db.accountPatchReviews().byPatchSet(patchSetId));
View Full Code Here

  private void doCheckout(final Ref branch) throws IOException {
    if (branch == null)
      throw die(CLIText.get().cannotChekoutNoHeadsAdvertisedByRemote);
    if (!Constants.HEAD.equals(branch.getName())) {
      RefUpdate u = db.updateRef(Constants.HEAD);
      u.disableRefLog();
      u.link(branch.getName());
    }

    final RevCommit commit = parseCommit(branch);
    final RefUpdate u = db.updateRef(Constants.HEAD);
    u.setNewObjectId(commit);
    u.forceUpdate();

    DirCache dc = db.lockDirCache();
    DirCacheCheckout co = new DirCacheCheckout(db, dc, commit.getTree());
    co.checkout();
  }
View Full Code Here

                }
            }

            if (null == masterCommit)
            {
                RefUpdate refUpdate = repo.getRefDatabase().newUpdate(Constants.HEAD, false);
                refUpdate.setForceUpdate(true);
                refUpdate.link(Constants.R_HEADS + context.getMaster());

                git.commit().setMessage("Initial Commit").call();
            }

            //creation of develop
View Full Code Here

        setCallable(false);
        return repo.getRef(Constants.HEAD);
      }

      // write the ref
      final RefUpdate ru = repo.updateRef(Constants.HEAD);
      ru.setNewObjectId(commitId);

      String refName = Repository.shortenRefName(ref);
      String message = refName + ": updating " + Constants.HEAD; //$NON-NLS-1$
      ru.setRefLogMessage(message, false);
      if (ru.forceUpdate() == RefUpdate.Result.LOCK_FAILURE)
        throw new JGitInternalException(MessageFormat.format(
            JGitText.get().cannotLock, ru.getName()));

      ObjectId origHead = ru.getOldObjectId();
      if (origHead != null)
        repo.writeOrigHead(origHead);

      switch (mode) {
        case HARD:
          checkoutIndex(commit);
          break;
        case MIXED:
          resetIndex(commit);
          break;
        case SOFT: // do nothing, only the ref was changed
          break;
        case KEEP: // TODO
        case MERGE: // TODO
          throw new UnsupportedOperationException();

      }

      if (mode != ResetType.SOFT) {
        if (merging)
          resetMerge();
        else if (cherryPicking)
          resetCherryPick();
        else if (repo.readSquashCommitMsg() != null)
          repo.writeSquashCommitMsg(null /* delete */);
      }

      setCallable(false);
      r = ru.getRef();
    } catch (IOException e) {
      throw new JGitInternalException(
          JGitText.get().exceptionCaughtDuringExecutionOfResetCommand,
          e);
    }
View Full Code Here

        else
          refLogMessage = "branch: Created from tag "
              + startPointFullName;
      }

      RefUpdate updateRef = repo.updateRef(Constants.R_HEADS + name);
      updateRef.setNewObjectId(startAt);
      updateRef.setRefLogMessage(refLogMessage, false);
      Result updateResult;
      if (exists && force)
        updateResult = updateRef.forceUpdate();
      else
        updateResult = updateRef.update();

      setCallable(false);

      boolean ok = false;
      switch (updateResult) {
View Full Code Here

        revWalk.parseHeaders(srcCommit);
        dco = new DirCacheCheckout(repo,
            repo.lockDirCache(), srcCommit.getTree());
        dco.setFailOnConflict(true);
        dco.checkout();
        RefUpdate refUpdate = repo
            .updateRef(head.getTarget().getName());
        refUpdate.setNewObjectId(objectId);
        refUpdate.setExpectedOldObjectId(null);
        refUpdate.setRefLogMessage("initial pull", false);
        if (refUpdate.update() != Result.NEW)
          throw new NoHeadException(
              JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
        setCallable(false);
        return new MergeResult(srcCommit, srcCommit, new ObjectId[] {
            null, srcCommit }, MergeStatus.FAST_FORWARD,
View Full Code Here

  }

  private void updateHead(StringBuilder refLogMessage, ObjectId newHeadId,
      ObjectId oldHeadID) throws IOException,
      ConcurrentRefUpdateException {
    RefUpdate refUpdate = repo.updateRef(Constants.HEAD);
    refUpdate.setNewObjectId(newHeadId);
    refUpdate.setRefLogMessage(refLogMessage.toString(), false);
    refUpdate.setExpectedOldObjectId(oldHeadID);
    Result rc = refUpdate.update();
    switch (rc) {
    case NEW:
    case FAST_FORWARD:
      return;
    case REJECTED:
    case LOCK_FAILURE:
      throw new ConcurrentRefUpdateException(
          JGitText.get().couldNotLockHEAD, refUpdate.getRef(), rc);
    default:
      throw new JGitInternalException(MessageFormat.format(
          JGitText.get().updatingRefFailed, Constants.HEAD,
          newHeadId.toString(), rc));
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.RefUpdate$Store

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.