Package com.mooltiverse.oss.nyx.git
Class Git
- java.lang.Object
-
- com.mooltiverse.oss.nyx.git.Git
-
public class Git extends Object
The entry point to the Git local and remote service. This is also the main entry point to retrieveRepository
instances
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Repository
clone(File directory, URI uri)
Returns a repository instance working in the given directory after cloning from the given URI.Repository
clone(File directory, URI uri, String user, String password)
Returns a repository instance working in the given directory after cloning from the given URI.Repository
clone(String directory, String uri)
Returns a repository instance working in the given directory after cloning from the given URI.Repository
clone(String directory, String uri, String user, String password)
Returns a repository instance working in the given directory after cloning from the given URI.String
getPassword()
Returns the password to be used when connecting to remote repositories.String
getUser()
Returns the user name to be used when connecting to remote repositories.static Git
instance()
Returns an instance using default options.Repository
open(File directory)
Returns a repository instance working in the given directory.Repository
open(String directory)
Returns a repository instance working in the given directory.void
setPassword(String password)
Sets the password to be used when connecting to remote repositories.void
setUser(String user)
Sets the user name to be used when connecting to remote repositories.
-
-
-
Method Detail
-
instance
public static Git instance()
Returns an instance using default options.- Returns:
- an instance using default options.
-
clone
public Repository clone(File directory, URI uri) throws GitException
Returns a repository instance working in the given directory after cloning from the given URI. If the instance has some credentials set, those are used to perform the operation, otherwise anonymous access will be used.- Parameters:
directory
- the directory where the repository has to be cloned. It is created if it doesn't exist.uri
- the URI of the remote repository to clone.- Returns:
- the new repository object.
- Throws:
NullPointerException
- if any of the given objects isnull
IllegalArgumentException
- if a given object is illegal for some reason, like referring to an illegal repositoryGitException
- in case the operation fails for some reason, including when authentication fails
-
clone
public Repository clone(File directory, URI uri, String user, String password) throws GitException
Returns a repository instance working in the given directory after cloning from the given URI.- Parameters:
directory
- the directory where the repository has to be cloned. It is created if it doesn't exist.uri
- the URI of the remote repository to clone.user
- the user name to use when credentials are required. If this andpassword
are bothnull
then no credentials is used. When using single token authentication (i.e. OAuth or Personal Access Tokens) this value may be the token or something other than a token, depending on the remote provider.password
- the password to use when credentials are required. If this anduser
are bothnull
then no credentials is used. When using single token authentication (i.e. OAuth or Personal Access Tokens) this value may be the token or something other than a token, depending on the remote provider.- Returns:
- the new repository object.
- Throws:
NullPointerException
- if any of the given objects isnull
IllegalArgumentException
- if a given object is illegal for some reason, like referring to an illegal repositoryGitException
- in case the operation fails for some reason, including when authentication fails
-
clone
public Repository clone(String directory, String uri) throws GitException
Returns a repository instance working in the given directory after cloning from the given URI. If the instance has some credentials set, those are used to perform the operation, otherwise anonymous access will be used.- Parameters:
directory
- the directory where the repository has to be cloned. It is created if it doesn't exist.uri
- the URI of the remote repository to clone.- Returns:
- the new repository object.
- Throws:
NullPointerException
- if any of the given objects isnull
IllegalArgumentException
- if a given object is illegal for some reason, like referring to an illegal repositoryGitException
- in case the operation fails for some reason, including when authentication fails
-
clone
public Repository clone(String directory, String uri, String user, String password) throws GitException
Returns a repository instance working in the given directory after cloning from the given URI.- Parameters:
directory
- the directory where the repository has to be cloned. It is created if it doesn't exist.uri
- the URI of the remote repository to clone.user
- the user name to use when credentials are required. If this andpassword
are bothnull
then no credentials is used. When using single token authentication (i.e. OAuth or Personal Access Tokens) this value may be the token or something other than a token, depending on the remote provider.password
- the password to use when credentials are required. If this anduser
are bothnull
then no credentials is used. When using single token authentication (i.e. OAuth or Personal Access Tokens) this value may be the token or something other than a token, depending on the remote provider.- Returns:
- the new repository object.
- Throws:
NullPointerException
- if any of the given objects isnull
IllegalArgumentException
- if a given object is illegal for some reason, like referring to an illegal repositoryGitException
- in case the operation fails for some reason, including when authentication fails
-
getUser
public String getUser()
Returns the user name to be used when connecting to remote repositories.- Returns:
- the user name to be used when connecting to remote repositories.
When
null
the remote repositories are meant to allow anonymous access and, in this case, also thepassword
isnull
.
-
getPassword
public String getPassword()
Returns the password to be used when connecting to remote repositories.- Returns:
- the password to be used when connecting to remote repositories.
When
getUser()
returnsnull
this method also returnsnull
amd the remote repositories are meant to allow anonymous access.
-
open
public Repository open(File directory) throws IOException
Returns a repository instance working in the given directory.- Parameters:
directory
- the directory where the repository is.- Returns:
- the new repository object.
- Throws:
NullPointerException
- if the given object isnull
IllegalArgumentException
- if the given object is illegal for some reason, like referring to an illegal repositoryIOException
- in case of any I/O issue accessing the repository
-
open
public Repository open(String directory) throws IOException
Returns a repository instance working in the given directory.- Parameters:
directory
- the directory where the repository is.- Returns:
- the new repository object.
- Throws:
NullPointerException
- if the given object isnull
IllegalArgumentException
- if the given object is illegal for some reason, like referring to an illegal repositoryIOException
- in case of any I/O issue accessing the repository
-
setUser
public void setUser(String user)
Sets the user name to be used when connecting to remote repositories.- Parameters:
user
- the user name to be used when connecting to remote repositories. Whennull
the remote repositories are meant to allow anonymous access.
-
setPassword
public void setPassword(String password)
Sets the password to be used when connecting to remote repositories.- Parameters:
password
- the password to be used when connecting to remote repositories.
-
-