Interface Repositories
- All Known Implementing Classes:
GitHub,RepositoriesImpl
public interface Repositories
Clones, updates and inspects a local checkout of a GitHub repository.
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.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcloneOrPull(File target, String owner, String repo, String branch) Clonesowner/repointotargetif no checkout exists there yet, otherwise pulls the latest changes forbranch(or the current branch, if null).voidcloneOrPullFrom(File target, String cloneUrl, String branch) Clones or pullscloneUrlintotarget, 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).The owner and repository parsed from the implementation's own configured repository URL.booleanbooleanisUpToDate(File path)
-
Method Details
-
cloneOrPull
Clonesowner/repointotargetif no checkout exists there yet, otherwise pulls the latest changes forbranch(or the current branch, if null).- Parameters:
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.- Throws:
IOException- if the clone or pull fails.
-
cloneOrPullFrom
Clones or pullscloneUrlintotarget, 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).- Parameters:
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.- Throws:
IOException- if the clone or pull fails.
-
exists
- Parameters:
path- the directory to check.- Returns:
- true if a git repository checkout exists at
path.
-
isUpToDate
- Parameters:
path- the checkout to check, whose ownoriginremote identifies the repository.- Returns:
- true if
path's current branch matches its remote counterpart, false if it is behind or the check itself fails (e.g. no network access).
-
remoteOf
- Parameters:
projectDir- the checkout whoseoriginremote is parsed.- Returns:
- the owner and repository name parsed from
projectDir'soriginremote URL. - Throws:
RuntimeException- ifprojectDirhas nooriginremote configured, or its URL cannot be parsed into an owner and repository name.
-
configuredRepo
RemoteRepo configuredRepo()The owner and repository parsed from the implementation's own configured repository URL.- Returns:
- the configured owner and repo, or a
RemoteRepowith null fields if none is configured.
-