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 class
GitCli.GitCommandLine
-
Field Summary
Fields Modifier and Type Field Description GitCliOutputExceptionResolver
COMMIT_EX_RESOLVER
GitCliOutputExceptionResolver
DEFAULT_EX_RESOLVER
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(String directory, String... paths)
String
commit(String directory, String author, String message, String... paths)
protected String
executeGitCommand(String directory, GitCli.GitCommandLine commandLine)
protected String
executeGitCommand(String directory, GitCli.GitCommandLine commandLine, GitCliOutputExceptionResolver exceptionResolver)
boolean
isRepoClean(String directory)
String
restore(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:
IOException
InterruptedException
-
executeGitCommand
protected String executeGitCommand(String directory, GitCli.GitCommandLine commandLine, GitCliOutputExceptionResolver exceptionResolver) throws IOException, InterruptedException
- Throws:
IOException
InterruptedException
-
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
-
-