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

Method getCommit

src/main/java/club/qqtim/command/Commit.java:65–85  ·  view source on GitHub ↗
(String id)

Source from the content-addressed store, hash-verified

63
64
65 public static CommitObject getCommit(String id) {
66 final byte[] commit = ZitContext.getObject(id, ConstantVal.COMMIT);
67 assert commit != null;
68 final String commitContent = new String(commit, Charsets.UTF_8);
69 final String[] lines = commitContent.split(ConstantVal.NEW_LINE);
70
71 List<String> parents = new ArrayList<>();
72 CommitObject commitObject = new CommitObject();
73 Arrays.stream(lines).forEach(line -> {
74 final String[] fields = line.split(ConstantVal.SINGLE_SPACE);
75 if (ConstantVal.TREE.equals(fields[0])) {
76 commitObject.setTree(fields[1]);
77 }
78 if (ConstantVal.PARENT.equals(fields[0])) {
79 parents.add(fields[1]);
80 }
81 });
82 commitObject.setParents(parents);
83 commitObject.setMessage(commitContent);
84 return commitObject;
85 }
86}

Callers 9

callMethod · 0.95
checkoutMethod · 0.95
runMethod · 0.95
runMethod · 0.95
callMethod · 0.95
runMethod · 0.95
runMethod · 0.95

Calls 1

getObjectMethod · 0.95

Tested by

no test coverage detected