• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PullRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: seenReviewers

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
public Set<String> seenReviewers(PullRequest pr) {
  Set<String> required = newHashSet(concat(config.getRequiredReviewers(), utils.dereferenceGroups(config.getRequiredReviewerGroups())));
  return difference(required, missingRevieiwers(pr));
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:5,代码来源:PullRequestApproval.java


示例17: transformReviewers

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
Map<String, PullRequestParticipant> transformReviewers(PullRequest pr) {
  return uniqueIndex(pr.getReviewers(), input -> input.getUser().getSlug());
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:4,代码来源:PullRequestApproval.java


示例18: submitterIsRequiredReviewer

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
Boolean submitterIsRequiredReviewer(PullRequest pr, String username) {
  return pr.getAuthor().getUser().getSlug().equals(username);
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:4,代码来源:PullRequestApproval.java


示例19: ApprovalTaskProcessor

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
public ApprovalTaskProcessor(PullRequest pr) {
  this.pr = pr;
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:4,代码来源:PullRequestListener.java


示例20: shouldDisplay

import com.atlassian.bitbucket.pull.PullRequest; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean shouldDisplay(Map<String, Object> context) {
  final Object obj = context.get(REPOSITORY);
  final Object pr = context.get("pullRequest");

  
  if (obj == null || !(obj instanceof Repository))
    return false;
  
  if (pr == null || !(pr instanceof PullRequest))
    return false;    
  
  Repository repo = (Repository) obj;
  PullRequest pullrequest = (PullRequest) pr;
  RepositoryHook hook = settingsService.getRepositoryHook(repo);
  Settings settings = settingsService.getSettings(repo);

  if (settings == null) {
    return false;
  }

  // check if builds are configured
  PullRequestRef ref = pullrequest.getFromRef();
  String branch = ref.getId();
      
  String root = settings.getString("featureRule", "");
  Boolean isConfigured = false;
  if(!root.isEmpty() && 
      (branch.toLowerCase().startsWith("refs/heads/feature/") || 
       branch.toLowerCase().startsWith("feature/"))) {
    isConfigured = true;
  }
  
  root = settings.getString("bugFixRule", "");
  if(!root.isEmpty() && 
      (branch.toLowerCase().startsWith("refs/heads/bugfix/") || 
       branch.toLowerCase().startsWith("bugfix/"))) {
    isConfigured = true;
  }

  root = settings.getString("hotfixRule", "");
  if(!root.isEmpty() && 
      (branch.toLowerCase().startsWith("refs/heads/hotfix/") || 
       branch.toLowerCase().startsWith("hotfix/"))) {
    isConfigured = true;
  }    
          
  return !(hook == null || !hook.isEnabled() || settings == null || !isConfigured);
}
 
开发者ID:TrimbleSolutionsCorporation,项目名称:TeamcityTriggerHook,代码行数:53,代码来源:WebhookIsEnabledCondition.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SuggestRequestBuilder类代码示例发布时间:2022-05-22
下一篇:
Java TransientObjectException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap