Package com._1c.g5.v8.dt.common.git
Class GitUtils
- java.lang.Object
-
- com._1c.g5.v8.dt.common.git.GitUtils
-
public class GitUtils extends Object
The Git and refactoring mechanism integration utility methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddFilesToGitIndex(org.eclipse.core.resources.IProject project, Collection<org.eclipse.core.runtime.IPath> oldAbsolutePaths, Collection<org.eclipse.core.runtime.IPath> newAbsolutePaths, boolean cached)Adds the files associated with the given new and old absolute paths to the Git index.static org.eclipse.jgit.lib.RepositorygetGitRepository(org.eclipse.core.resources.IResource resource)Determines the Git repository containing the given resource.static org.eclipse.jgit.lib.RepositorygetGitRepository(org.eclipse.core.runtime.IPath path)Determines the Git repository containing the givenIPath.static org.eclipse.core.resources.IProject[]getProjectsInRepository(org.eclipse.jgit.lib.Repository repository)Determines projects associated with the given repository.static voidrunGitAddCommand(org.eclipse.core.resources.IProject project, Collection<org.eclipse.core.runtime.IPath> absolutePaths)Runs Git add command for the files associated with the given absolute paths if the given project in the Git repository.static voidrunGitAddCommand(org.eclipse.jgit.lib.Repository repository, Collection<org.eclipse.core.runtime.IPath> absolutePaths)Runs Git add command for the given repository and files associated with the given absolute paths.static voidrunGitRmCommand(org.eclipse.core.resources.IProject project, Collection<org.eclipse.core.runtime.IPath> absolutePaths, boolean cached)Runs Git rm command for the files associated with the given absolute paths if the given project in the Git repository.static voidrunGitRmCommand(org.eclipse.jgit.lib.Repository repository, Collection<org.eclipse.core.runtime.IPath> absolutePaths, boolean cached)Runs Git rm command for the given repository and files associated with the given absolute paths.
-
-
-
Method Detail
-
getGitRepository
public static org.eclipse.jgit.lib.Repository getGitRepository(org.eclipse.core.resources.IResource resource)
Determines the Git repository containing the given resource. Should not close the repository after work with it was finished.- Parameters:
resource- the resource to get the Git repository for, cannot benull- Returns:
- the associated with the given resource Git repository or
nullif no repository associates with the given resource
-
getGitRepository
public static org.eclipse.jgit.lib.Repository getGitRepository(org.eclipse.core.runtime.IPath path)
Determines the Git repository containing the givenIPath. Should not close the repository after work with it was finished.- Parameters:
path- the path to get the Git repository for, cannot benull- Returns:
- the associated with the given path Git repository or
nullif no repository associates with the given path
-
getProjectsInRepository
public static org.eclipse.core.resources.IProject[] getProjectsInRepository(org.eclipse.jgit.lib.Repository repository)
Determines projects associated with the given repository.- Parameters:
repository- the Git repository to lookup projects in, cannot benull- Returns:
- the projects, associated with the given repository, never
null
-
runGitAddCommand
public static void runGitAddCommand(org.eclipse.jgit.lib.Repository repository, Collection<org.eclipse.core.runtime.IPath> absolutePaths) throws org.eclipse.core.runtime.CoreExceptionRuns Git add command for the given repository and files associated with the given absolute paths.- Parameters:
repository- the given Git repository, can not benullabsolutePaths- the given absolute paths to files, can not benull- Throws:
org.eclipse.core.runtime.CoreException- if an error occurred while calling Git add command
-
runGitAddCommand
public static void runGitAddCommand(org.eclipse.core.resources.IProject project, Collection<org.eclipse.core.runtime.IPath> absolutePaths) throws org.eclipse.core.runtime.CoreExceptionRuns Git add command for the files associated with the given absolute paths if the given project in the Git repository.- Parameters:
project- the project the target files from, can not benullabsolutePaths- the given absolute paths to files, can not benull- Throws:
org.eclipse.core.runtime.CoreException- if an error occurred while finding Git repo or calling Git add command
-
runGitRmCommand
public static void runGitRmCommand(org.eclipse.jgit.lib.Repository repository, Collection<org.eclipse.core.runtime.IPath> absolutePaths, boolean cached) throws org.eclipse.core.runtime.CoreExceptionRuns Git rm command for the given repository and files associated with the given absolute paths.- Parameters:
repository- the given Git repository, can not benullabsolutePaths- the given absolute paths to files, can not benullcached-trueif files should only be removed from index,falseif files should also be deleted from the working directory- Throws:
org.eclipse.core.runtime.CoreException- if an error occurred while calling Git rm command
-
runGitRmCommand
public static void runGitRmCommand(org.eclipse.core.resources.IProject project, Collection<org.eclipse.core.runtime.IPath> absolutePaths, boolean cached) throws org.eclipse.core.runtime.CoreExceptionRuns Git rm command for the files associated with the given absolute paths if the given project in the Git repository.- Parameters:
project- the project the target files from, can not benullabsolutePaths- the given absolute paths to files, can not benullcached-trueif files should only be removed from index,falseif files should also be deleted from the working directory- Throws:
org.eclipse.core.runtime.CoreException- if an error occurred while finding Git repo or calling Git rm command
-
addFilesToGitIndex
public static void addFilesToGitIndex(org.eclipse.core.resources.IProject project, Collection<org.eclipse.core.runtime.IPath> oldAbsolutePaths, Collection<org.eclipse.core.runtime.IPath> newAbsolutePaths, boolean cached) throws org.eclipse.core.runtime.CoreExceptionAdds the files associated with the given new and old absolute paths to the Git index. Runs Git add command for the new paths and Git rm command for the old paths.
It is important that the collection of old and new paths are not intersecting.- Parameters:
project- the project the target files from, can not benulloldAbsolutePaths- the old absolute paths, can not benullnewAbsolutePaths- the new absolute paths, can not benullcached-trueif old files should only be removed from index,falseif old files should also be deleted from the working directory- Throws:
org.eclipse.core.runtime.CoreException- if an error occurred while finding Git repo or adding files to index
-
-