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 retrieve Repository instances
  • Method Details

    • instance

      public static Git instance()
      Returns an instance using default options.
      Returns:
      an instance using default options.
    • clone

      public Repository clone(File directory, String uri) throws GitException
      Returns a repository instance working in the given directory after cloning from the given URI. This method uses no authentication.
      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 is null
      IllegalArgumentException - if a given object is illegal for some reason, like referring to an illegal repository
      GitException - in case the operation fails for some reason, including when authentication fails
    • clone

      public Repository clone(File 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 and password are both null 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 and user are both null 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 is null
      IllegalArgumentException - if a given object is illegal for some reason, like referring to an illegal repository
      GitException - in case the operation fails for some reason, including when authentication fails
    • clone

      public Repository clone(File directory, String uri, String privateKey, byte[] passphrase) 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.
      privateKey - the SSH private key. If null the private key will be searched in its default location (i.e. in the users' $HOME/.ssh directory).
      passphrase - the optional password to use to open the private key, in case it's protected by a passphrase. This is required when the private key is password protected as this implementation does not support prompting the user interactively for entering the password.
      Returns:
      the new repository object.
      Throws:
      NullPointerException - if any of the given objects is null
      IllegalArgumentException - if a given object is illegal for some reason, like referring to an illegal repository
      GitException - 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. This method uses no authentication.
      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 is null
      IllegalArgumentException - if a given object is illegal for some reason, like referring to an illegal repository
      GitException - 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 and password are both null 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 and user are both null 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 is null
      IllegalArgumentException - if a given object is illegal for some reason, like referring to an illegal repository
      GitException - in case the operation fails for some reason, including when authentication fails
    • clone

      public Repository clone(String directory, String uri, String privateKey, byte[] passphrase) 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.
      privateKey - the SSH private key. If null the private key will be searched in its default location (i.e. in the users' $HOME/.ssh directory).
      passphrase - the optional password to use to open the private key, in case it's protected by a passphrase. This is required when the private key is password protected as this implementation does not support prompting the user interactively for entering the password.
      Returns:
      the new repository object.
      Throws:
      NullPointerException - if any of the given objects is null
      IllegalArgumentException - if a given object is illegal for some reason, like referring to an illegal repository
      GitException - in case the operation fails for some reason, including when authentication fails
    • 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 is null
      IllegalArgumentException - if the given object is illegal for some reason, like referring to an illegal repository
      IOException - 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 is null
      IllegalArgumentException - if the given object is illegal for some reason, like referring to an illegal repository
      IOException - in case of any I/O issue accessing the repository