Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.CherryPickResult


            cherryPickedRefs.add(src);
         }
         else
         {
            if (merger.failed())
               return new CherryPickResult(merger.getFailingPaths());

            // there are merge conflicts
            String message = new MergeMessageFormatter()
                     .formatWithConflicts(srcCommit.getFullMessage(),
                              merger.getUnmergedPaths());

            repo.writeCherryPickHead(srcCommit.getId());
            repo.writeMergeCommitMsg(message);

            return CherryPickResult.CONFLICT;
         }
      }
      catch (IOException e)
      {
         throw new JGitInternalException(
                  MessageFormat.format(
                           JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand,
                           e), e);
      }
      finally
      {
         revWalk.release();
      }

      return new CherryPickResult(newHead, cherryPickedRefs);
   }
View Full Code Here


   public void shouldNotCrashWhenCherryPickNoMergeIsCalledOnLastCommit() throws Exception
   {
      String[] branchNames = { "master" };
      String[] files = { "test1.txt" };
      List<String> commits = null;
      CherryPickResult cherryPickResult = null;

      Project project = projectFactory.createTempProject();
      Git repo = gitUtils.init(project.getRootDirectory());

      gitUtils.addAll(repo);
      gitUtils.commitAll(repo, "initial commit");

      FileResource<?> file0 = project.getRootDirectory().getChild(files[0]).reify(FileResource.class);
      file0.createNewFile();
      gitUtils.add(repo, files[0]);
      gitUtils.commit(repo, "file added on " + branchNames[0]);

      commits = gitUtils.getLogForCurrentBranch(repo);
      Assert.assertEquals("Wrong number of commits in log", 2, commits.size());
      cherryPickResult = gitUtils.cherryPickNoMerge(repo, repo.getRepository().getRef(branchNames[0]));
      Assert.assertEquals("Wrong cherrypick status", CherryPickResult.CherryPickStatus.OK, cherryPickResult.getStatus());
      gitUtils.resetHard(repo, "HEAD^1");

      commits = gitUtils.getLogForCurrentBranch(repo);
      Assert.assertEquals("Wrong number of commits in log", 1, commits.size());
      try {        
View Full Code Here

            cherryPickedRefs.add(src);
         }
         else
         {
            if (merger.failed())
               return new CherryPickResult(merger.getFailingPaths());

            // there are merge conflicts
            String message = new MergeMessageFormatter()
                     .formatWithConflicts(srcCommit.getFullMessage(),
                              merger.getUnmergedPaths());

            repo.writeCherryPickHead(srcCommit.getId());
            repo.writeMergeCommitMsg(message);

            return CherryPickResult.CONFLICT;
         }
      }
      catch (IOException e)
      {
         throw new JGitInternalException(
                  MessageFormat.format(
                           JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand,
                           e), e);
      }
      finally
      {
         revWalk.release();
      }

      return new CherryPickResult(newHead, cherryPickedRefs);
   }
View Full Code Here

            cherryPickedRefs.add(src);
         }
         else
         {
            if (merger.failed())
               return new CherryPickResult(merger.getFailingPaths());

            // there are merge conflicts
            String message = new MergeMessageFormatter()
                     .formatWithConflicts(srcCommit.getFullMessage(),
                              merger.getUnmergedPaths());

            repo.writeCherryPickHead(srcCommit.getId());
            repo.writeMergeCommitMsg(message);

            return CherryPickResult.CONFLICT;
         }
      }
      catch (IOException e)
      {
         throw new JGitInternalException(
                  MessageFormat.format(
                           JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand,
                           e), e);
      }
      finally
      {
         revWalk.release();
      }

      return new CherryPickResult(newHead, cherryPickedRefs);
   }
View Full Code Here

            "An error occured when cherry-picking.", null));
      RevCommit head = revWalk.parseCommit(headRef.getObjectId());

      ObjectId objectId = db.resolve(commitToCherryPick);
      Git git = new Git(db);
      CherryPickResult cherryPickResult = git.cherryPick().include(objectId).call();
      RevCommit newHead = cherryPickResult.getNewHead();

      JSONObject result = new JSONObject();
      result.put(GitConstants.KEY_RESULT, cherryPickResult.getStatus().name());
      result.put(GitConstants.KEY_HEAD_UPDATED, !head.equals(newHead));
      OrionServlet.writeJSONResponse(request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT);
      return true;
    } catch (IOException e) {
      return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
View Full Code Here

            cherryPickedRefs.add(src);
         }
         else
         {
            if (merger.failed())
               return new CherryPickResult(merger.getFailingPaths());

            // there are merge conflicts
            String message = new MergeMessageFormatter()
                     .formatWithConflicts(srcCommit.getFullMessage(),
                              merger.getUnmergedPaths());

            repo.writeCherryPickHead(srcCommit.getId());
            repo.writeMergeCommitMsg(message);

            return CherryPickResult.CONFLICT;
         }
      }
      catch (IOException e)
      {
         throw new JGitInternalException(
                  MessageFormat.format(
                           JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand,
                           e), e);
      }
      finally
      {
         revWalk.release();
      }

      return new CherryPickResult(newHead, cherryPickedRefs);
   }
View Full Code Here

            cherryPickedRefs.add(src);
         }
         else
         {
            if (merger.failed())
               return new CherryPickResult(merger.getFailingPaths());

            // there are merge conflicts
            String message = new MergeMessageFormatter()
                     .formatWithConflicts(srcCommit.getFullMessage(),
                              merger.getUnmergedPaths());

            repo.writeCherryPickHead(srcCommit.getId());
            repo.writeMergeCommitMsg(message);

            return CherryPickResult.CONFLICT;
         }
      }
      catch (IOException e)
      {
         throw new JGitInternalException(
                  MessageFormat.format(
                           JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand,
                           e), e);
      }
      finally
      {
         revWalk.release();
      }

      return new CherryPickResult(newHead, cherryPickedRefs);
   }
View Full Code Here

            cherryPickedRefs.add(src);
         }
         else
         {
            if (merger.failed())
               return new CherryPickResult(merger.getFailingPaths());

            // there are merge conflicts
            String message = new MergeMessageFormatter()
                     .formatWithConflicts(srcCommit.getFullMessage(),
                              merger.getUnmergedPaths());

            repo.writeCherryPickHead(srcCommit.getId());
            repo.writeMergeCommitMsg(message);

            return CherryPickResult.CONFLICT;
         }
      }
      catch (IOException e)
      {
         throw new JGitInternalException(
                  MessageFormat.format(
                           JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand,
                           e), e);
      }
      finally
      {
         revWalk.release();
      }

      return new CherryPickResult(newHead, cherryPickedRefs);
   }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.api.CherryPickResult

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.