当前位置: 首页>>代码示例>>Java>>正文


Java PullRequest类代码示例

本文整理汇总了Java中com.atlassian.bitbucket.pull.PullRequest的典型用法代码示例。如果您正苦于以下问题:Java PullRequest类的具体用法?Java PullRequest怎么用?Java PullRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PullRequest类属于com.atlassian.bitbucket.pull包,在下文中一共展示了PullRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: check

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
@Override
public void check(@Nonnull MergeRequest mergeRequest) {
  PullRequest pr = mergeRequest.getPullRequest();
  Repository repo = pr.getToRef().getRepository();
  final Config config = configDao.getConfigForRepo(repo.getProject().getKey(), repo.getSlug());

  String branch = regexUtils.formatBranchName(pr.getToRef().getId());
  if (regexUtils.match(config.getBlockedPRs(), branch)) {
    mergeRequest.veto("Pull Request Blocked", "Pull requests have been disabled for branch [" + branch + "]");
  } else {
    PullRequestApproval approval = new PullRequestApproval(config, userUtils);
    if (!approval.isPullRequestApproved(pr)) {
      Set<String> missing = approval.missingRevieiwersNames(pr);
      mergeRequest.veto("Required reviewers must approve", (config.getRequiredReviews() - approval.seenReviewers(pr).size()) +
          " more approvals required from the following users: " + Joiner.on(", ").join(missing));
    } else {
      Boolean needsWork = config.getBlockMergeIfPrNeedsWork();
      final Boolean blockAutoMergeBecausePrNeedsWork = needsWork != null && needsWork && needsWork(pr);

      if (blockAutoMergeBecausePrNeedsWork) {
        mergeRequest.veto("Needs work", "PR marked as Needs Work from reviewer(s)");
      }
    }
  }
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:26,代码来源:MergeBlocker.java

示例2: findPRByCommitId

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
PullRequest findPRByCommitId(String commitId) {
  PullRequestSearchRequest request = new PullRequestSearchRequest.Builder()
      .state(PullRequestState.OPEN)
      .withProperties(false)
      .build();
  PageRequest nextPage = new PageRequestImpl(0, SEARCH_PAGE_SIZE);
  do {
    Page<PullRequest> page = prService.search(request, nextPage);
    PullRequest pr = searchForPR(page, commitId);
    if(pr != null) {
      return pr;
    } else {
      nextPage = page.getNextPageRequest();
    }
  } while(nextPage != null);
  return null;
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:18,代码来源:PullRequestListener.java

示例3: onPullRequestReopened

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
@EventListener
public void onPullRequestReopened(PullRequestReopenedEvent event)
{
    PullRequest pullRequest = event.getPullRequest();
    if (pullRequest.getFromRef().getLatestCommit().equals(event.getPreviousFromHash()) &&
            pullRequest.getToRef().getLatestCommit().equals(event.getPreviousToHash()))
    {
        // If the PullRequest's from and to refs were not updated when it was reopend, trigger webhooks
        // for the update. Otherwise, if _either_ ref changed, a rescope event will also be raised. Let
        // that trigger webhooks instead, to ensure the pull request's refs are updated on disk
        sendPullRequestEvent(event, EventType.PULL_REQUEST_REOPENED);
    }
}
 
开发者ID:Eernie,项目名称:bitbucket-webhooks-plugin,代码行数:14,代码来源:PullRequestListener.java

示例4: sendPullRequestEvent

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
private void sendPullRequestEvent(PullRequestEvent event, EventType eventType, boolean updateRefs)
{
    executorService.submit(() -> {
        PullRequest pullRequest = event.getPullRequest();
        if (updateRefs && pullRequest.isOpen())
        {
            try
            {
                ScmPullRequestCommandFactory pullRequestCommandFactory = scmService.getPullRequestCommandFactory(pullRequest);
                Command<?> command;
                if (useCanMerge)
                {
                    /*
                    This is to support version from 4.5.x - 4.9.x
                    Once we only support from 4.10.x and beyond we can remove this.
                     */
                    command = pullRequestCommandFactory.canMerge();
                }
                else
                {
                    command = pullRequestCommandFactory.tryMerge(pullRequest);
                }
                command.call();
            }
            catch (ServiceException e)
            {
                LOGGER.warn("{}: Mergeability check failed; pull request refs may not be up-to-date", pullRequest, e);
            }
        }

        Repository repository = pullRequest.getToRef().getRepository();
        String prUrl = navBuilder.repo(repository).pullRequest(pullRequest.getId()).buildAbsolute();

        BitbucketServerPullRequestEvent pullRequestEvent =
                Events.createPullrequestEvent(event, applicationPropertiesService);
        pullRequestEvent.getPullrequest().setLink(prUrl);

        sendEvents(pullRequestEvent, repository, eventType);
    });
}
 
开发者ID:Eernie,项目名称:bitbucket-webhooks-plugin,代码行数:41,代码来源:PullRequestListener.java

示例5: createPullrequest

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
public static BitbucketServerPullRequest createPullrequest(PullRequest pullRequest,
                                                           ApplicationPropertiesService appPropSvc)
{
    BitbucketServerPullRequest pullRequestType = new BitbucketServerPullRequest();
    pullRequestType.setId(String.valueOf(pullRequest.getId()));
    pullRequestType.setFromRef(createSource(pullRequest.getFromRef(), appPropSvc));
    pullRequestType.setToRef(createSource(pullRequest.getToRef(), appPropSvc));
    pullRequestType.setTitle(pullRequest.getTitle());
    pullRequestType.setAuthorLogin(pullRequest.getAuthor().getUser().getDisplayName());
    return pullRequestType;
}
 
开发者ID:Eernie,项目名称:bitbucket-webhooks-plugin,代码行数:12,代码来源:Models.java

示例6: check

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
public void check(@Nonnull MergeRequest mergeRequest) {
    PullRequest pullRequest = mergeRequest.getPullRequest();
    long commits = pullRequestService.countCommits(pullRequest.getToRef().getRepository().getId(), pullRequest.getId());
    if (pullRequestSquashSettings.isEnabled(pullRequest.getToRef().getRepository()) && commits > 1) {
        mergeRequest.veto(i18Service.getMessage("org.christiangalsterer.bitbucket.server.prsquash.prsquashmergecheck.summary"), i18Service.getMessage("org.christiangalsterer.bitbucket.server.prsquash.prsquashmergecheck.detailed"));
    }
}
 
开发者ID:christiangalsterer,项目名称:bitbucket-prsquash-plugin,代码行数:8,代码来源:PullRequestSquashMergeRequestCheck.java

示例7: missingRevieiwers

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
public Set<String> missingRevieiwers(PullRequest pr) {
  Map<String, PullRequestParticipant> map = transformReviewers(pr);
  Set<String> missingReviewers = newHashSet();

  for(String req : concat(config.getRequiredReviewers(), utils.dereferenceGroups(config.getRequiredReviewerGroups()))) {
    if(reviewerIsMissing(map.get(req.toLowerCase())) && !(submitterIsRequiredReviewer(pr, req.toLowerCase()) && exactlyEnoughRequiredReviewers())) {
      missingReviewers.add(req);
    }
  }
  return missingReviewers;
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:12,代码来源:PullRequestApproval.java

示例8: missingRevieiwersNames

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
public Set<String> missingRevieiwersNames(PullRequest pr) {
   Map<String, PullRequestParticipant> map = transformReviewers(pr);
   Set<String> missingReviewers = newHashSet();

   for(String req : concat(config.getRequiredReviewers(), utils.dereferenceGroups(config.getRequiredReviewerGroups()))) {
      if(reviewerIsMissing(map.get(req.toLowerCase())) && !(submitterIsRequiredReviewer(pr, req.toLowerCase()) && exactlyEnoughRequiredReviewers())) {
      missingReviewers.add(utils.getUserDisplayNameByName(req));
   }
}
return missingReviewers;
 }
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:12,代码来源:PullRequestApproval.java

示例9: automergePullRequest

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
void automergePullRequest(PullRequest pr) {
  Repository repo = pr.getToRef().getRepository();
  Config config = configDao.getConfigForRepo(repo.getProject().getKey(), repo.getSlug());
  String toBranch = regexUtils.formatBranchName(pr.getToRef().getId());
  String fromBranch = regexUtils.formatBranchName(pr.getFromRef().getId());

  if((regexUtils.match(config.getAutomergePRs(), toBranch) || regexUtils.match(config.getAutomergePRsFrom(), fromBranch)) &&
      !regexUtils.match(config.getBlockedPRs(), toBranch) && prService.canMerge(repo.getId(), pr.getId()).canMerge()) {
    securityService.impersonating(pr.getAuthor().getUser(), "Performing automerge on behalf of " + pr.getAuthor().getUser().getSlug()).call(() -> {
      prService.merge(new PullRequestMergeRequest.Builder(pr).build());
      return null;
    });
  }
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:15,代码来源:PullRequestListener.java

示例10: searchForPR

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
private PullRequest searchForPR(Page<PullRequest> requests, String commitId) {
  for(PullRequest pr : requests.getValues()) {
    AtomicBoolean found = new AtomicBoolean(false);
    prService.streamCommits(pr.getToRef().getRepository().getId(), pr.getId(), commit -> {
      found.set(commit.getId().equals(commitId));
      return !found.get();
    });
    if(found.get()) {
      return pr;
    }
  }
  return null;
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:14,代码来源:PullRequestListener.java

示例11: run

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
@Override
public void run() {
  securityService.withPermission(Permission.ADMIN, "Automerge check (PR approval)").call(() -> {
    PullRequest pr = findPRByCommitId(commitId);
    if(pr != null) {
      automergePullRequest(pr);
    }
    return null;
  });
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:11,代码来源:PullRequestListener.java

示例12: check

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
@Override
public void check(RepositoryMergeRequestCheckContext context) {
	final MergeRequest request = context.getMergeRequest();
	final PullRequest pr = request.getPullRequest();
	final Commit prFrom = getChangeSet(pr.getFromRef());
	final Commit prTo = getChangeSet(pr.getToRef());
	final Commit base = mergeBaseResolver.findMergeBase(prFrom, prTo);
    final FileNameHookSetting setting = getSettings(context.getSettings());
    
	final ChangesRequest.Builder builder = new ChangesRequest.Builder(prFrom.getRepository(), prFrom.getId()); 
       if (base.getId() != null) { 
           builder.sinceId(base.getId()); 
       } 
       final ChangesRequest pathsRequest = builder.build(); 
       final ChangedPathsCollector pathsCallback = new ChangedPathsCollector();
       commitService.streamChanges(pathsRequest, pathsCallback);
    Collection<String> filteredFiles = pathsCallback.getChangedPaths();
       filteredFiles = filteredFiles.stream().filter(setting.getIncludePattern().asPredicate()).collect(Collectors.toList());
	 
	if(setting.getExcludePattern().isPresent()) {
		 Pattern excludePattern = setting.getExcludePattern().get();
		 filteredFiles = filteredFiles.stream().filter(excludePattern.asPredicate().negate()).collect(Collectors.toList());
	}
    
    if (filteredFiles.size() > 0) {
        request.veto(i18n.getText("filename-hook.mergecheck.veto", "File Name Hook: The following files violate the file name pattern [{0}]:", setting.getIncludePattern().pattern()), getPullRequestError(filteredFiles));
    }     
}
 
开发者ID:christiangalsterer,项目名称:stash-filehooks-plugin,代码行数:29,代码来源:FileNameHook.java

示例13: HandlePullRequestEvent

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
private void HandlePullRequestEvent(PullRequest pullRequest)
  {
  	Repository repository = pullRequest.getToRef().getRepository();
  	String ref = "refs/pull-requests/" + Long.toString(pullRequest.getId());

repositoryInformationService.PostChange(repository,
		ref,
		pullRequest.getFromRef().getLatestCommit(),
		pullRequest.getToRef().getId(),
		Long.toString(pullRequest.getId()));
  }
 
开发者ID:wparad,项目名称:stash-http-request-trigger,代码行数:12,代码来源:PostReceiveHook.java

示例14: getContextMap

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
@Override
public Map<String, Object> getContextMap(Map<String, Object> context) 
{
	Repository repository = (Repository)context.get("repository");
	PullRequest pullRequest = (PullRequest)context.get("pullRequest");
   	String ref = "refs/pull-requests/" + Long.toString(pullRequest.getId());
   	String buildUrl = repositoryInformationService.GetPullRequestUrl(repository,
   			ref,
   			pullRequest.getFromRef().getLatestCommit(),
   			pullRequest.getToRef().getId(),
   			Long.toString(pullRequest.getId()),
   			true);
   	return ImmutableMap.<String, Object>builder().put("buildUrl", buildUrl).build();
}
 
开发者ID:wparad,项目名称:stash-http-request-trigger,代码行数:15,代码来源:RepositoryContextProvider.java

示例15: isPullRequestApproved

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
public boolean isPullRequestApproved(PullRequest pr) {
  Integer requiredReviews = config.getRequiredReviews();
  return requiredReviews == null || seenReviewers(pr).size() >= requiredReviews;
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:5,代码来源:PullRequestApproval.java


注:本文中的com.atlassian.bitbucket.pull.PullRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。