public class RepositoriesImpl extends java.lang.Object implements Repositories
Repositories that builds a fresh, per-call GitHub scoped to the exact owner and
repo an operation names, instead of reusing the single GitHub GitHubApi.create
was given.SourceBuilder.buildFromSource(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String): a GitHub carries one ResourceSettings, so its own update path (which resolves the owner from that extension) is
only correct for repeated calls against the same repository. cloneOrPull(java.io.File, java.lang.String, java.lang.String, java.lang.String) builds its own
scoped GitHub per call so a consumer can target any repository, any number of times,
without a previous call's target leaking into the next one. cloneOrPullFrom(java.io.File, java.lang.String, java.lang.String) does the
same but scopes to the caller's own cloneUrl verbatim instead of reconstructing a
github.com URL from owner and repo, so a non-github.com host (self-hosted GitLab, Gitea, a
GitHub Enterprise instance) is honoured rather than silently redirected to public github.com.
isUpToDate(java.io.File) takes no owner/repo, so it derives the repository identity from the
checkout at path itself (the same way remoteOf(java.io.File) does) rather than from
whichever repository happened to be configured at construction time. exists(java.io.File), remoteOf(java.io.File) and configuredRepo() genuinely have no repository-specific behavior to scope,
so they keep using the construction-time GitHub.| Constructor and Description |
|---|
RepositoriesImpl(GitHub configured,
GitHubConfig config,
GitHubLogger logger) |
| Modifier and Type | Method and Description |
|---|---|
void |
cloneOrPull(java.io.File target,
java.lang.String owner,
java.lang.String repo,
java.lang.String branch)
Clones
owner/repo into target if no checkout exists there yet, otherwise
pulls the latest changes for branch (or the current branch, if null). |
void |
cloneOrPullFrom(java.io.File target,
java.lang.String cloneUrl,
java.lang.String branch)
Clones or pulls
cloneUrl into target, using the given URL directly rather
than reconstructing one from an owner and repo, so any git host is honoured exactly as
configured (github.com, GitHub Enterprise, or any other host). |
RemoteRepo |
configuredRepo()
The owner and repository parsed from the implementation's own configured repository URL.
|
boolean |
exists(java.io.File path) |
boolean |
isUpToDate(java.io.File path) |
RemoteRepo |
remoteOf(java.io.File projectDir) |
public RepositoriesImpl(GitHub configured, GitHubConfig config, GitHubLogger logger)
configured - the construction-time GitHub, used as-is by operations that have
no repository-specific behavior to scope (exists(java.io.File), remoteOf(java.io.File), configuredRepo()).config - the access token and auth/cli/resilience settings, reused to build each per-call scoped GitHub.logger - receives diagnostic output from each per-call scoped GitHub.public void cloneOrPull(java.io.File target,
java.lang.String owner,
java.lang.String repo,
java.lang.String branch)
throws java.io.IOException
Repositoriesowner/repo into target if no checkout exists there yet, otherwise
pulls the latest changes for branch (or the current branch, if null).cloneOrPull in interface Repositoriestarget - the local directory to clone into or pull within.owner - the GitHub account or organization that owns the repository.repo - the repository name, without the owner prefix.branch - the branch to clone or pull, or null for the current/default branch.java.io.IOException - if the clone or pull fails.public void cloneOrPullFrom(java.io.File target,
java.lang.String cloneUrl,
java.lang.String branch)
throws java.io.IOException
RepositoriescloneUrl into target, using the given URL directly rather
than reconstructing one from an owner and repo, so any git host is honoured exactly as
configured (github.com, GitHub Enterprise, or any other host).cloneOrPullFrom in interface Repositoriestarget - the local directory to clone into or pull within.cloneUrl - the exact URL to clone from.branch - the branch to clone or pull, or null for the current/default branch.java.io.IOException - if the clone or pull fails.public boolean exists(java.io.File path)
exists in interface Repositoriespath - the directory to check.path.public boolean isUpToDate(java.io.File path)
isUpToDate in interface Repositoriespath - the checkout to check, whose own origin remote identifies the repository.path's current branch matches its remote counterpart, false if it
is behind or the check itself fails (e.g. no network access).public RemoteRepo remoteOf(java.io.File projectDir)
remoteOf in interface RepositoriesprojectDir - a directory inside the checkout whose origin remote is parsed; the
search walks up to the enclosing repository, so a Gradle subproject directory works.origin remote URL.public RemoteRepo configuredRepo()
RepositoriesconfiguredRepo in interface RepositoriesRemoteRepo with null fields if none is configured.