Package org.eclipse.jgit.lib.RefUpdate

Examples of org.eclipse.jgit.lib.RefUpdate.Result


                      JGitText.get().cannotDeleteCheckedOutBranch,
                      branchName));
        RefUpdate update = repo.updateRef(fullName);
        update.setRefLogMessage("branch deleted", false);
        update.setForceUpdate(true);
        Result deleteResult = update.delete();

        boolean ok = true;
        switch (deleteResult) {
        case IO_FAILURE:
        case LOCK_FAILURE:
        case REJECTED:
          ok = false;
          break;
        default:
          break;
        }

        if (ok) {
          result.add(fullName);
          if (fullName.startsWith(Constants.R_HEADS)) {
            String shortenedName = fullName
                .substring(Constants.R_HEADS.length());
            // remove upstream configuration if any
            final StoredConfig cfg = repo.getConfig();
            cfg.unsetSection(
                ConfigConstants.CONFIG_BRANCH_SECTION,
                shortenedName);
            cfg.save();
          }
        } else
          throw new JGitInternalException(MessageFormat.format(
              JGitText.get().deleteBranchUnexpectedResult,
              deleteResult.name()));
      }
      return result;
    } catch (IOException ioe) {
      throw new JGitInternalException(ioe.getMessage(), ioe);
    }
View Full Code Here


          String refName = Constants.R_TAGS + newTag.getTag();
          RefUpdate tagRef = repo.updateRef(refName);
          tagRef.setNewObjectId(tagId);
          tagRef.setForceUpdate(forceUpdate);
          tagRef.setRefLogMessage("tagged " + name, false);
          Result updateResult = tagRef.update(revWalk);
          switch (updateResult) {
          case NEW:
          case FORCED:
            return revTag;
          case LOCK_FAILURE:
View Full Code Here

            branchName = "refs/heads/" + branchName;
          }
          RefUpdate ru = repository.updateRef(branchName);
          ru.setNewObjectId(commitId);
          ru.setRefLogMessage("commit: " + revCommit.getShortMessage(), false);
          Result rc = ru.forceUpdate();
          switch (rc) {
          case NEW:
          case FORCED:
          case FAST_FORWARD:
            success = true;
View Full Code Here

      RefRename cmd;
      try {
        cmd = db.renameRef(oldRef.getName(), BRANCH);
        cmd.setRefLogIdent(new PersonIdent("Gitblit", "gitblit@localhost"));
        cmd.setRefLogMessage("renamed " + oldRef.getName() + " => " + BRANCH);
        Result res = cmd.rename();
        switch (res) {
        case RENAMED:
          log.info(db.getDirectory() + " " + cmd.getRefLogMessage());
          return getTicketsBranch(db);
        default:
          log.error("failed to rename " + oldRef.getName() + " => " + BRANCH + " (" + res.name() + ")");
        }
      } catch (IOException e) {
        log.error("failed to rename tickets branch", e);
      }
    }
View Full Code Here

        RevCommit revCommit = revWalk.parseCommit(commitId);
        RefUpdate ru = db.updateRef(BRANCH);
        ru.setNewObjectId(commitId);
        ru.setExpectedOldObjectId(headId);
        ru.setRefLogMessage("commit: " + revCommit.getShortMessage(), false);
        Result rc = ru.forceUpdate();
        switch (rc) {
        case NEW:
        case FORCED:
        case FAST_FORWARD:
          success = true;
View Full Code Here

        // point the previous head (if any) to the new commit
        String headName = readFile(rebaseDir, HEAD_NAME);
        if (headName.startsWith(Constants.R_REFS)) {
          RefUpdate rup = repo.updateRef(headName);
          rup.setNewObjectId(newHead);
          Result res = rup.forceUpdate();
          switch (res) {
          case FAST_FORWARD:
          case FORCED:
          case NO_CHANGE:
            break;
View Full Code Here

        RefUpdate rup = repo.updateRef(headName);
        rup.setExpectedOldObjectId(oldCommit);
        rup.setNewObjectId(newCommit);
        rup.setRefLogMessage("Fast-foward from " + oldCommit.name()
            + " to " + newCommit.name(), false);
        Result res = rup.update(walk);
        switch (res) {
        case FAST_FORWARD:
        case NO_CHANGE:
        case FORCED:
          break;
View Full Code Here

            JGitText.get().resettingHead, headName),
            ProgressMonitor.UNKNOWN);

        // update the HEAD
        RefUpdate refUpdate = repo.updateRef(Constants.HEAD, false);
        Result res = refUpdate.link(headName);
        switch (res) {
        case FAST_FORWARD:
        case FORCED:
        case NO_CHANGE:
          break;
View Full Code Here

      dco.checkout();
      // update the HEAD
      RefUpdate refUpdate = repo.updateRef(Constants.HEAD, true);
      refUpdate.setExpectedOldObjectId(head);
      refUpdate.setNewObjectId(commit);
      Result res = refUpdate.forceUpdate();
      switch (res) {
      case FAST_FORWARD:
      case NO_CHANGE:
      case FORCED:
        break;
View Full Code Here

        ref = null;
      RefUpdate refUpdate = repo.updateRef(Constants.HEAD, ref == null);
      refUpdate.setForceUpdate(force);
      refUpdate.setRefLogMessage(refLogMessage + " to "
          + newCommit.getName(), false);
      Result updateResult;
      if (ref != null)
        updateResult = refUpdate.link(ref.getName());
      else {
        refUpdate.setNewObjectId(newCommit);
        updateResult = refUpdate.forceUpdate();
      }

      setCallable(false);

      boolean ok = false;
      switch (updateResult) {
      case NEW:
        ok = true;
        break;
      case NO_CHANGE:
      case FAST_FORWARD:
      case FORCED:
        ok = true;
        break;
      default:
        break;
      }

      if (!ok)
        throw new JGitInternalException(MessageFormat.format(JGitText
            .get().checkoutUnexpectedResult, updateResult.name()));

      if (!dco.getToBeDeleted().isEmpty()) {
        status = new CheckoutResult(Status.NONDELETED, dco
            .getToBeDeleted());
      }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.RefUpdate.Result

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.