當前位置: 首頁>>代碼示例>>Java>>正文


Java GHRepository.hasPullAccess方法代碼示例

本文整理匯總了Java中org.kohsuke.github.GHRepository.hasPullAccess方法的典型用法代碼示例。如果您正苦於以下問題:Java GHRepository.hasPullAccess方法的具體用法?Java GHRepository.hasPullAccess怎麽用?Java GHRepository.hasPullAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.kohsuke.github.GHRepository的用法示例。


在下文中一共展示了GHRepository.hasPullAccess方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: withPermission

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
private NullSafePredicate<GitHub> withPermission(final GitHubRepositoryName name, GHPermission permission) {
    return new NullSafePredicate<GitHub>() {
        @Override
        protected boolean applyNullSafe(@Nonnull GitHub gh) {
            try {
                final GHRepository repo = gh.getRepository(name.getUserName() + "/" + name.getRepositoryName());
                if (permission == GHPermission.ADMIN) {
                    return repo.hasAdminAccess();
                } else if (permission == GHPermission.PUSH) {
                    return repo.hasPushAccess();
                } else {
                    return repo.hasPullAccess();
                }
            } catch (IOException e) {
                return false;
            }
        }
    };
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:20,代碼來源:GitHubPluginRepoProvider.java

示例2: doAction

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
@Override
public void doAction(
    IdentifiedUser user,
    GitHubLogin hubLogin,
    HttpServletRequest req,
    HttpServletResponse resp,
    ControllerErrors errors)
    throws ServletException, IOException {
  String organisation = req.getParameter("organisation");

  JsonArray jsonRepos = new JsonArray();
  int numRepos = 0;
  PagedIterator<GHRepository> repoIter = getRepositories(hubLogin, organisation).iterator();

  while (repoIter.hasNext() && numRepos < config.repositoryListLimit) {
    GHRepository ghRepository = repoIter.next();
    if (ghRepository.hasPushAccess() && ghRepository.hasPullAccess()) {
      JsonObject repository = new JsonObject();
      String projectName = organisation + "/" + ghRepository.getName();
      if (projects.get(Project.NameKey.parse(projectName)) == null) {
        repository.add("name", new JsonPrimitive(ghRepository.getName()));
        repository.add("organisation", new JsonPrimitive(organisation));
        repository.add(
            "description", new JsonPrimitive(Strings.nullToEmpty(ghRepository.getDescription())));
        repository.add("private", new JsonPrimitive(new Boolean(ghRepository.isPrivate())));
        jsonRepos.add(repository);
        numRepos++;
      }
    } else {
      log.warn(
          "Skipping repository {} because user {} has no push/pull access to it",
          ghRepository.getName(),
          user.getUserName());
    }
  }

  resp.getWriter().println(jsonRepos.toString());
}
 
開發者ID:GerritCodeReview,項目名稱:plugins_github,代碼行數:39,代碼來源:RepositoriesListController.java

示例3: doCheckRepoAccess

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
public FormValidation doCheckRepoAccess(
        @QueryParameter("serverAPIUrl") final String serverAPIUrl, 
        @QueryParameter("credentialsId") final String credentialsId,
        @QueryParameter("repo") final String repo) {
    try {
        GitHubBuilder builder = getBuilder(null, serverAPIUrl, credentialsId);
        if (builder == null) {
            return FormValidation.error("Unable to look up GitHub credentials using ID: " + credentialsId + "!!");
        }
        GitHub gh = builder.build();
        GHRepository repository = gh.getRepository(repo);
        StringBuilder sb = new StringBuilder();
        sb.append("User has access to: ");
        List<String> permissions = new ArrayList<String>(3);
        if (repository.hasAdminAccess()) {
            permissions.add("Admin");
        }
        if (repository.hasPushAccess()) {
            permissions.add("Push");
        }
        if (repository.hasPullAccess()) {
            permissions.add("Pull");
        }
        sb.append(Joiner.on(", ").join(permissions));
        
        return FormValidation.ok(sb.toString());
    } catch (Exception ex) {
        return FormValidation.error("Unable to connect to GitHub API: " + ex);
    }
}
 
開發者ID:bratchenko,項目名稱:jenkins-github-pull-request-comments,代碼行數:31,代碼來源:GhprcGitHubAuth.java


注:本文中的org.kohsuke.github.GHRepository.hasPullAccess方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。