MCPcopy
hub / github.com/creationix/js-git / decodeCommit

Function decodeCommit

lib/object-codec.js:156–190  ·  view source on GitHub ↗
(body)

Source from the content-addressed store, hash-verified

154}
155
156function decodeCommit(body) {
157 var i = 0;
158 var start;
159 var key;
160 var parents = [];
161 var commit = {
162 tree: "",
163 parents: parents,
164 author: "",
165 committer: "",
166 message: ""
167 };
168 while (body[i] !== 0x0a) {
169 start = i;
170 i = indexOf(body, 0x20, start);
171 if (i < 0) throw new SyntaxError("Missing space");
172 key = bodec.toRaw(body, start, i++);
173 start = i;
174 i = indexOf(body, 0x0a, start);
175 if (i < 0) throw new SyntaxError("Missing linefeed");
176 var value = bodec.toUnicode(body, start, i++);
177 if (key === "parent") {
178 parents.push(value);
179 }
180 else {
181 if (key === "author" || key === "committer") {
182 value = decodePerson(value);
183 }
184 commit[key] = value;
185 }
186 }
187 i++;
188 commit.message = bodec.toUnicode(body, i, body.length);
189 return commit;
190}
191
192function decodeTag(body) {
193 var i = 0;

Callers

nothing calls this directly

Calls 2

indexOfFunction · 0.85
decodePersonFunction · 0.85

Tested by

no test coverage detected