public URL getUrl() { return repository.getHtmlUrl(); }
@Override public String getProjectUrl() { return this.repository.getHtmlUrl().toExternalForm(); }
public GitHubBranch(String name, String commitSha, GHRepository ghRepository) { this.name = name; this.commitSha = commitSha; this.htmlUrl = ghRepository.getHtmlUrl().toString() + "/tree/" + name; }
public String getHtmlUrl() { return ghRepo.getHtmlUrl().toString(); }
private static String buildUrl(GHRepository remoteRepository, String tag) { String repoUrl = remoteRepository.getHtmlUrl().toExternalForm(); if (remoteRepository.getDefaultBranch().equals(tag)) { return repoUrl; } return repoUrl + "/releases/tag/" + tag; }
@PreDestroy public void delete() { try { ghRepo.delete(); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } submodules.forEach(TestGitHubRepository::delete); LOG.info("GitHub repo {} has been removed", ghRepo.getHtmlUrl()); }
private static String buildUrl(GHRepository remoteRepository, String branch) { String repoUrl = remoteRepository.getHtmlUrl().toExternalForm(); if (remoteRepository.getDefaultBranch().equals(branch)) { return repoUrl; } return repoUrl + "/tree/" + branch; }
public boolean isHookConfigured() throws IOException { return githubAccessTokenRepository.isConfigured(repository.getHtmlUrl().toExternalForm()); }
public String getHookAssignedTo() { return githubAccessTokenRepository.getAssociatedLogin(repository.getHtmlUrl().toExternalForm()); }
public GitHubRepoAction(GHRepository remoteRepository) { super(remoteRepository.getHtmlUrl().toExternalForm()); this.name = remoteRepository.getFullName(); }
/** * Does this repository match the repository referenced in the given {@link GHCommitPointer}? */ public boolean matches(GHRepository repo) throws IOException { return userName.equals(repo.getOwner().getLogin()) // TODO: use getOwnerName && repositoryName.equals(repo.getName()) && host.equals(repo.getHtmlUrl().getHost()); }
@CheckForNull public URL getGithubUrl(@Nullable InputComponent inputComponent, @Nullable Integer issueLine) { if (inputComponent instanceof InputPath) { String path = getPath((InputPath) inputComponent); URL url1 = ghRepo.getHtmlUrl(); try { return new URI(url1.getProtocol(), null, url1.getHost(), url1.getPort(), url1.getFile() + "/blob/" + pr.getHead().getSha() + "/" + path, null, issueLine != null ? ("L" + issueLine) : "").toURL(); } catch (MalformedURLException | URISyntaxException e) { LOG.error("Invalid URL", e); } } return null; }
private GHRepository create() throws IOException { GHRepository repo = gitHub.createRepository(repoName).create(); ensureRepositoryCreated(repo, System.currentTimeMillis()); LOG.info("GitHub repo {} has been created", repo.getHtmlUrl()); return repo; }
private void retrieveRepositoryNames() throws IOException { System.err.println("Retrieving GitHub repository names..."); Cache cache = new Cache(GITHUB_API_CACHE, 20L*1024*1024); // 20 MB cache github = new GitHubBuilder().withConnector(new OkHttp3Connector(new OkUrlFactory(new OkHttpClient.Builder().cache(cache).build()))).withPassword(GITHUB_API_USERNAME, GITHUB_API_PASSWORD).build(); List<String> ret = new ArrayList<>(); for (GHRepository repo : github.getOrganization("jenkinsci").listRepositories().withPageSize(100)) { ret.add(repo.getHtmlUrl().toString()); } Files.write(GITHUB_REPO_LIST.toPath(), ret); }
public void addHook(final String accessToken, final String user) throws IOException { String githubCallbackUrl = getSetupConfig().getGithubCallbackUrl(); if (!githubCallbackUrl.endsWith("/")) { githubCallbackUrl = githubCallbackUrl + "/"; } final Map<String, String> params = ImmutableMap.of("url", githubCallbackUrl); final List<GHEvent> events = Arrays.asList(GHEvent.PUSH, GHEvent.PULL_REQUEST); this.githubAccessTokenRepository.put(getRepository().getHtmlUrl().toExternalForm(), accessToken, user); removeExistingHook(githubCallbackUrl); getRepository().createHook("web", params, events, true); }
@Override public List<Repository> getRepositories(String accessToken, String organizationName) throws IOException, ServiceException { GitHub gitHub = GitHub.connectUsingOAuth(accessToken); GHPerson person = StringUtils.isBlank(organizationName) ? gitHub.getMyself() : gitHub.getOrganization(organizationName); return person.listRepositories().asList().stream().map(repository -> { Repository repo = new Repository(repository.getName()); repo.setPrivate(repository.isPrivate()); repo.setUrl(repository.getHtmlUrl().toString()); return repo; }).collect(Collectors.toList()); }
public GithubRepository(GHRepository repository) { this.repository = repository; URL htmlUrl = repository.getHtmlUrl(); if (htmlUrl != null) { setHtmlUrl(htmlUrl.toString()); } setName(repository.getName()); setCloneUrl(repository.getGitTransportUrl()); }
public GithubRepository(GHRepository repository) { this.repository = repository; URL htmlUrl = repository.getHtmlUrl(); if (htmlUrl != null) { setHtmlUrl(htmlUrl.toString()); } setName(repository.getName()); setCloneUrl(repository.getGitTransportUrl()); }
protected void addDeployKey() throws IOException { if (getRepository().isPrivate()) { removeDeployKeyIfPreviouslyAdded(); final DeployKeyPair keyPair = new KeyPairGenerator().generateKeyPair(); getRepository().addDeployKey("DotCi", keyPair.publicKey); this.githubDeployKeyRepository.put(getRepository().getHtmlUrl().toExternalForm(), keyPair); } }
public CommitInfo(final GHCommit commit, final GitBranch branch) { this.sha = commit.getSHA1(); try { this.message = commit.getCommitShortInfo().getMessage(); this.committerName = commit.getCommitShortInfo().getCommitter().getName(); this.committerEmail = commit.getCommitShortInfo().getCommitter().getEmail(); this.commitUrl = commit.getOwner().getHtmlUrl() + "/commit/" + this.sha; } catch (final IOException e) { throw new RuntimeException(e); } this.branch = branch.toString(); this.avatarUrl = null; }