Ejemplo n.º 1
0
  private IStatus doClone() {
    try {
      File cloneFolder = new File(clone.getContentLocation().getPath());
      if (!cloneFolder.exists()) {
        cloneFolder.mkdir();
      }
      CloneCommand cc = Git.cloneRepository();
      cc.setBare(false);
      cc.setCredentialsProvider(credentials);
      cc.setDirectory(cloneFolder);
      cc.setRemote(Constants.DEFAULT_REMOTE_NAME);
      cc.setURI(clone.getUrl());
      Git git = cc.call();

      // Configure the clone, see Bug 337820
      setMessage(NLS.bind("Configuring {0}...", clone.getUrl()));
      GitCloneHandlerV1.doConfigureClone(git, user);
      git.getRepository().close();
    } catch (IOException e) {
      return new Status(IStatus.ERROR, GitActivator.PI_GIT, "Error cloning git repository", e);
    } catch (CoreException e) {
      return e.getStatus();
    } catch (GitAPIException e) {
      return getGitAPIExceptionStatus(e, "Error cloning git repository");
    } catch (JGitInternalException e) {
      return getJGitInternalExceptionStatus(e, "Error cloning git repository");
    } catch (Exception e) {
      return new Status(IStatus.ERROR, GitActivator.PI_GIT, "Error cloning git repository", e);
    }
    return Status.OK_STATUS;
  }
Ejemplo n.º 2
0
 @Override
 protected IStatus performJob() {
   IStatus result = doClone();
   if (result.isOK()) {
     return result;
   } else {
     try {
       if (project != null) GitCloneHandlerV1.removeProject(user, project);
       else FileUtils.delete(URIUtil.toFile(clone.getContentLocation()), FileUtils.RECURSIVE);
     } catch (IOException e) {
       String msg = "An error occured when cleaning up after a clone failure";
       result =
           new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e);
     }
     return result;
   }
 }