Package org.wso2.carbon.deployment.synchronizer.git.util

## Class GitUtilities

- java.lang.Object
- - org.wso2.carbon.deployment.synchronizer.git.util.GitUtilities

-     public class GitUtilities
      extends Object

  Utility methods specific for Git

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `GitUtilities()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static boolean` | `addRemote​(org.eclipse.jgit.lib.Repository repository, String remoteUrl)` | Adds the remote repository at remoteUrl to the given local repository
    `static org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider` | `createCredentialsProvider​(org.wso2.carbon.deployment.synchronizer.RepositoryManager repositoryManager, int tenantId)` | Creates and return a UsernamePasswordCredentialsProvider instance for a tenant
    `static void` | `InitGitRepository​(File gitRepoDir)` | Initialize local git repository
    `static boolean` | `isValidGitRepo​(org.eclipse.jgit.lib.Repository repository)` | Checks if an existing local repository is a valid git repository

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### GitUtilities

          public GitUtilities()

  - ### Method Detail

    - #### isValidGitRepo

          public static boolean isValidGitRepo​(org.eclipse.jgit.lib.Repository repository)

      Checks if an existing local repository is a valid git repository
      Parameters:
        `repository` - Repository instance
      Returns:
        true if a valid git repo, else false

    - #### createCredentialsProvider

          public static org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider createCredentialsProvider​(org.wso2.carbon.deployment.synchronizer.RepositoryManager repositoryManager,
                                                                                                                 int tenantId)

      Creates and return a UsernamePasswordCredentialsProvider instance for a tenant
      Parameters:
        `tenantId` - tenant Id
        `repositoryManager` - RepositoryManager instance
      Returns:
        UsernamePasswordCredentialsProvider instance or null if username/password is not valid

    - #### InitGitRepository

          public static void InitGitRepository​(File gitRepoDir)

      Initialize local git repository
      Parameters:
        `gitRepoDir` - directory in the local file system

    - #### addRemote

          public static boolean addRemote​(org.eclipse.jgit.lib.Repository repository,
                                          String remoteUrl)

      Adds the remote repository at remoteUrl to the given local repository
      Parameters:
        `repository` - Repository instance representing local repo
        `remoteUrl` - remote repository url
      Returns:
        true if remote successfully added, else false