Package org.eclipse.jgit.api.errors

Examples of org.eclipse.jgit.api.errors.JGitInternalException


            FileUtils.delete(new File(repo.getWorkTree(), file));
          files.add(file);
        }
      }
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    }
    return files;
  }
View Full Code Here


      return refmap.values();
    } catch (URISyntaxException e) {
      throw new InvalidRemoteException(MessageFormat.format(
          JGitText.get().invalidRemote, remote));
    } catch (NotSupportedException e) {
      throw new JGitInternalException(
          JGitText.get().exceptionCaughtDuringExecutionOfLsRemoteCommand,
          e);
    } catch (TransportException e) {
        throw new org.eclipse.jgit.api.errors.TransportException(
          JGitText.get().exceptionCaughtDuringExecutionOfLsRemoteCommand,
View Full Code Here

        }

        if (ok) {
          result.add(fullName);
        } else
          throw new JGitInternalException(MessageFormat.format(
              JGitText.get().deleteTagUnexpectedResult,
              deleteResult.name()));
      }
      return result;
    } catch (IOException ioe) {
      throw new JGitInternalException(ioe.getMessage(), ioe);
    }
  }
View Full Code Here

      default:
        break;
      }

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

      Ref result = repo.getRef(name);
      if (result == null)
        throw new JGitInternalException(
            JGitText.get().createBranchFailedUnknownReason);

      if (baseBranch.length() == 0) {
        return result;
      }

      // if we are based on another branch, see
      // if we need to configure upstream configuration: first check
      // whether the setting was done explicitly
      boolean doConfigure;
      if (upstreamMode == SetupUpstreamMode.SET_UPSTREAM
          || upstreamMode == SetupUpstreamMode.TRACK)
        // explicitly set to configure
        doConfigure = true;
      else if (upstreamMode == SetupUpstreamMode.NOTRACK)
        // explicitly set to not configure
        doConfigure = false;
      else {
        // if there was no explicit setting, check the configuration
        String autosetupflag = repo.getConfig().getString(
            ConfigConstants.CONFIG_BRANCH_SECTION, null,
            ConfigConstants.CONFIG_KEY_AUTOSETUPMERGE);
        if ("false".equals(autosetupflag)) {
          doConfigure = false;
        } else if ("always".equals(autosetupflag)) {
          doConfigure = true;
        } else {
          // in this case, the default is to configure
          // only in case the base branch was a remote branch
          doConfigure = baseBranch.startsWith(Constants.R_REMOTES);
        }
      }

      if (doConfigure) {
        StoredConfig config = repo.getConfig();
        String[] tokens = baseBranch.split("/", 4);
        boolean isRemote = tokens[1].equals("remotes");
        if (isRemote) {
          // refs/remotes/<remote name>/<branch>
          String remoteName = tokens[2];
          String branchName = tokens[3];
          config
              .setString(ConfigConstants.CONFIG_BRANCH_SECTION,
                  name, ConfigConstants.CONFIG_KEY_REMOTE,
                  remoteName);
          config.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
              name, ConfigConstants.CONFIG_KEY_MERGE,
              Constants.R_HEADS + branchName);
        } else {
          // set "." as remote
          config.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
              name, ConfigConstants.CONFIG_KEY_REMOTE, ".");
          config.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
              name, ConfigConstants.CONFIG_KEY_MERGE, baseBranch);
        }
        config.save();
      }
      return result;
    } catch (IOException ioe) {
      throw new JGitInternalException(ioe.getMessage(), ioe);
    } finally {
      revWalk.release();
    }
  }
View Full Code Here

    } catch (org.eclipse.jgit.errors.CheckoutConflictException e) {
      List<String> conflicts = (dco == null) ? Collections
          .<String> emptyList() : dco.getConflicts();
      throw new CheckoutConflictException(conflicts, e);
    } catch (IOException e) {
      throw new JGitInternalException(
          MessageFormat.format(
              JGitText.get().exceptionCaughtDuringExecutionOfMergeCommand,
              e), e);
    } finally {
      if (revWalk != null)
View Full Code Here

    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

      try {
        commitId = repo.resolve(ref);
        if (commitId == null) {
          // @TODO throw an InvalidRefNameException. We can't do that
          // now because this would break the API
          throw new JGitInternalException("Invalid ref " + ref
              + " specified");
        }
      } catch (IOException e) {
        throw new JGitInternalException(
            MessageFormat.format(JGitText.get().cannotRead, ref),
            e);
      }
      RevWalk rw = new RevWalk(repo);
      try {
        commit = rw.parseCommit(commitId);
      } catch (IOException e) {
        throw new JGitInternalException(
            MessageFormat.format(
            JGitText.get().cannotReadCommit, commitId.toString()),
            e);
      } finally {
        rw.release();
      }

      if (!filepaths.isEmpty()) {
        // reset [commit] -- paths
        resetIndexForPaths(commit);
        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()));

      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();
      }

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

    return r;
View Full Code Here

   *            the mode of the reset command
   * @return this instance
   */
  public ResetCommand setMode(ResetType mode) {
    if (!filepaths.isEmpty())
      throw new JGitInternalException(MessageFormat.format(
          JGitText.get().illegalCombinationOfArguments,
          "[--mixed | --soft | --hard]", "<paths>..."));
    this.mode = mode;
    return this;
  }
View Full Code Here

   *            the file to add
   * @return this instance
   */
  public ResetCommand addPath(String file) {
    if (mode != null)
      throw new JGitInternalException(MessageFormat.format(
          JGitText.get().illegalCombinationOfArguments, "<paths>...",
          "[--mixed | --soft | --hard]"));
    filepaths.add(file);
    return this;
  }
View Full Code Here

        SubmoduleStatus status = getStatus(generator);
        statuses.put(status.getPath(), status);
      }
      return statuses;
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } catch (ConfigInvalidException e) {
      throw new JGitInternalException(e.getMessage(), e);
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.api.errors.JGitInternalException

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.