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


Java GHRepository類代碼示例

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


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

示例1: readGHRepo

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
public static Optional<GHRepository> readGHRepo() {
	try {
		GitHub github = GitHub.connect();
		String desiredRepo = System.getProperty("GITHUB_REPOSITORY");
		System.out.println("Desired Repo:" + desiredRepo);
		GHRepository repo = github.getRepository(desiredRepo);
		return Optional.of(repo);
	} catch (Exception e) {
		for (Object o : System.getProperties().keySet()) {
			System.out.println(o + ":" + System.getProperty(o + ""));
		}

		for (String env : System.getenv().keySet()) {
			System.out.println(env + ":" + System.getenv(env));
		}
		e.printStackTrace();
		return Optional.empty();
	}
}
 
開發者ID:eraether,項目名稱:WatchWordBot,代碼行數:20,代碼來源:Runner.java

示例2: deleteWebhook

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void deleteWebhook(final GitRepository repository, GitHook webhook) throws IllegalArgumentException {
    if (repository == null) {
        throw new IllegalArgumentException("repository must be specified");
    }
    if (webhook == null) {
        throw new IllegalArgumentException("webhook must be specified");
    }
    final GHRepository repo;
    try {
        repo = delegate.getRepository(repository.getFullName());

        for (GHHook hook : repo.getHooks()) {
            if (hook.getConfig().get(WEBHOOK_URL).equals(webhook.getUrl())) {
                hook.delete();
                break;
            }
        }
    } catch (final GHFileNotFoundException ghe) {
        throw new NoSuchRepositoryException("Could not remove webhooks from specified repository "
                                                    + repository.getFullName() + " because it could not be found or there is no webhooks for that repository.");
    } catch (final IOException ioe) {
        throw new RuntimeException("Could not remove webhooks from " + repository.getFullName(), ioe);
    }
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:29,代碼來源:KohsukeGitHubServiceImpl.java

示例3: deleteRepository

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void deleteRepository(final String repositoryName) throws IllegalArgumentException {
    if (repositoryName == null) {
        throw new IllegalArgumentException("repositoryName must be specified");
    }
    try {
        final GHRepository repo = delegate.getRepository(repositoryName);
        log.fine("Deleting repo at " + repo.gitHttpTransportUrl());
        repo.delete();
    } catch (final GHFileNotFoundException ghe) {
        log.log(Level.SEVERE, "Error while deleting repository " + repositoryName, ghe);
        throw new NoSuchRepositoryException("Could not remove repository "
                                                    + repositoryName + " because it could not be found.");
    } catch (final IOException ioe) {
        log.log(Level.SEVERE, "Error while deleting repository " + repositoryName, ioe);
        throw new RuntimeException("Could not remove " + repositoryName, ioe);
    }
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:22,代碼來源:KohsukeGitHubServiceImpl.java

示例4: GitRepositoryDTO

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
public GitRepositoryDTO(String key, GHRepository repository) {
    this.id = key;
    this.name = repository.getName();
    if (Strings.isNullOrBlank(name)) {
        name = repository.getFullName();
    }
    if (Strings.isNullOrBlank(name)) {
        name = key;
    }
    description = repository.getDescription();
    if (Strings.isNullOrBlank(description) || key.equals(description)) {
        try {
            description = createdAtText(repository.getCreatedAt());
        } catch (IOException e) {
            // ignore
        }
    }
    if (Strings.isNullOrBlank(description)) {
        description = repository.getHomepage();
    }
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:22,代碼來源:GitRepositoryDTO.java

示例5: createRepository

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
public GHRepository createRepository(String orgName, String repoName, String description) throws IOException {
    GHCreateRepositoryBuilder builder;
    if (Strings.isNullOrBlank(orgName) || orgName.equals(details.getUsername())) {
        builder = github.createRepository(repoName);
    } else {
        builder = github.getOrganization(orgName).createRepository(repoName);
    }
    // TODO link to the space URL?
    builder.private_(false)
            .homepage("")
            .issues(false)
            .downloads(false)
            .wiki(false);

    if (Strings.isNotBlank(description)) {
        builder.description(description);
    }
    return builder.create();
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:20,代碼來源:GitHubFacade.java

示例6: createWebHook

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
public void createWebHook(WebHookDetails webhook) throws IOException {
    String repoName = webhook.getRepositoryName();


    String orgName = webhook.getGitOwnerName();
    GHRepository repository = github.getRepository(orgName + "/" + repoName);
    String webhookUrl = webhook.getWebhookUrl();

    removeOldWebHooks(repository, webhookUrl);

    Map<String, String> config = new HashMap<>();
    config.put("url", webhookUrl);
    config.put("insecure_ssl", "1");
    config.put("content_type", "json");
    config.put("secret", webhook.getSecret());
    List<GHEvent> events = new ArrayList<>();
    events.add(GHEvent.PUSH);
    events.add(GHEvent.PULL_REQUEST);
    events.add(GHEvent.ISSUE_COMMENT);
    GHHook hook = repository.createHook("web", config, events, true);
    if (hook != null) {
        LOG.info("Created WebHook " + hook.getName() + " with ID " + hook.getId() + " for " + repository.getFullName() + " on URL " + webhookUrl);
    }
    //registerGitWebHook(details, webhook.getWebhookUrl(), webhook.getGitOwnerName(), repoName, webhook.getSecret());
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:26,代碼來源:GitHubFacade.java

示例7: loadCommandsFromPullRequest

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
/**
 * Lets load the old command context from comments on the PullRequest so that we can re-run a command to rebase things.
 */
protected CompositeCommand loadCommandsFromPullRequest(CommandContext context, GHRepository ghRepository, GHPullRequest pullRequest) throws IOException {
    List<GHIssueComment> comments = pullRequest.getComments();
    String lastCommand = null;
    for (GHIssueComment comment : comments) {
        String command = updateBotCommentCommand(context, comment);
        if (command != null) {
            lastCommand = command;
        }
    }
    if (lastCommand == null) {
        context.warn(LOG, "No UpdateBot comment found on pull request " + pullRequest.getHtmlUrl() + " so cannot rebase!");
        return null;
    }
    return parseUpdateBotCommandComment(context, lastCommand);
}
 
開發者ID:fabric8-updatebot,項目名稱:updatebot,代碼行數:19,代碼來源:UpdatePullRequests.java

示例8: waitForPullRequestToHaveMergable

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
public static Boolean waitForPullRequestToHaveMergable(GHPullRequest pullRequest, long sleepMS, long maximumTimeMS) throws IOException {
    long end = System.currentTimeMillis() + maximumTimeMS;
    while (true) {
        Boolean mergeable = pullRequest.getMergeable();
        if (mergeable == null) {
            GHRepository repository = pullRequest.getRepository();
            int number = pullRequest.getNumber();
            pullRequest = repository.getPullRequest(number);
            mergeable = pullRequest.getMergeable();
        }
        if (mergeable != null) {
            return mergeable;
        }
        if (System.currentTimeMillis() > end) {
            return null;
        }
        try {
            Thread.sleep(sleepMS);
        } catch (InterruptedException e) {
            // ignore
        }
    }
}
 
開發者ID:fabric8-updatebot,項目名稱:updatebot,代碼行數:24,代碼來源:GitHubHelpers.java

示例9: initializeRepos

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
public static void initializeRepos(GHOrganization org, List<String> repos, String image,
                                   List<GHRepository> createdRepos, GitHubUtil gitHubUtil) throws Exception {
    for (String repoName : repos) {
        GHRepository repo = org.createRepository(repoName)
                .description("Delete if this exists. If it exists, then an integration test crashed somewhere.")
                .private_(false)
                .create();
        // Ensure that repository exists
        for (int attempts = 0; attempts < 5; attempts++) {
            try {
                repo = gitHubUtil.getRepo(repo.getFullName());
                break;
            } catch (Exception e) {
                log.info("Waiting for {} to be created", repo.getFullName());
                Thread.sleep(TimeUnit.SECONDS.toMillis(1));
            }
        }

        repo.createContent("FROM " + image + ":test", "Integration Testing", "Dockerfile");
        createdRepos.add(repo);
        log.info("Initializing {}/{}", org.getLogin(), repoName);
        gitHubUtil.tryRetrievingContent(repo, "Dockerfile", repo.getDefaultBranch());
    }
}
 
開發者ID:salesforce,項目名稱:dockerfile-image-update,代碼行數:25,代碼來源:TestCommon.java

示例10: checkAndDelete

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
private static List<Exception> checkAndDelete(List<GHRepository> repos) throws IOException {
    List<Exception> exceptions = new ArrayList<>();
    for (GHRepository repo : repos) {
        for (GHRepository fork : repo.listForks()) {
            Exception forkDeleteException = checkAndDelete(fork);
            if (forkDeleteException != null) {
                exceptions.add(forkDeleteException);
            }
        }
        Exception repoDeleteException = checkAndDelete(repo);
        if (repoDeleteException != null) {
            exceptions.add(repoDeleteException);
        }
    }
    return exceptions;
}
 
開發者ID:salesforce,項目名稱:dockerfile-image-update,代碼行數:17,代碼來源:TestCommon.java

示例11: deleteRepository

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void deleteRepository(final String repositoryName) throws IllegalArgumentException {
    if (repositoryName == null) {
        throw new IllegalArgumentException("repositoryName must be specified");
    }
    try {
        final GHRepository repo = delegate.getRepository(repositoryName);
        log.fine("Deleting repo at " + repo.gitHttpTransportUrl());
        repo.delete();
    } catch (final IOException ioe) {
        log.log(Level.SEVERE, "Error while deleting repository " + repositoryName, ioe);
        // Check for repo not found (this is how Kohsuke Java Client reports the error)
        if (isRepoNotFound(ioe)) {
            throw new NoSuchRepositoryException("Could not remove repository "
                                                        + repositoryName + " because it could not be found.");
        }
        throw new RuntimeException("Could not remove " + repositoryName, ioe);
    }
}
 
開發者ID:fabric8-launcher,項目名稱:launchpad-missioncontrol,代碼行數:23,代碼來源:KohsukeGitHubServiceImpl.java

示例12: main

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
public static void main(String[] args) {
	if (args.length == 0) {
		System.err
				.println("Please pass in your slack token code as an argument.");
		System.exit(1);
	}

	Optional<SessionFactory> sessionFactory = readSessionFactory();
	Optional<GHRepository> ghRepo = readGHRepo();

	WatchWordBot bot = new WatchWordBot(args[0], sessionFactory, ghRepo);
	try {
		bot.loadResources();
		bot.connect();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:eraether,項目名稱:WatchWordBot,代碼行數:19,代碼來源:Runner.java

示例13: testGetGithubUrl

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
@Test
public void testGetGithubUrl() throws Exception {

  File gitBasedir = temp.newFolder();

  PullRequestFacade facade = new PullRequestFacade(mock(GitHubPluginConfiguration.class));
  facade.setGitBaseDir(gitBasedir);
  GHRepository ghRepo = mock(GHRepository.class);
  when(ghRepo.getHtmlUrl()).thenReturn(new URL("https://github.com/SonarSource/sonar-java"));
  facade.setGhRepo(ghRepo);
  GHPullRequest pr = mock(GHPullRequest.class, withSettings().defaultAnswer(RETURNS_DEEP_STUBS));
  when(pr.getHead().getSha()).thenReturn("abc123");
  facade.setPr(pr);
  InputPath inputPath = mock(InputPath.class);
  when(inputPath.file()).thenReturn(new File(gitBasedir, "src/main/with space/Foo.java"));
  assertThat(facade.getGithubUrl(inputPath, 10).toString()).isEqualTo("https://github.com/SonarSource/sonar-java/blob/abc123/src/main/with%20space/Foo.java#L10");
}
 
開發者ID:SonarSource,項目名稱:sonar-github,代碼行數:18,代碼來源:PullRequestFacadeTest.java

示例14: testGetCommitStatusForContextWithOneCorrectStatus

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
@Test
public void testGetCommitStatusForContextWithOneCorrectStatus() throws IOException {
  PullRequestFacade facade = new PullRequestFacade(mock(GitHubPluginConfiguration.class));
  GHRepository ghRepo = mock(GHRepository.class);
  PagedIterable<GHCommitStatus> ghCommitStatuses = Mockito.mock(PagedIterable.class);
  List<GHCommitStatus> ghCommitStatusesList = new ArrayList<>();
  GHCommitStatus ghCommitStatusGHPRHContext = Mockito.mock(GHCommitStatus.class);
  ghCommitStatusesList.add(ghCommitStatusGHPRHContext);
  GHPullRequest pr = mock(GHPullRequest.class, withSettings().defaultAnswer(RETURNS_DEEP_STUBS));
  when(pr.getRepository()).thenReturn(ghRepo);
  when(pr.getHead().getSha()).thenReturn("abc123");
  when(ghRepo.listCommitStatuses(pr.getHead().getSha())).thenReturn(ghCommitStatuses);
  when(ghCommitStatuses.asList()).thenReturn(ghCommitStatusesList);
  when(ghCommitStatusGHPRHContext.getContext()).thenReturn(PullRequestFacade.COMMIT_CONTEXT);
  assertThat(facade.getCommitStatusForContext(pr, PullRequestFacade.COMMIT_CONTEXT).getContext()).isEqualTo(PullRequestFacade.COMMIT_CONTEXT);
}
 
開發者ID:SonarSource,項目名稱:sonar-github,代碼行數:17,代碼來源:PullRequestFacadeTest.java

示例15: run

import org.kohsuke.github.GHRepository; //導入依賴的package包/類
public void run() throws IOException {
    debugCommandLine(propertyReader, commandLineOptions.getPullRequests());

    debug("Parsing whitelist...");
    WhiteList whiteList = fromJsonFile();

    debug("Connecting to GitHub...");
    GHRepository repo = getGitHubRepository(propertyReader);

    debug("Reading code coverage data for %d PRs...", commandLineOptions.getPullRequests().size());
    JsonDownloader jsonDownloader = new JsonDownloader(propertyReader);
    CodeCoverageReader reader = new CodeCoverageReader(propertyReader, repo, jsonDownloader);
    reader.run(commandLineOptions.getPullRequests());

    debug("Analyzing code coverage data of %d files...", reader.getFiles().size());
    CodeCoverageAnalyzer analyzer = new CodeCoverageAnalyzer(reader.getFiles(), propertyReader, repo, whiteList);
    analyzer.run();

    debug("Printing code coverage data...");
    CodeCoveragePrinter printer = new CodeCoveragePrinter(reader.getPullRequests(), analyzer.getFiles(),
            propertyReader, commandLineOptions);
    printer.run();

    printTimeTracks();
    debugGreen("Done!\n");
}
 
開發者ID:hazelcast,項目名稱:hazelcast-qa,代碼行數:27,代碼來源:PullRequests.java


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