Exemple #1
0
 @Override
 public boolean isEnabled() {
   GitRepository repo = getSelectedRepository();
   if (repo == null) return false;
   String[] commits = repo.commitsAhead(repo.currentBranch());
   return commits != null && commits.length > 0;
 }
Exemple #2
0
 private boolean isHerokuProject(IProject selectedProject) {
   GitRepository repo =
       GitPlugin.getDefault().getGitRepositoryManager().getAttached(selectedProject);
   if (repo != null) {
     for (String remote : repo.remotes()) {
       if (remote.indexOf("heroku") != -1) // $NON-NLS-1$
       {
         return true;
       }
     }
     for (String remoteURL : repo.remoteURLs()) {
       if (remoteURL.indexOf("heroku.com") != -1) // $NON-NLS-1$
       {
         return true;
       }
     }
   }
   return false;
 }
Exemple #3
0
  @SuppressWarnings("unchecked")
  public IGithubPullRequest createPullRequest(
      String title, String body, GitRepository repo, IProgressMonitor monitor)
      throws CoreException {
    SubMonitor sub =
        SubMonitor.convert(monitor, Messages.GithubRepository_GeneratingPRTaskName, 100);
    String branch = repo.currentBranch();

    // push current branch to origin first!
    sub.subTask(Messages.GithubRepository_PushingBranchSubtaskName);
    IStatus pushStatus = repo.push(GitRepository.ORIGIN, branch);
    sub.worked(50);
    if (!pushStatus.isOK()) {
      throw new CoreException(pushStatus);
    }

    sub.subTask(Messages.GithubRepository_SubmittingPRSubtaskName);
    IGithubRepository parent = getParent();
    JSONObject prObject = new JSONObject();
    prObject.put("title", title); // $NON-NLS-1$
    prObject.put("body", body); // $NON-NLS-1$
    // TODO Allow user to choose branch on the fork to use as contents for PR?
    prObject.put("head", getOwner() + ':' + branch); // $NON-NLS-1$
    // FIXME Allow user to choose the branch from parent to merge against. Default to the parent's
    // default
    // branch
    prObject.put("base", parent.getDefaultBranch()); // $NON-NLS-1$

    JSONObject result =
        (JSONObject)
            getAPI()
                .post(
                    ((GithubRepository) parent).getAPIURL() + "/pulls",
                    prObject.toJSONString()); // $NON-NLS-1$
    return new GithubPullRequest(result);
  }
 private ChangedFile getChangedFile(GitRepository repo, IResource resource) {
   return repo.getChangedFileForResource(resource);
 }
Exemple #5
0
 @Override
 protected void doOperation(GitRepository repo, List<ChangedFile> changedFiles) {
   repo.index().stageFiles(changedFiles);
 }