Class GitCli
- java.lang.Object
-
- org.craftercms.studio.impl.v2.utils.git.GitCli
-
public class GitCli extends Object
Allows doing Git operations throw the CLI.
If you ever use this class, please lock/synchronize the calls (hopefully with theGeneralLockService)- Since:
- 3.1.23
- Author:
- Sumer Jabri, Alfonso Vasquez
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classGitCli.GitCommandLine
-
Field Summary
Fields Modifier and Type Field Description GitCliOutputExceptionResolverCOMMIT_EX_RESOLVERGitCliOutputExceptionResolverDEFAULT_EX_RESOLVER
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String directory, String... paths)Stringcommit(String directory, String author, String message, String... paths)protected StringexecuteGitCommand(String directory, GitCli.GitCommandLine commandLine)protected StringexecuteGitCommand(String directory, GitCli.GitCommandLine commandLine, GitCliOutputExceptionResolver exceptionResolver)booleanisRepoClean(String directory)Stringrestore(String directory, String... paths)Remove the given paths from the index and discard changes
-
-
-
Field Detail
-
DEFAULT_EX_RESOLVER
public final GitCliOutputExceptionResolver DEFAULT_EX_RESOLVER
-
COMMIT_EX_RESOLVER
public final GitCliOutputExceptionResolver COMMIT_EX_RESOLVER
-
-
Constructor Detail
-
GitCli
public GitCli()
-
GitCli
public GitCli(String gitProcName, int gitProcWaitForTimeoutSecs, int gitProcDestroyWaitForTimeoutSecs)
-
-
Method Detail
-
executeGitCommand
protected String executeGitCommand(String directory, GitCli.GitCommandLine commandLine) throws IOException, InterruptedException
- Throws:
IOExceptionInterruptedException
-
executeGitCommand
protected String executeGitCommand(String directory, GitCli.GitCommandLine commandLine, GitCliOutputExceptionResolver exceptionResolver) throws IOException, InterruptedException
- Throws:
IOExceptionInterruptedException
-
add
public void add(String directory, String... paths) throws GitCliException
- Throws:
GitCliException
-
restore
public String restore(String directory, String... paths) throws GitCliException
Remove the given paths from the index and discard changes- Parameters:
directory- the git repository directorypaths- the paths to restore- Returns:
- the output of the git restore command
- Throws:
GitCliException
-
commit
public String commit(String directory, String author, String message, String... paths) throws GitCliException
- Throws:
GitCliException
-
isRepoClean
public boolean isRepoClean(String directory) throws GitCliException
- Throws:
GitCliException
-
-