Class GITRemoteRepository2

java.lang.Object
org.omegat.core.team2.impl.GITRemoteRepository2
All Implemented Interfaces:
IRemoteRepository2

public class GITRemoteRepository2 extends Object implements IRemoteRepository2
GIT repository connection implementation.
  • Constructor Details

    • GITRemoteRepository2

      public GITRemoteRepository2()
  • Method Details

    • loadPlugins

      public static void loadPlugins()
      Plugin loader.
    • unloadPlugins

      public static void unloadPlugins()
      Plugin unloader.
    • init

      public void init(RepositoryDefinition repo, File dir, ProjectTeamSettings teamSettings) throws Exception
      Initialize remote repository access credentials.
      Specified by:
      init in interface IRemoteRepository2
      Parameters:
      repo - repository description instance
      dir - directory for store files
      teamSettings - team settings.
      Throws:
      Exception - when error happened.
    • getFileVersion

      public String getFileVersion(String file) throws IOException
      Get version string.
      Specified by:
      getFileVersion in interface IRemoteRepository2
      Parameters:
      file - target file to check.
      Returns:
      version string when file exists, otherwise null.
      Throws:
      IOException - when error occurred.
    • switchToVersion

      public void switchToVersion(String version) throws Exception
      Switch to git version specified.
      Specified by:
      switchToVersion in interface IRemoteRepository2
      Parameters:
      version - version string to switch.
      Throws:
      Exception - when error occurred.
    • addForCommit

      public void addForCommit(String path) throws Exception
      Add directory/file to commit.
      Specified by:
      addForCommit in interface IRemoteRepository2
      Parameters:
      path - The relative path of the item from the root of the repo (should not start with a /)
      Throws:
      Exception - when error occurred.
    • addForDeletion

      public void addForDeletion(String path) throws Exception
      Add path to be deleted.
      Specified by:
      addForDeletion in interface IRemoteRepository2
      Parameters:
      path - The relative path of the item from the root of the repo (should not start with a /)
      Throws:
      Exception - when error occurred.
    • getLocalDirectory

      public File getLocalDirectory()
      Getter for local directory.
      Specified by:
      getLocalDirectory in interface IRemoteRepository2
      Returns:
      local directory file object.
    • getRecentlyDeletedFiles

      public String[] getRecentlyDeletedFiles() throws Exception
      Get recently deleted files.
      Specified by:
      getRecentlyDeletedFiles in interface IRemoteRepository2
      Returns:
      Array of paths of deleted files.
      Throws:
      Exception - when error occurred.
    • commit

      public String commit(String[] onVersions, String comment) throws Exception
      Commit files in the current stack.
      Specified by:
      commit in interface IRemoteRepository2
      Parameters:
      onVersions - if a version defined, then commit must be just after this version. Otherwise, (if a remote repository was updated after rebase), commit shouldn't be processed and should return null. If a version is null, then commit can be after any version, i.e. a previous version shouldn't be checked. It can be several versions defined since the glossary will be committed after project_save.tmx.
      comment - comment for commit
      Returns:
      resulted commit name.
      Throws:
      Exception - when error occurred.
    • deleteDirectory

      public static boolean deleteDirectory(File path)
      Delete target directory.
      Parameters:
      path - to be deleted.
      Returns:
      true when succeeded, otherwise false.
    • getDefaultBranchName

      public static String getDefaultBranchName(org.eclipse.jgit.lib.Repository repository)
      Retrieve default branch name from repository.
      Parameters:
      repository - target repository.
      Returns:
      default branch name, ordinary "main" (recent popular) or "master" (old default)
    • isGitRepository

      public static boolean isGitRepository(String url)
      Determines whether the supplied URL represents a valid Git repository.

      Does the equivalent of git ls-remote url.

      Parameters:
      url - URL of supposed remote repository
      Returns:
      true if the repository appears to be valid, false otherwise