()
| 26 | public 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 | } |
nothing calls this directly
no test coverage detected