Class GitCli
java.lang.Object
org.craftercms.studio.impl.v2.utils.git.GitCli
Allows doing Git operations throw the CLI.
If you ever use this class, please lock/synchronize the calls (hopefully with the
If you ever use this class, please lock/synchronize the calls (hopefully with the
GeneralLockService)- Since:
- 3.1.23
- Author:
- Sumer Jabri, Alfonso Vasquez
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidGit clean (optionally -f)protected voiddoExecuteGitCommand(GitCli.GitCommandLine commandLine) booleanisRepoClean(File directory) Check if the repository is clean, meaning there are no changes to commitvoidGit reset --hardvoidRemove the given paths from the index and discard changes
-
Field Details
-
DEFAULT_EX_RESOLVER
-
COMMIT_EX_RESOLVER
-
-
Constructor Details
-
GitCli
public GitCli() -
GitCli
public GitCli(String gitProcName, int gitProcWaitForTimeoutSecs, int gitProcDestroyWaitForTimeoutSecs, int maxProcessOutputBytes)
-
-
Method Details
-
doExecuteGitCommand
protected void doExecuteGitCommand(GitCli.GitCommandLine commandLine) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
add
- Throws:
GitCliException
-
restore
Remove the given paths from the index and discard changes- Parameters:
directory- the git repository directorypaths- the paths to restore- Throws:
GitCliException
-
commit
public String commit(File directory, String author, String message, String... paths) throws GitCliException - Throws:
GitCliException
-
isRepoClean
Check if the repository is clean, meaning there are no changes to commit- Parameters:
directory- the git repository directory- Returns:
- true if the repository is clean, false otherwise
- Throws:
GitCliException- if the git status command fails
-
resetHard
Git reset --hard- Parameters:
repoDir- the git repository directory- Throws:
GitCliException- if the git reset command fails
-
clean
Git clean (optionally -f)- Parameters:
repoDir- the git repository directoryforce- true to force cleanrecursive- true to clean directories recursively- Throws:
GitCliException- if the git clean command fails
-