public interface Repositories
cloneOrPull(java.io.File, java.lang.String, java.lang.String, java.lang.String) honours its owner/repo arguments on every call,
including the update path for a checkout that already exists, so calling it repeatedly for the
same repository, or for different repositories from the same instance, is safe.
isUpToDate(java.io.File) takes no owner/repo argument; it derives the repository identity from the
checkout at path itself, the same way remoteOf(java.io.File) does, rather than from whatever
repository was configured when this instance was created.
| 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) |
void cloneOrPull(java.io.File target,
java.lang.String owner,
java.lang.String repo,
java.lang.String branch)
throws java.io.IOException
owner/repo into target if no checkout exists there yet, otherwise
pulls the latest changes for branch (or the current branch, if null).target - 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.void cloneOrPullFrom(java.io.File target,
java.lang.String cloneUrl,
java.lang.String branch)
throws java.io.IOException
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).target - 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.boolean exists(java.io.File path)
path - the directory to check.path.boolean isUpToDate(java.io.File path)
path - 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).RemoteRepo remoteOf(java.io.File projectDir)
projectDir - 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.java.lang.RuntimeException - if no enclosing checkout has an origin remote configured, or its
URL cannot be parsed into an owner and repository name.RemoteRepo configuredRepo()
RemoteRepo with null fields if none is configured.