Package com._1c.g5.v8.dt.compare.git
Class GitCompareUtils
java.lang.Object
com._1c.g5.v8.dt.compare.git.GitCompareUtils
Utility class to Git infrastructure and the EDT mechanism of comparison and merge.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe prefix length of commit hash.static final StringThe index revision identifier. -
Method Summary
Modifier and TypeMethodDescriptionstatic ComparisonScopebuildComparisonScope(String projectPath, List<FileDiff> diffs, IQualifiedNameFilePathConverter filePathConverter, boolean isThreeWay) Builds a comparison scope according to given diffs.findAddedProjectPaths(List<FileDiff> diffs) Finds the added project paths from the given collection of diffs.findDeletedProjectPaths(List<FileDiff> diffs) Finds the deleted project paths from the given collection of diffs.findDiffs(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevCommit mainCommit, org.eclipse.jgit.revwalk.RevCommit otherCommit, boolean useIndex, List<String> pathsToFilter, org.eclipse.core.runtime.IProgressMonitor monitor) Returns file diffs for the main and other commits.findProjectDiffs(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevCommit mainCommit, org.eclipse.jgit.revwalk.RevCommit otherCommit, boolean useIndex, String projectPath, List<String> pathsToFilter, org.eclipse.core.runtime.IProgressMonitor monitor) Returns file diffs for the main and other commits for the given project.static org.eclipse.jgit.revwalk.RevCommitgetBaseCommit(org.eclipse.jgit.revwalk.RevCommit firstCommit, org.eclipse.jgit.revwalk.RevCommit secondCommit, org.eclipse.jgit.revwalk.RevWalk revWalk) Returns the base commit of the two given commits.static StringgetCommitShortName(org.eclipse.jgit.revwalk.RevCommit revCommit) Returns commit short name.static org.eclipse.jgit.revwalk.RevCommitgetRevCommit(org.eclipse.jgit.lib.Repository repository, String refName, boolean load) Returns aRevCommitfor the given ref name.static org.eclipse.jgit.revwalk.RevCommitgetRevCommit(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevWalk revWalk, String refName, boolean load) Returns aRevCommitfor the given ref name.static InputStreamgetStreamByFileName(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevCommit revCommit, String filePath, org.eclipse.core.runtime.IProgressMonitor monitor) Returns an input stream for the given rev commit and file path.static InputStreamgetStreamByFileNameFromIndex(org.eclipse.jgit.lib.Repository repository, String filePath, org.eclipse.core.runtime.IProgressMonitor monitor) Returns an input stream for the given file path from the Git index.static booleanisV8Project(Path projectPath) Checks whether the project associated with the given path is V8 project.static StringreplaceBackslash(String path) Replaces all backslashes to slashes in the specified path.
-
Field Details
-
INDEX
The index revision identifier.- See Also:
-
COMMIT_HASH_PREFIX_LENGTH
public static final int COMMIT_HASH_PREFIX_LENGTHThe prefix length of commit hash.- See Also:
-
-
Method Details
-
getBaseCommit
public static org.eclipse.jgit.revwalk.RevCommit getBaseCommit(org.eclipse.jgit.revwalk.RevCommit firstCommit, org.eclipse.jgit.revwalk.RevCommit secondCommit, org.eclipse.jgit.revwalk.RevWalk revWalk) throws IOException Returns the base commit of the two given commits.- Parameters:
firstCommit- the first commit, cannot benullsecondCommit- the second commit, cannot benullrevWalk- theRevWalkinstance, cannot benull- Returns:
- the base commit or
nullif there is no base commit - Throws:
IOException- if failed to get the base commit
-
getRevCommit
public static org.eclipse.jgit.revwalk.RevCommit getRevCommit(org.eclipse.jgit.lib.Repository repository, String refName, boolean load) throws IOException Returns aRevCommitfor the given ref name.- Parameters:
repository- the target Git repository, cannot benullrefName- the given ref name, cannot benullload-trueif it needed to load rev commit,falseif it needed to look up only- Returns:
- the
RevCommitassociated with the given ref name, nevernull - Throws:
IOException- if failed to find or load rev commit
-
getRevCommit
public static org.eclipse.jgit.revwalk.RevCommit getRevCommit(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevWalk revWalk, String refName, boolean load) throws IOException Returns aRevCommitfor the given ref name.- Parameters:
repository- the target Git repository, cannot benullrevWalk- theRevWalkinstance, cannot benullrefName- the given ref name, cannot benullload-trueif it needed to load rev commit,falseif it needed to look up only- Returns:
- the
RevCommitassociated with the given ref name, nevernull - Throws:
IOException- if failed to find or load rev commit
-
buildComparisonScope
public static ComparisonScope buildComparisonScope(String projectPath, List<FileDiff> diffs, IQualifiedNameFilePathConverter filePathConverter, boolean isThreeWay) Builds a comparison scope according to given diffs.- Parameters:
projectPath- the project path relative to repository root, cannot benulldiffs- the diff entries between compared/merged refs, cannot benullfilePathConverter- the qualified name file path converter, cannot benullisThreeWay- tells whether the comparison is three-way- Returns:
- the comparison scope, never
null
-
findDiffs
public static List<FileDiff> findDiffs(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevCommit mainCommit, org.eclipse.jgit.revwalk.RevCommit otherCommit, boolean useIndex, List<String> pathsToFilter, org.eclipse.core.runtime.IProgressMonitor monitor) throws IOException Returns file diffs for the main and other commits.- Parameters:
repository- the target Git repository, cannot benullmainCommit- the main side commit to compare, may benullotherCommit- the other side commit to compare, may benulluseIndex- tells whether to use index for other sidepathsToFilter- the paths to filter on; paths should be relative to the root of the repository, cannot benullmonitor- the progress monitor to indicate progress, cannot benull- Returns:
- the file diffs for the main and other commits, never
null - Throws:
IOException- if failed to read the Git repository
-
findProjectDiffs
public static List<FileDiff> findProjectDiffs(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevCommit mainCommit, org.eclipse.jgit.revwalk.RevCommit otherCommit, boolean useIndex, String projectPath, List<String> pathsToFilter, org.eclipse.core.runtime.IProgressMonitor monitor) throws IOException Returns file diffs for the main and other commits for the given project. Also handles diffs of the deleted files for projects that have been created or updated base on the libraries.- Parameters:
repository- the target Git repository, cannot benullmainCommit- the main side commit to compare, may benullotherCommit- the other side commit to compare, may benulluseIndex- tells whether to use index for other sideprojectPath- the path to project; the path should be relative to the root of the repository, cannot benullpathsToFilter- the paths to filter on; paths should be relative to the root of the repository, cannot benullmonitor- the progress monitor to indicate progress, cannot benull- Returns:
- the file diffs for the main and other commits, never
null - Throws:
IOException- if failed to read the Git repository
-
isV8Project
Checks whether the project associated with the given path is V8 project.- Parameters:
projectPath- the project folder path, cannot benull- Returns:
trueif the target project is V8 project,falseotherwise
-
replaceBackslash
Replaces all backslashes to slashes in the specified path.- Parameters:
path- the path to replace backslashes in, cannot benull- Returns:
- the path with replaced backslashes to slashes, never
null
-
getStreamByFileName
public static InputStream getStreamByFileName(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevCommit revCommit, String filePath, org.eclipse.core.runtime.IProgressMonitor monitor) throws IOException, org.eclipse.core.runtime.CoreException Returns an input stream for the given rev commit and file path.- Parameters:
repository- the Git repository, cannot benullrevCommit- the rev commit, cannot benullfilePath- the relative file path the input stream to get for, cannot benullmonitor- the progress monitor to indicate progress, may benull- Returns:
- the input stream, may be
null - Throws:
IOException- if an error occursorg.eclipse.core.runtime.CoreException- if the contents of this storage could not be accessed
-
getStreamByFileNameFromIndex
public static InputStream getStreamByFileNameFromIndex(org.eclipse.jgit.lib.Repository repository, String filePath, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException Returns an input stream for the given file path from the Git index.- Parameters:
repository- the Git repository, cannot benullfilePath- the relative file path the input stream to get for, cannot benullmonitor- the progress monitor to indicate progress, may benull- Returns:
- the input stream, may be
null - Throws:
org.eclipse.core.runtime.CoreException- if the contents of this storage could not be accessed
-
findDeletedProjectPaths
Finds the deleted project paths from the given collection of diffs.- Parameters:
diffs- the collection of diffs, cannot benull- Returns:
- the list of deleted project paths, never
null
-
findAddedProjectPaths
Finds the added project paths from the given collection of diffs.- Parameters:
diffs- the collection of diffs, cannot benull- Returns:
- the list of deleted project paths, never
null
-
getCommitShortName
Returns commit short name.- Parameters:
revCommit- git commit which short name will be returned, can benull- Returns:
- empty string if commit equals
null, commit short name otherwise
-