forked from reposense/RepoSense
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitRevParse.java
More file actions
26 lines (23 loc) · 871 Bytes
/
GitRevParse.java
File metadata and controls
26 lines (23 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package reposense.git;
import java.nio.file.Path;
import reposense.git.exception.GitBranchException;
import reposense.model.RepoConfiguration;
import reposense.system.CommandRunner;
/**
* Contains git rev parse related functionalities.
* Git rev parse is responsible for verifying the existence of a particular branch.
*/
public class GitRevParse {
/**
* Asserts that the branch in {@code config} exists.
* @throws GitBranchException when the branch does not exist.
*/
public static void assertBranchExists(RepoConfiguration config, Path repoRoot) throws GitBranchException {
String command = String.format("git rev-parse --verify %s", config.getBranch());
try {
CommandRunner.runCommand(repoRoot, command);
} catch (RuntimeException rte) {
throw new GitBranchException(rte);
}
}
}