MCPcopy Create free account
hub / github.com/ReZeroS/git / run

Method run

src/main/java/club/qqtim/command/Status.java:28–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26public class Status implements Runnable {
27
28 @Override
29 public void run() {
30 final String headId = ZitContext.getId(ConstantVal.HEAD_ALIAS);
31 final String branchName = ZitContext.getBranchName();
32 if (Objects.nonNull(branchName)) {
33 log.info("On branch * {}", branchName);
34 } else {
35 if (headId != null) {
36 log.info("HEAD detached at {}", headId.substring(0, 11));
37 }
38 }
39
40 final String mergeHeadId = ZitContext.getRef(ConstantVal.MERGE_HEAD).getValue();
41 if (Objects.nonNull(mergeHeadId)) {
42 log.info("Merging with {}", mergeHeadId.substring(0, 11));
43 }
44
45
46
47 final String indexContent = FileUtil.getFileAsString(ConstantVal.INDEX, ConstantVal.NONE);
48
49 Map<String, String> indexItems = new Gson().fromJson(indexContent, new TypeToken<Map<String, String>>(){}.getType());
50
51 if (headId != null) {
52 log.info("\nChanges to be committed:\n");
53 final String headTree = Commit.getCommit(headId).getTree();
54 final List<SimplyChange> toBeCommitted = DiffUtil.iteratorChangedFiles(ReadTree.getTree(headTree), indexItems);
55 toBeCommitted.forEach(simplyChange -> log.info(simplyChange.toString()));
56 }
57
58
59 log.info("\nChanges not staged for commit:\n");
60 final List<SimplyChange> notStaged = DiffUtil.iteratorChangedFiles(indexItems, Diff.getWorkingTree());
61 notStaged.forEach(simplyChange -> log.info(simplyChange.toString()));
62
63 }
64}

Callers

nothing calls this directly

Calls 9

getIdMethod · 0.95
getBranchNameMethod · 0.95
getRefMethod · 0.95
getFileAsStringMethod · 0.95
getTreeMethod · 0.95
getCommitMethod · 0.95
iteratorChangedFilesMethod · 0.95
getWorkingTreeMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected