Java Code Examples for org.kohsuke.github.GHRepository#getFullName()
The following examples show how to use
org.kohsuke.github.GHRepository#getFullName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PullRequestSCMHead.java From github-branch-source-plugin with MIT License | 6 votes |
PullRequestSCMHead(GHPullRequest pr, String name, boolean merge) { super(name); // the merge flag is encoded into the name, so safe to store here this.merge = merge; this.number = pr.getNumber(); this.target = new BranchSCMHead(pr.getBase().getRef()); // the source stuff is immutable for a pull request on github, so safe to store here GHRepository repository = pr.getHead().getRepository(); // may be null for deleted forks JENKINS-41246 this.sourceOwner = repository == null ? null : repository.getOwnerName(); this.sourceRepo = repository == null ? null : repository.getName(); this.sourceBranch = pr.getHead().getRef(); if (pr.getRepository().getOwnerName().equalsIgnoreCase(sourceOwner)) { this.origin = SCMHeadOrigin.DEFAULT; } else { // if the forked repo name differs from the upstream repo name this.origin = pr.getBase().getRepository().getName().equalsIgnoreCase(sourceRepo) ? new SCMHeadOrigin.Fork(this.sourceOwner) : new SCMHeadOrigin.Fork(repository == null ? this.sourceOwner : repository.getFullName()); } }
Example 2
Source File: GitHubPullRequestSender.java From dockerfile-image-update with BSD 3-Clause "New" or "Revised" License | 5 votes |
public Multimap<String, GitHubContentToProcess> forkRepositoriesFoundAndGetPathToDockerfiles( PagedSearchIterable<GHContent> contentsWithImage, GitForkBranch gitForkBranch) { log.info("Forking repositories..."); Multimap<String, GitHubContentToProcess> pathToDockerfilesInParentRepo = HashMultimap.create(); GHRepository parent; String parentRepoName; for (GHContent ghContent : contentsWithImage) { /* Kohsuke's GitHub API library, when retrieving the forked repository, looks at the name of the parent to * retrieve. The issue with that is: GitHub, when forking two or more repositories with the same name, * automatically fixes the names to be unique (by appending "-#" to the end). Because of this edge case, we * cannot save the forks and iterate over the repositories; else, we end up missing/not updating the * repositories that were automatically fixed by GitHub. Instead, we save the names of the parent repos * in the map above, find the list of repositories under the authorized user, and iterate through that list. */ parent = ghContent.getOwner(); parentRepoName = parent.getFullName(); // Refresh the repo to ensure that the object has full details try { parent = dockerfileGitHubUtil.getRepo(parentRepoName); ShouldForkResult shouldForkResult = forkableRepoValidator.shouldFork(parent, ghContent, gitForkBranch); if (shouldForkResult.isForkable()) { // fork the parent if not already forked ensureForkedAndAddToListForProcessing(pathToDockerfilesInParentRepo, parent, parentRepoName, ghContent); } else { log.warn("Skipping {} because {}", parentRepoName, shouldForkResult.getReason()); } } catch (IOException exception) { log.warn("Could not refresh details of {}", parentRepoName); } } log.info("Path to Dockerfiles in repos: {}", pathToDockerfilesInParentRepo); return pathToDockerfilesInParentRepo; }
Example 3
Source File: GitHubRepository.java From github-integration-plugin with MIT License | 5 votes |
/** * Repository may be created without gh connection, but trigger logic expects this fields. * Should be called before trigger logic starts checks. */ public synchronized void actualise(@Nonnull GHRepository ghRepository, @Nonnull TaskListener listener) throws IOException { changed = false; PrintStream logger = listener.getLogger(); // just in case your organisation decided to change domain // take into account only repo/name if (isNull(fullName) || !fullName.equalsIgnoreCase(ghRepository.getFullName())) { logger.printf("Repository full name changed from '%s' to '%s'.%n", fullName, ghRepository.getFullName()); fullName = ghRepository.getFullName(); changed = true; } if (isNull(githubUrl) || !githubUrl.toExternalForm().equalsIgnoreCase(ghRepository.getHtmlUrl().toExternalForm())) { logger.printf("Changing GitHub url from '%s' to '%s'.%n", githubUrl, ghRepository.getHtmlUrl()); githubUrl = ghRepository.getHtmlUrl(); } if (isNull(gitUrl) || !gitUrl.equalsIgnoreCase(ghRepository.getGitTransportUrl())) { logger.printf("Changing Git url from '%s' to '%s'.%n", gitUrl, ghRepository.getGitTransportUrl()); gitUrl = ghRepository.getGitTransportUrl(); } if (isNull(sshUrl) || !sshUrl.equalsIgnoreCase(ghRepository.getSshUrl())) { logger.printf("Changing SSH url from '%s' to '%s'.%n", sshUrl, ghRepository.getSshUrl()); sshUrl = ghRepository.getSshUrl(); } actualiseOnChange(ghRepository, listener); }
Example 4
Source File: GitHubBranchSCMHead.java From github-integration-plugin with MIT License | 5 votes |
@Override public String fetchHeadSha(GHRepository remoteRepo) throws IOException { GHBranch branch = remoteRepo.getBranch(getName()); if (branch == null) { throw new IOException("No branch " + getName() + " in " + remoteRepo.getFullName()); } return branch.getSHA1(); }
Example 5
Source File: GitHubPRSCMHead.java From github-integration-plugin with MIT License | 5 votes |
@Override public String fetchHeadSha(GHRepository remoteRepo) throws IOException { GHPullRequest pullRequest = remoteRepo.getPullRequest(prNumber); if (pullRequest == null) { throw new IOException("No PR " + prNumber + " in " + remoteRepo.getFullName()); } return pullRequest.getHead().getSha(); }
Example 6
Source File: GitHubTagSCMHead.java From github-integration-plugin with MIT License | 5 votes |
@Override public String fetchHeadSha(GHRepository remoteRepo) throws IOException { GHTag tag = GitHubTag.findRemoteTag(remoteRepo, getName()); if (tag == null) { throw new IOException("No tag " + getName() + " in " + remoteRepo.getFullName()); } return tag.getCommit().getSHA1(); }
Example 7
Source File: Parent.java From dockerfile-image-update with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected void changeDockerfiles(Namespace ns, Multimap<String, GitHubContentToProcess> pathToDockerfilesInParentRepo, GitHubContentToProcess gitHubContentToProcess, List<String> skippedRepos) throws IOException, InterruptedException { // Should we skip doing a getRepository just to fill in the parent value? We already know this to be the parent... GHRepository parent = gitHubContentToProcess.getParent(); GHRepository forkedRepo = gitHubContentToProcess.getFork(); // TODO: Getting a null pointer here for someone... probably just fixed this since we have parent String parentName = parent.getFullName(); log.info("Fixing Dockerfiles in {} to PR to {}", forkedRepo.getFullName(), parent.getFullName()); GitForkBranch gitForkBranch = new GitForkBranch(ns.get(Constants.IMG), ns.get(Constants.TAG), ns.get(Constants.GIT_BRANCH)); dockerfileGitHubUtil.createOrUpdateForkBranchToParentDefault(parent, forkedRepo, gitForkBranch); // loop through all the Dockerfiles in the same repo boolean isContentModified = false; boolean isRepoSkipped = true; for (GitHubContentToProcess forkWithCurrentContentPath : pathToDockerfilesInParentRepo.get(parentName)) { String pathToDockerfile = forkWithCurrentContentPath.getContentPath(); GHContent content = dockerfileGitHubUtil.tryRetrievingContent(forkedRepo, pathToDockerfile, gitForkBranch.getBranchName()); if (content == null) { log.info("No Dockerfile found at path: '{}'", pathToDockerfile); } else { dockerfileGitHubUtil.modifyOnGithub(content, gitForkBranch.getBranchName(), gitForkBranch.getImageName(), gitForkBranch.getImageTag(), ns.get(Constants.GIT_ADDITIONAL_COMMIT_MESSAGE)); isContentModified = true; isRepoSkipped = false; } } if (isRepoSkipped) { log.info("Skipping repo '{}' because contents of it's fork could not be retrieved. Moving ahead...", parentName); skippedRepos.add(forkedRepo.getFullName()); } if (isContentModified) { // TODO: get the new PR number and cross post over to old ones dockerfileGitHubUtil.createPullReq(parent, gitForkBranch.getBranchName(), forkedRepo, ns.get(Constants.GIT_PR_TITLE)); // TODO: Run through PRs in fork to see if they have head branches that match the prefix and close those? } }
Example 8
Source File: GitHubRepoAction.java From github-integration-plugin with MIT License | 4 votes |
public GitHubRepoAction(GHRepository remoteRepository) { super(remoteRepository.getHtmlUrl().toExternalForm()); this.name = remoteRepository.getFullName(); }