forked from reposense/RepoSense
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitChecker.java
More file actions
40 lines (30 loc) · 1.26 KB
/
GitChecker.java
File metadata and controls
40 lines (30 loc) · 1.26 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
package reposense.git;
import java.util.Date;
import java.util.logging.Logger;
import reposense.commits.model.CommitResult;
import reposense.system.CommandRunner;
import reposense.system.LogsManager;
public class GitChecker {
private static final Logger logger = LogsManager.getLogger(GitChecker.class);
public static void checkOutToRecentBranch(String root) {
checkout(root, "-");
}
public static void checkoutBranch(String root, String branch) {
checkout(root, branch);
}
public static void checkOutToCommit(String root, CommitResult commit) {
logger.info("Checking out " + commit.getHash() + "time:" + commit.getTime());
checkout(root, commit.getHash());
}
public static void checkout(String root, String commitHash) {
CommandRunner.checkout(root, commitHash);
}
/**
* Checks out to the latest commit before {@code untilDate} in {@code branchName} branch
* if {@code untilDate} is not null.
* @throws CommitNotFoundException if commits before {@code untilDate} cannot be found.
*/
public static void checkoutToDate(String root, String branchName, Date untilDate) throws CommitNotFoundException {
CommandRunner.checkoutToDate(root, branchName, untilDate);
}
}