Package org.omegat.core.team2.impl
Class GITRemoteRepository2
- java.lang.Object
-
- org.omegat.core.team2.impl.GITRemoteRepository2
-
- All Implemented Interfaces:
IRemoteRepository2
public class GITRemoteRepository2 extends java.lang.Object implements IRemoteRepository2
GIT repository connection implementation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.omegat.core.team2.IRemoteRepository2
IRemoteRepository2.BadRepositoryException, IRemoteRepository2.NetworkException
-
-
Constructor Summary
Constructors Constructor Description GITRemoteRepository2()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddForCommit(java.lang.String path)Add the specified file in preparation for commit (e.g.voidaddForDeletion(java.lang.String path)remove the specified file in preparation for commit (e.g.java.lang.Stringcommit(java.lang.String[] onVersions, java.lang.String comment)Commit to repository after specified version, or after any version if 'null' specified.static booleandeleteDirectory(java.io.File path)static java.lang.StringgetDefaultBranchName(org.eclipse.jgit.lib.Repository repository)Retrieve default branch name from repository.java.lang.StringgetFileVersion(java.lang.String file)Get file version.java.io.FilegetLocalDirectory()Return directory where this repo is in.java.lang.String[]getRecentlyDeletedFiles()Returns a list of files or directories (empty or not) that have been deleted since the last call to this function, relative to the repository root that has been checked out.voidinit(RepositoryDefinition repo, java.io.File dir, ProjectTeamSettings teamSettings)Initialize repository provider.static booleanisGitRepository(java.lang.String url)Determines whether or not the supplied URL represents a valid Git repository.voidswitchToVersion(java.lang.String version)
-
-
-
Method Detail
-
init
public void init(RepositoryDefinition repo, java.io.File dir, ProjectTeamSettings teamSettings) throws java.lang.Exception
Description copied from interface:IRemoteRepository2Initialize repository provider.- Specified by:
initin interfaceIRemoteRepository2- Parameters:
repo- repository description instancedir- directory for store filesteamSettings- team settings object for project- Throws:
java.lang.Exception
-
getFileVersion
public java.lang.String getFileVersion(java.lang.String file) throws java.io.IOExceptionDescription copied from interface:IRemoteRepository2Get file version.- Specified by:
getFileVersionin interfaceIRemoteRepository2- Throws:
java.io.IOException
-
switchToVersion
public void switchToVersion(java.lang.String version) throws java.lang.Exception- Specified by:
switchToVersionin interfaceIRemoteRepository2- Throws:
java.lang.Exception
-
addForCommit
public void addForCommit(java.lang.String path) throws java.lang.ExceptionDescription copied from interface:IRemoteRepository2Add the specified file in preparation for commit (e.g.git add,svn add).- Specified by:
addForCommitin interfaceIRemoteRepository2- Parameters:
path- The relative path of the item from the root of the repo (should not start with a/)- Throws:
java.lang.Exception
-
addForDeletion
public void addForDeletion(java.lang.String path) throws java.lang.ExceptionDescription copied from interface:IRemoteRepository2remove the specified file in preparation for commit (e.g.git rm,svn delete).- Specified by:
addForDeletionin interfaceIRemoteRepository2- Parameters:
path- The relative path of the item from the root of the repo (should not start with a/)- Throws:
java.lang.Exception
-
getLocalDirectory
public java.io.File getLocalDirectory()
Description copied from interface:IRemoteRepository2Return directory where this repo is in.- Specified by:
getLocalDirectoryin interfaceIRemoteRepository2- Returns:
- The directory, e.g. /path/to/omegatdir/.repositories/https_site.com_myproject.git
-
getRecentlyDeletedFiles
public java.lang.String[] getRecentlyDeletedFiles() throws java.lang.ExceptionDescription copied from interface:IRemoteRepository2Returns a list of files or directories (empty or not) that have been deleted since the last call to this function, relative to the repository root that has been checked out. If this function is called for the first time, it returns the empty list.- Specified by:
getRecentlyDeletedFilesin interfaceIRemoteRepository2- Returns:
- Throws:
java.lang.Exception
-
commit
public java.lang.String commit(java.lang.String[] onVersions, java.lang.String comment) throws java.lang.ExceptionDescription copied from interface:IRemoteRepository2Commit to repository after specified version, or after any version if 'null' specified.- Specified by:
commitin interfaceIRemoteRepository2- Parameters:
onVersions- if version defined, then commit must be just after this version. Otherwise(if remote repository was updated after rebase), commit shouldn't be processed and should return null. If version is null, then commit can be after any version, i.e. previous version shouldn't be checked. It can be several versions defined since glossary will be committed after project_save.tmx.comment- comment for commit- Returns:
- new version if commit was processed, or null if remote repository was updated by other user
- Throws:
java.lang.Exception
-
deleteDirectory
public static boolean deleteDirectory(java.io.File path)
-
getDefaultBranchName
public static java.lang.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(java.lang.String url)
Determines whether or not 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 repository appears to be valid, false otherwise
-
-