Package com._1c.g5.v8.dt.compare.git
Class GitCompareUtils
- java.lang.Object
- 
- com._1c.g5.v8.dt.compare.git.GitCompareUtils
 
- 
 public final class GitCompareUtils extends Object Utility class to Git infrastructure and the EDT mechanism of comparison and merge.
- 
- 
Field SummaryFields Modifier and Type Field Description static intCOMMIT_HASH_PREFIX_LENGTHThe prefix length of commit hash.static StringINDEXThe index revision identifier.
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static ComparisonScopebuildComparisonScope(String projectPath, List<FileDiff> diffs, IQualifiedNameFilePathConverter filePathConverter, boolean isThreeWay)Builds a comparison scope according to given diffs.static List<String>findAddedProjectPaths(List<FileDiff> diffs)Finds the added project paths from the given collection of diffs.static List<String>findDeletedProjectPaths(List<FileDiff> diffs)Finds the deleted project paths from the given collection of diffs.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)Returns file diffs for the main and other commits.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)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 Detail- 
INDEXpublic static final String INDEX The index revision identifier.- See Also:
- Constant Field Values
 
 - 
COMMIT_HASH_PREFIX_LENGTHpublic static final int COMMIT_HASH_PREFIX_LENGTH The prefix length of commit hash.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getBaseCommitpublic 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 IOExceptionReturns the base commit of the two given commits.- Parameters:
- firstCommit- the first commit, cannot be- null
- secondCommit- the second commit, cannot be- null
- revWalk- the- RevWalkinstance, cannot be- null
- Returns:
- the base commit or nullif there is no base commit
- Throws:
- IOException- if failed to get the base commit
 
 - 
getRevCommitpublic static org.eclipse.jgit.revwalk.RevCommit getRevCommit(org.eclipse.jgit.lib.Repository repository, String refName, boolean load) throws IOExceptionReturns aRevCommitfor the given ref name.- Parameters:
- repository- the target Git repository, cannot be- null
- refName- the given ref name, cannot be- null
- load-- 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
 
 - 
getRevCommitpublic static org.eclipse.jgit.revwalk.RevCommit getRevCommit(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevWalk revWalk, String refName, boolean load) throws IOExceptionReturns aRevCommitfor the given ref name.- Parameters:
- repository- the target Git repository, cannot be- null
- revWalk- the- RevWalkinstance, cannot be- null
- refName- the given ref name, cannot be- null
- load-- 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
 
 - 
buildComparisonScopepublic 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 be- null
- diffs- the diff entries between compared/merged refs, cannot be- null
- filePathConverter- the qualified name file path converter, cannot be- null
- isThreeWay- tells whether the comparison is three-way
- Returns:
- the comparison scope, never null
 
 - 
findDiffspublic 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 be- null
- mainCommit- the main side commit to compare, may be- null
- otherCommit- the other side commit to compare, may be- null
- useIndex- tells whether to use index for other side
- pathsToFilter- the paths to filter on; paths should be relative to the root of the repository, cannot be- null
- monitor- the progress monitor to indicate progress, cannot be- null
- Returns:
- the file diffs for the main and other commits, never null
- Throws:
- IOException- if failed to read the Git repository
 
 - 
findProjectDiffspublic 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 be- null
- mainCommit- the main side commit to compare, may be- null
- otherCommit- the other side commit to compare, may be- null
- useIndex- tells whether to use index for other side
- projectPath- the path to project; the path should be relative to the root of the repository, cannot be- null
- pathsToFilter- the paths to filter on; paths should be relative to the root of the repository, cannot be- null
- monitor- the progress monitor to indicate progress, cannot be- null
- Returns:
- the file diffs for the main and other commits, never null
- Throws:
- IOException- if failed to read the Git repository
 
 - 
isV8Projectpublic static boolean isV8Project(Path projectPath) Checks whether the project associated with the given path is V8 project.- Parameters:
- projectPath- the project folder path, cannot be- null
- Returns:
- trueif the target project is V8 project,- falseotherwise
 
 - 
replaceBackslashpublic static String replaceBackslash(String path) Replaces all backslashes to slashes in the specified path.- Parameters:
- path- the path to replace backslashes in, cannot be- null
- Returns:
- the path with replaced backslashes to slashes, never null
 
 - 
getStreamByFileNamepublic 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 be- null
- revCommit- the rev commit, cannot be- null
- filePath- the relative file path the input stream to get for, cannot be- null
- monitor- the progress monitor to indicate progress, may be- null
- Returns:
- the input stream, may be null
- Throws:
- IOException- if an error occurs
- org.eclipse.core.runtime.CoreException- if the contents of this storage could not be accessed
 
 - 
getStreamByFileNameFromIndexpublic 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 be- null
- filePath- the relative file path the input stream to get for, cannot be- null
- monitor- the progress monitor to indicate progress, may be- null
- Returns:
- the input stream, may be null
- Throws:
- org.eclipse.core.runtime.CoreException- if the contents of this storage could not be accessed
 
 - 
findDeletedProjectPathspublic static List<String> findDeletedProjectPaths(List<FileDiff> diffs) Finds the deleted project paths from the given collection of diffs.- Parameters:
- diffs- the collection of diffs, cannot be- null
- Returns:
- the list of deleted project paths, never null
 
 - 
findAddedProjectPathspublic static List<String> findAddedProjectPaths(List<FileDiff> diffs) Finds the added project paths from the given collection of diffs.- Parameters:
- diffs- the collection of diffs, cannot be- null
- Returns:
- the list of deleted project paths, never null
 
 - 
getCommitShortNamepublic static String getCommitShortName(org.eclipse.jgit.revwalk.RevCommit revCommit) Returns commit short name.- Parameters:
- revCommit- git commit which short name will be returned, can be- null
- Returns:
- empty string if commit equals null, commit short name otherwise
 
 
- 
 
-