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 retrieveRepositoryinstances
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Repositoryclone(File directory, URI uri)Returns a repository instance working in the given directory after cloning from the given URI.Repositoryclone(File directory, URI uri, String user, String password)Returns a repository instance working in the given directory after cloning from the given URI.Repositoryclone(String directory, String uri)Returns a repository instance working in the given directory after cloning from the given URI.Repositoryclone(String directory, String uri, String user, String password)Returns a repository instance working in the given directory after cloning from the given URI.StringgetPassword()Returns the password to be used when connecting to remote repositories.StringgetUser()Returns the user name to be used when connecting to remote repositories.static Gitinstance()Returns an instance using default options.Repositoryopen(File directory)Returns a repository instance working in the given directory.Repositoryopen(String directory)Returns a repository instance working in the given directory.voidsetPassword(String password)Sets the password to be used when connecting to remote repositories.voidsetUser(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 isnullIllegalArgumentException- 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 andpasswordare bothnullthen 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 anduserare bothnullthen 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 isnullIllegalArgumentException- 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 isnullIllegalArgumentException- 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 andpasswordare bothnullthen 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 anduserare bothnullthen 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 isnullIllegalArgumentException- 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
nullthe remote repositories are meant to allow anonymous access and, in this case, also thepasswordisnull.
-
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()returnsnullthis method also returnsnullamd 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 isnullIllegalArgumentException- 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 isnullIllegalArgumentException- 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. Whennullthe 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.
-
-