-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathgit.java
32 lines (28 loc) · 1.29 KB
/
git.java
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
import com.fizzed.blaze.Contexts;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.Status;
import org.slf4j.Logger;
public class git {
static final private Logger log = Contexts.logger();
public void status() throws Exception {
Repository repo = new FileRepositoryBuilder()
.readEnvironment() // scan environment GIT_* variables
.findGitDir() // scan up the file system tree
.build();
try (Git git = new Git(repo)) {
Status status = git.status().call();
log.info("Added: " + status.getAdded());
log.info("Changed: " + status.getChanged());
log.info("Conflicting: " + status.getConflicting());
log.info("ConflictingStageState: " + status.getConflictingStageState());
log.info("IgnoredNotInIndex: " + status.getIgnoredNotInIndex());
log.info("Missing: " + status.getMissing());
log.info("Modified: " + status.getModified());
log.info("Removed: " + status.getRemoved());
log.info("Untracked: " + status.getUntracked());
log.info("UntrackedFolders: " + status.getUntrackedFolders());
}
}
}