Java 类org.eclipse.jgit.api.errors.JGitInternalException 实例源码

项目:incubator-netbeans    文件:SubmoduleStatusCommand.java   
@Override
protected void run () throws GitException {
    Repository repository = getRepository();
    File workTree = repository.getWorkTree();
    org.eclipse.jgit.api.SubmoduleStatusCommand cmd = new Git(repository).submoduleStatus();
    for (String path : Utils.getRelativePaths(workTree, roots)) {
        cmd.addPath(path);
    }
    try {
        Map<String, SubmoduleStatus> result = cmd.call();
        GitClassFactory fac = getClassFactory();
        for (Map.Entry<String, SubmoduleStatus> e : result.entrySet()) {
            File root = new File(workTree, e.getKey());
            statuses.put(root, fac.createSubmoduleStatus(e.getValue(), root));
        }
    } catch (GitAPIException | JGitInternalException ex) {
        throw new GitException(ex);
    }
}
项目:incubator-netbeans    文件:CreateTagCommand.java   
@Override
protected void run () throws GitException {
    Repository repository = getRepository();
    try {
        RevObject obj = Utils.findObject(repository, taggedObject);
        TagCommand cmd = new Git(repository).tag();
        cmd.setName(tagName);
        cmd.setForceUpdate(forceUpdate);
        cmd.setObjectId(obj);
        cmd.setAnnotated(message != null && !message.isEmpty() || signed);
        if (cmd.isAnnotated()) {
            cmd.setMessage(message);
            cmd.setSigned(signed);
        }
        cmd.call();
        ListTagCommand tagCmd = new ListTagCommand(repository, getClassFactory(), false, new DelegatingGitProgressMonitor(monitor));
        tagCmd.run();
        Map<String, GitTag> tags = tagCmd.getTags();
        tag = tags.get(tagName);
    } catch (JGitInternalException | GitAPIException ex) {
        throw new GitException(ex);
    }
}
项目:hawkcd    文件:GitService.java   
@Override
public GitMaterial cloneRepository(GitMaterial gitMaterial) {
    try {
        CredentialsProvider credentials = this.handleCredentials(gitMaterial);
        Git.cloneRepository()
                .setURI(gitMaterial.getRepositoryUrl())
                .setCredentialsProvider(credentials)
                .setDirectory(new File(gitMaterial.getDestination()))
                .setCloneSubmodules(true)
                .call();

        gitMaterial.setErrorMessage("");

        return null;
    } catch (GitAPIException | JGitInternalException e) {
        gitMaterial.setErrorMessage(e.getMessage());
        return gitMaterial;
    }
}
项目:Black    文件:test.java   
public static void main(String args[]) throws IOException, JGitInternalException, GitAPIException, URISyntaxException{
       String in = "������³˹��³˹������˹����˹��³˹������˹�Ǹ�����";
       String str = "��³˹������˹";
        int lastIndexOf = blackAction.lastIndexOf(str, in);
        System.out.println(lastIndexOf);
//       String path = "d://test//git//test01";
//       String path2 = "C://Users//Administrator//Documents//blacktest//2017.01.133";
//       String[] s = new String[]{"refs/heads/nov","refs/heads/master"};
//       
//       ArrayList<RevCommit> commits = gitTool.getCommitsFromBranch(path, s);
//       for(RevCommit r:commits){
//         System.out.println(r.getFullMessage());
//       }
//       
//      
//   
    }
项目:appformer    文件:SimpleRefUpdateCommand.java   
private void forceUpdate(final RefUpdate ru,
                         final ObjectId id) throws java.io.IOException, ConcurrentRefUpdateException {
    final RefUpdate.Result rc = ru.forceUpdate();
    switch (rc) {
        case NEW:
        case FORCED:
        case FAST_FORWARD:
            break;
        case REJECTED:
        case LOCK_FAILURE:
            throw new ConcurrentRefUpdateException(JGitText.get().couldNotLockHEAD,
                                                   ru.getRef(),
                                                   rc);
        default:
            throw new JGitInternalException(MessageFormat.format(JGitText.get().updatingRefFailed,
                                                                 Constants.HEAD,
                                                                 id.toString(),
                                                                 rc));
    }
}
项目:ninja_chic-    文件:Clone.java   
public OpNotification execute() throws Exception {
    Log.d(TAG, "Starting execute... directory=" + directory);
    ensureFolderExists(directory.getParentFile());

    try {
        cloneRepository()
                .setBare(bare)
                .setDirectory(directory)
                .setURI(sourceUri.toPrivateString())
                .setProgressMonitor(messagingProgressMonitor)
                .setTransportConfigCallback(transportConfigCallback)
                .setCredentialsProvider(credentialsProvider)
                .call();

        Log.d(TAG, "Completed checkout!");
    } catch (JGitInternalException e) {
        throw exceptionWithFriendlyMessageFor(e);
    } finally {
        repoUpdateBroadcaster.broadcastUpdate();
    }

    return new OpNotification(stat_sys_download_done, "Cloned "
            + sourceUri.getHumanishName(), "Clone completed",
            sourceUri.toString());
}
项目:devhub-prototype    文件:GitRepositoryUtils.java   
@Override
public void setCustomTemplateInRepo(String repositoryUrl, String cloneRepo) {
    File tmpDir = Files.createTempDir();
    log.info("Creating clone in {}", tmpDir.getPath());
    try {
        Git git;
        if (cloneRepo == null) {
            git = copyDefaultTemplate(tmpDir);
        } else {
            git = cloneRepo(cloneRepo, tmpDir);
        }
        pushClonedRepoToOurRepository(repositoryUrl, git);

    } catch (IOException | JGitInternalException | GitAPIException | URISyntaxException e) {
        log.error("Could not instantiate repo", e);
        throw new DevHubException("Could not instantiate repo", e);
    } finally {
        boolean deleted = FileUtils.deleteQuietly(tmpDir);
        log.debug("Temporary template deletion succes = {}", deleted);
    }

}
项目:jgit-cookbook    文件:UpdateIndex.java   
@Override
public String call() throws GitAPIException {
    try {
        DirCache index = repo.lockDirCache();
        DirCacheEntry entry = index.getEntry(fileName);

        if (entry != null) {
            entry.setAssumeValid(assumeUnchanged);
            index.write();
            index.commit();
            return entry.getPathString();
        }
    } catch (IOException e) {
        throw new JGitInternalException(e.getMessage(), e);
    }

    return null;
}
项目:github-backup-java    文件:CreateOrphanBranchCommand.java   
@Override
public Ref call() throws GitAPIException, RefNotFoundException,
    CheckoutConflictException, InvalidRefNameException,
    RefAlreadyExistsException
{
    this.checkCallable();
    try {
        this.processOptions();
        this.checkoutStartPoint();
        RefUpdate update = this.getRepository().updateRef(Constants.HEAD);
        Result r = update.link(this.getBranchName());
        if (EnumSet.of(Result.NEW, Result.FORCED).contains(r) == false) {
            throw new JGitInternalException(MessageFormat.format(
                JGitText.get().checkoutUnexpectedResult, r.name()));
        }
        this.setCallable(false);
        return this.getRepository().getRef(Constants.HEAD);
    }
    catch (IOException e) {
        throw new JGitInternalException(e.getMessage(), e);
    }
}
项目:incubator-netbeans    文件:SubmoduleInitializeCommand.java   
@Override
protected void run () throws GitException {
    Repository repository = getRepository();
    File workTree = repository.getWorkTree();
    org.eclipse.jgit.api.SubmoduleInitCommand cmd = new Git(repository).submoduleInit();
    for (String path : Utils.getRelativePaths(workTree, roots)) {
        cmd.addPath(path);
    }
    try {
        cmd.call();
        statusCmd.run();
    } catch (GitAPIException | JGitInternalException ex) {
        throw new GitException(ex);
    }
}
项目:Black    文件:test.java   
/**
* push���ش��뵽Զ�ֿ̲��ַ
*/
@Test
public void testPush() throws IOException, JGitInternalException,
        GitAPIException {

    UsernamePasswordCredentialsProvider usernamePasswordCredentialsProvider =new
            UsernamePasswordCredentialsProvider(username,password);
    //git�ֿ��ַ
    Git git = new Git(new FileRepository(localPath+"/.git")); 

    git.push().setRemote(remotePath).setCredentialsProvider(usernamePasswordCredentialsProvider)
    .setPushAll()
    .call();
}
项目:plugins_github    文件:GitCloneFailedException.java   
private String getCauseDescription(Throwable cause) {
  if (cause == null) {
    return "";
  } else if (JGitInternalException.class.isAssignableFrom(cause.getClass())) {
    Throwable innerCause = cause.getCause();
    return innerCause != null ? getCauseDescription(cause.getCause()) : "JGit internal error";
  } else {
    return getDecamelisedName(cause);
  }
}
项目:editor-de-servicos    文件:RepositorioGit.java   
@SneakyThrows
public void commit(Path caminho, String mensagem, UserProfile profile) {
    PersonIdent ident = new PersonIdent(profile.getName(), profile.getEmail());
    try {
        RevCommit result = git.commit()
                .setMessage(mensagem)
                .setCommitter(ident)
                .setAuthor(ident)
                .setOnly(caminho.toString())
                .call();

        Marker marker = append("commit", result.getName())
                .and(append("commit.message", mensagem))
                .and(append("commit.author", ident.getName()))
                .and(append("commit.email", ident.getEmailAddress()))
                .and(append("commit.path", caminho.toString()))
                .and(append("git.branch", git.getRepository().getBranch()))
                .and(append("git.state", git.getRepository().getRepositoryState().toString()));

        log.info(marker, "git commit {}", caminho);

    } catch (JGitInternalException e) {
        if (e.getMessage().equals(JGitText.get().emptyCommit)) {
            log.info("Commit não possui alterações em {}", caminho);
        } else {
            throw e;
        }
    }
}
项目:mondo-collab-framework    文件:MondoGitHandler.java   
public void push(String projectName, String branchName, String username, String password) throws IOException, JGitInternalException,
    GitAPIException {
    CredentialsProvider cp = new UsernamePasswordCredentialsProvider(username, password);
    Iterable<PushResult> pushResult = getGitObject(projectName, branchName).getGitInstance().push().setCredentialsProvider(cp).call();
    System.out.println("Push result: ");
    for(PushResult res : pushResult) {
        System.out.println(res.toString());
    }
}
项目:mondo-collab-framework    文件:MondoGitHandler.java   
public void push(String projectName, String branchName, String username, String password) throws IOException, JGitInternalException,
    GitAPIException {
    CredentialsProvider cp = new UsernamePasswordCredentialsProvider(username, password);
    Iterable<PushResult> pushResult = getGitObject(projectName, branchName).getGitInstance().push().setCredentialsProvider(cp).call();
    System.out.println("Push result: ");
    for(PushResult res : pushResult) {
        System.out.println(res.toString());
    }
}
项目:ninja_chic-    文件:Pull.java   
private AnyObjectId commitToMergeFor(FetchResult fetchRes, String remoteBranchName, boolean remote) {
    // we check the updates to see which of the updated branches
    // corresponds
    // to the remote branch name
    AnyObjectId commitToMerge;
    if (remote) {
        Ref r = null;
        if (fetchRes != null) {
            r = fetchRes.getAdvertisedRef(remoteBranchName);
            if (r == null)
                r = fetchRes.getAdvertisedRef(R_HEADS + remoteBranchName);
        }
        if (r == null)
            throw new JGitInternalException(MessageFormat.format(JGitText
                    .get().couldNotGetAdvertisedRef, remoteBranchName));
        else
            commitToMerge = r.getObjectId();
    } else {
        try {
            commitToMerge = repo.resolve(remoteBranchName);
            if (commitToMerge == null)
                throw exceptionMessage(R.string.ref_not_resolved, remoteBranchName);
        } catch (IOException e) {
            throw new JGitInternalException(
                    JGitText.get().exceptionCaughtDuringExecutionOfPullCommand,
                    e);
        }
    }
    return commitToMerge;
}
项目:tools-idea    文件:GitHttpAdapter.java   
private static boolean smartHttpPushNotSupported(JGitInternalException e) {
  if (e.getCause() instanceof NotSupportedException) {
    NotSupportedException nse = (NotSupportedException)e.getCause();
    String message = nse.getMessage();
    return message != null && message.toLowerCase().contains("smart http push");
  }
  return false;
}
项目:git-server    文件:JGitRepositoryFacade.java   
@Override
public BlameModel blame(String commitId,
                        String filePath) throws IOException, GitException {

    Preconditions.checkNotNull(commitId);
    Preconditions.checkNotNull(filePath);

    try {
        BlameResult blameResult = git.blame()
            .setStartCommit(repo.resolve(commitId))
            .setFilePath(filePath)
            .setFollowFileRenames(true)
            .call();

        if(blameResult == null) {
            throw new NotFoundException(String.format("%s not found in %S at %s", filePath,
                repository.toString(), commitId));
        }

        return transformBlameModel(blameResult, commitId, filePath);
    }
    catch (JGitInternalException | GitAPIException e) {
        Throwable cause = e.getCause();
        if(MissingObjectException.class.isInstance(cause)) {
            throw new NotFoundException(cause.getMessage(), e);
        }
        throw new GitException(e);
    }
}
项目:devhub-prototype    文件:RepositoryDownloaderTest.java   
@Test
public void prepareDownloadWithoutError() throws IOException {
    Set<String> repositories = ImmutableSet.of(
            "git://github.com/octocat/Hello-World.git",
            "git://github.com/octocat/Spoon-Knife.git");
    try {
        RepositoryDownloader downloader = new RepositoryDownloader();
        String hash = downloader.prepareDownload(repositories);
        assertThat(hash, is(not(isEmptyOrNullString())));

        File f = downloader.getFile(hash);
        assertThat(f.exists(), is(true));
        String fileHash = getHashFromFile(f);
        assertThat(fileHash, is(hash));
        f.deleteOnExit();
    } catch (DevHubException e) {
        if (e.getCause() instanceof JGitInternalException) {
            LOG.warn("Test failed but it's ignore because it's probaply because some external URL is not working", e);
            /*
             * That's fine. Something is probably just wrong with the
             * connection. You might have to fix the test but it's not
             * definitive that the code is broken.
             */
            return;
        } else {
            throw e;
            // Unexpected exception. This is bad news.
        }
    }
}
项目:codemap    文件:JGitTest.java   
public void testTrackMaster() throws IOException, JGitInternalException, GitAPIException {     
    git.branchCreate() 
       .setName("master")
       .setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM)
       .setStartPoint("origin/master")
       .setForce(true)
       .call();
}
项目:git-client-plugin    文件:GitExceptionTest.java   
@Test
public void initJGitImplThrowsGitException() throws GitAPIException, IOException, InterruptedException {
    File badDirectory = new File("/this/is/a/bad/dir");
    if (isWindows()) {
        badDirectory = new File("\\\\badserver\\badshare\\bad\\dir");
    }
    GitClient defaultClient = Git.with(TaskListener.NULL, new EnvVars()).in(badDirectory).using("jgit").getClient();
    assertNotNull(defaultClient);
    thrown.expect(JGitInternalException.class);
    thrown.expectCause(is(IOException.class));
    defaultClient.init_().workspace(badDirectory.getAbsolutePath()).execute();
}
项目:git-client-plugin    文件:GitExceptionTest.java   
@Test
public void initJGitImplCollisionThrowsGitException() throws GitAPIException, IOException, InterruptedException {
    File dir = folder.getRoot();
    File dotGit = folder.newFile(".git");
    Files.write(dotGit.toPath(), "file named .git".getBytes("UTF-8"), APPEND);
    thrown.expect(JGitInternalException.class);
    thrown.expectCause(is(IOException.class));
    GitClient defaultClient = Git.with(TaskListener.NULL, new EnvVars()).in(dir).using("jgit").getClient();
    defaultClient.init_().workspace(dir.getAbsolutePath()).execute();
}
项目:SGit    文件:CheckoutTask.java   
public void checkoutFromRemote(String remoteBranchName, String branchName)
        throws GitAPIException, JGitInternalException, StopTaskException {
    mRepo.getGit().checkout().setCreateBranch(true).setName(branchName)
            .setStartPoint(remoteBranchName).call();
    mRepo.getGit()
            .branchCreate()
            .setUpstreamMode(
                    CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM)
            .setStartPoint(remoteBranchName).setName(branchName)
            .setForce(true).call();
}
项目:incubator-netbeans    文件:CherryPickCommand.java   
private void applySteps (List<RebaseTodoLine> steps, boolean skipFirstStep) throws GitAPIException, IOException {
    Repository repository = getRepository();
    ObjectReader or = repository.newObjectReader();
    CherryPickResult res = null;
    boolean skipped = false;
    List<Ref> cherryPickedRefs = new ArrayList<>();
    for (Iterator<RebaseTodoLine> it = steps.iterator(); it.hasNext();) {
        RebaseTodoLine step = it.next();
        if (step.getAction() == RebaseTodoLine.Action.PICK) {
            if (skipFirstStep && !skipped) {
                it.remove();
                writeTodoFile(repository, steps);
                skipped = true;
                continue;
            }
            Collection<ObjectId> ids = or.resolve(step.getCommit());
            if (ids.size() != 1) {
                throw new JGitInternalException("Could not resolve uniquely the abbreviated object ID");
            }
            org.eclipse.jgit.api.CherryPickCommand command = new Git(repository).cherryPick();
            command.include(ids.iterator().next());
            if (workAroundStrategyIssue) {
                command.setStrategy(new FailuresDetectRecurciveStrategy());
            }
            res = command.call();
            if (res.getStatus() == CherryPickResult.CherryPickStatus.OK) {
                it.remove();
                writeTodoFile(repository, steps);
                cherryPickedRefs.addAll(res.getCherryPickedRefs());
            } else {
                break;
            }
        } else {
            it.remove();
        }
    }
    if (res == null) {
        result = createCustomResult(GitCherryPickResult.CherryPickStatus.OK, cherryPickedRefs);
    } else {
        result = createResult(res, cherryPickedRefs);
    }
    if (steps.isEmpty()) {
        // sequencer no longer needed
        Utils.deleteRecursively(getSequencerFolder());
    }
}
项目:WebIDE-Backend    文件:ExceptionAdvice.java   
@ExceptionHandler(JGitInternalException.class)
@ResponseStatus(INTERNAL_SERVER_ERROR)
@ResponseBody
public JsonObject jGitInternalErrors(JGitInternalException e) {
    return makeMsg(e);
}
项目:mondo-collab-framework    文件:MondoGitHandler.java   
public void commit(String msg, String projectName, String branchName) throws IOException, GitAPIException,
    JGitInternalException {
    getGitObject(projectName, branchName).getGitInstance()
        .commit().setAll(true).setMessage(msg).call();
}
项目:mondo-collab-framework    文件:MondoGitHandler.java   
public void commit(String msg, String projectName, String branchName) throws IOException, GitAPIException,
    JGitInternalException {
    getGitObject(projectName, branchName).getGitInstance()
        .commit().setAll(true).setMessage(msg).call();
}
项目:tools-idea    文件:GitHttpAdapter.java   
private static boolean isTransportExceptionForHttp(@NotNull JGitInternalException e, @NotNull String url) {
  if (!(e.getCause() instanceof TransportException)) {
    return false;
  }
  return url.toLowerCase().startsWith("http") && !url.toLowerCase().startsWith("https");
}
项目:tools-idea    文件:GitHttpAdapter.java   
private static boolean authError(@NotNull JGitInternalException e) {
  Throwable cause = e.getCause();
  return (cause instanceof TransportException && cause.getMessage().contains("not authorized"));
}
项目:codemap    文件:JGitTest.java   
public void testCommit() throws IOException, JGitInternalException, UnmergedPathsException, GitAPIException {
    git.commit()
       .setMessage("Added myfile")
       .call();
}
项目:codemap    文件:JGitTest.java   
public void testPush() throws IOException, JGitInternalException, TransportException, GitAPIException {     
    git.push()
        .call();
}
项目:IRCBlit    文件:PushLogUtils.java   
/**
 * Updates a push log.
 * 
 * @param user
 * @param repository
 * @param commands
 * @return true, if the update was successful
 */
public static boolean updatePushLog(UserModel user, Repository repository,
        Collection<ReceiveCommand> commands) {
    RefModel pushlogBranch = getPushLogBranch(repository);
    if (pushlogBranch == null) {
        JGitUtils.createOrphanBranch(repository, GB_PUSHES, null);
    }

    boolean success = false;
    String message = "push";

    try {
        ObjectId headId = repository.resolve(GB_PUSHES + "^{commit}");
        ObjectInserter odi = repository.newObjectInserter();
        try {
            // Create the in-memory index of the push log entry
            DirCache index = createIndex(repository, headId, commands);
            ObjectId indexTreeId = index.writeTree(odi);

            PersonIdent ident = new PersonIdent(user.getDisplayName(), 
                    user.emailAddress == null ? user.username:user.emailAddress);

            // Create a commit object
            CommitBuilder commit = new CommitBuilder();
            commit.setAuthor(ident);
            commit.setCommitter(ident);
            commit.setEncoding(Constants.CHARACTER_ENCODING);
            commit.setMessage(message);
            commit.setParentId(headId);
            commit.setTreeId(indexTreeId);

            // Insert the commit into the repository
            ObjectId commitId = odi.insert(commit);
            odi.flush();

            RevWalk revWalk = new RevWalk(repository);
            try {
                RevCommit revCommit = revWalk.parseCommit(commitId);
                RefUpdate ru = repository.updateRef(GB_PUSHES);
                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;
                    break;
                case REJECTED:
                case LOCK_FAILURE:
                    throw new ConcurrentRefUpdateException(JGitText.get().couldNotLockHEAD,
                            ru.getRef(), rc);
                default:
                    throw new JGitInternalException(MessageFormat.format(
                            JGitText.get().updatingRefFailed, GB_PUSHES, commitId.toString(),
                            rc));
                }
            } finally {
                revWalk.release();
            }
        } finally {
            odi.release();
        }
    } catch (Throwable t) {
        error(t, repository, "Failed to commit pushlog entry to {0}");
    }
    return success;
}
项目:SGit    文件:CheckoutTask.java   
public void checkoutNewBranch(String name) throws GitAPIException,
        JGitInternalException, StopTaskException {
    mRepo.getGit().checkout().setName(name).setCreateBranch(true).call();
}
项目:SGit    文件:CheckoutTask.java   
public void checkoutFromLocal(String name) throws GitAPIException,
        JGitInternalException, StopTaskException {
    mRepo.getGit().checkout().setName(name).call();
}
项目:SGit    文件:CheckoutTask.java   
public void checkoutFromLocal(String name, String branch) throws GitAPIException,
 JGitInternalException, StopTaskException {
    mRepo.getGit().checkout().setCreateBranch(true).setName(branch)
            .setStartPoint(name).call();
}