Package dev.gradleplugins.fixtures.vcs
Class GitFileRepository
- java.lang.Object
-
- dev.gradleplugins.fixtures.vcs.GitFileRepository
-
- All Implemented Interfaces:
GitRepository,java.lang.AutoCloseable
public class GitFileRepository extends java.lang.Object implements GitRepository, java.lang.AutoCloseable
-
-
Constructor Summary
Constructors Constructor Description GitFileRepository(java.io.File parentDirectory)GitFileRepository(java.lang.String repositoryName, java.io.File parentDirectory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.eclipse.jgit.revwalk.RevCommitaddSubmodule(GitFileRepository submoduleRepo)org.eclipse.jgit.lib.Refcheckout(java.lang.String branchName)voidclose()Clean up any held resources (called automatically when used as a @Rule)org.eclipse.jgit.revwalk.RevCommitcommit(java.lang.String message)Commits all changes in the working tree.org.eclipse.jgit.revwalk.RevCommitcommit(java.lang.String message, java.lang.String... paths)Commits changes to the given paths.org.eclipse.jgit.lib.RefcreateAnnotatedTag(java.lang.String tagName, java.lang.String message)org.eclipse.jgit.lib.RefcreateBranch(java.lang.String branchName)org.eclipse.jgit.lib.RefcreateLightWeightTag(java.lang.String tagName)java.io.Filefile(java.lang.Object... path)org.eclipse.jgit.api.GitgetGit()Returns the underlying Git object from JGit.org.eclipse.jgit.lib.RefgetHead()java.lang.StringgetId()java.lang.StringgetName()java.util.List<java.net.URI>getRemotes()java.net.URIgetUrl()java.io.FilegetWorkTree()static GitFileRepositoryinit(java.io.File repositoryDirectory)Factory method for creating a GitRepository without using a JUnit @Rule.static GitFileRepositoryopen(java.io.File repositoryDirectory)Factory method for opening a GitRepository without using a JUnit @Rule.org.eclipse.jgit.revwalk.RevCommitupdateSubmodulesToLatest()Updates any submodules in this repository to the latest in the submodule origin repository
-
-
-
Method Detail
-
getGit
public org.eclipse.jgit.api.Git getGit()
Returns the underlying Git object from JGit. Please consider adding more convenience methods to this fixture over using "raw" Git APIs.
-
getName
public java.lang.String getName()
-
init
public static GitFileRepository init(java.io.File repositoryDirectory) throws org.eclipse.jgit.api.errors.GitAPIException
Factory method for creating a GitRepository without using a JUnit @Rule. Creates a repository in the given repositoryDirectory.- Throws:
org.eclipse.jgit.api.errors.GitAPIException
-
open
public static GitFileRepository open(java.io.File repositoryDirectory) throws java.io.IOException
Factory method for opening a GitRepository without using a JUnit @Rule. Open an existing repository in the given repositoryDirectory.- Throws:
java.io.IOException
-
close
public void close()
Clean up any held resources (called automatically when used as a @Rule)- Specified by:
closein interfacejava.lang.AutoCloseable
-
addSubmodule
public org.eclipse.jgit.revwalk.RevCommit addSubmodule(GitFileRepository submoduleRepo) throws org.eclipse.jgit.api.errors.GitAPIException
- Throws:
org.eclipse.jgit.api.errors.GitAPIException
-
getRemotes
public java.util.List<java.net.URI> getRemotes() throws org.eclipse.jgit.api.errors.GitAPIException, java.net.URISyntaxException- Throws:
org.eclipse.jgit.api.errors.GitAPIExceptionjava.net.URISyntaxException
-
updateSubmodulesToLatest
public org.eclipse.jgit.revwalk.RevCommit updateSubmodulesToLatest() throws org.eclipse.jgit.api.errors.GitAPIExceptionUpdates any submodules in this repository to the latest in the submodule origin repository- Throws:
org.eclipse.jgit.api.errors.GitAPIException
-
commit
public org.eclipse.jgit.revwalk.RevCommit commit(java.lang.String message, java.lang.String... paths) throws org.eclipse.jgit.api.errors.GitAPIExceptionCommits changes to the given paths. The paths are passed as-is to the underlying JGit library.- Throws:
org.eclipse.jgit.api.errors.GitAPIException
-
commit
public org.eclipse.jgit.revwalk.RevCommit commit(java.lang.String message) throws org.eclipse.jgit.api.errors.GitAPIExceptionCommits all changes in the working tree. This is approximatelygit commit -am "message"- Specified by:
commitin interfaceGitRepository- Throws:
org.eclipse.jgit.api.errors.GitAPIException
-
createBranch
public org.eclipse.jgit.lib.Ref createBranch(java.lang.String branchName) throws org.eclipse.jgit.api.errors.GitAPIException- Specified by:
createBranchin interfaceGitRepository- Throws:
org.eclipse.jgit.api.errors.GitAPIException
-
checkout
public org.eclipse.jgit.lib.Ref checkout(java.lang.String branchName) throws org.eclipse.jgit.api.errors.GitAPIException- Specified by:
checkoutin interfaceGitRepository- Throws:
org.eclipse.jgit.api.errors.GitAPIException
-
createLightWeightTag
public org.eclipse.jgit.lib.Ref createLightWeightTag(java.lang.String tagName) throws org.eclipse.jgit.api.errors.GitAPIException- Specified by:
createLightWeightTagin interfaceGitRepository- Throws:
org.eclipse.jgit.api.errors.GitAPIException
-
createAnnotatedTag
public org.eclipse.jgit.lib.Ref createAnnotatedTag(java.lang.String tagName, java.lang.String message) throws org.eclipse.jgit.api.errors.GitAPIException- Throws:
org.eclipse.jgit.api.errors.GitAPIException
-
getHead
public org.eclipse.jgit.lib.Ref getHead() throws java.io.IOException- Throws:
java.io.IOException
-
getWorkTree
public java.io.File getWorkTree()
- Specified by:
getWorkTreein interfaceGitRepository
-
file
public java.io.File file(java.lang.Object... path)
- Specified by:
filein interfaceGitRepository
-
getUrl
public java.net.URI getUrl()
- Specified by:
getUrlin interfaceGitRepository
-
getId
public java.lang.String getId()
-
-