MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / parseHeaders

Method parseHeaders

src/models/GitCommit.js:60–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58 }
59
60 parseHeaders() {
61 const headers = GitCommit.justHeaders(this._commit).split('\n')
62 const hs = []
63 for (const h of headers) {
64 if (h[0] === ' ') {
65 // combine with previous header (without space indent)
66 hs[hs.length - 1] += '\n' + h.slice(1)
67 } else {
68 hs.push(h)
69 }
70 }
71 const obj = {
72 parent: [],
73 }
74 for (const h of hs) {
75 const key = h.slice(0, h.indexOf(' '))
76 const value = h.slice(h.indexOf(' ') + 1)
77 if (Array.isArray(obj[key])) {
78 obj[key].push(value)
79 } else {
80 obj[key] = value
81 }
82 }
83 if (obj.author) {
84 obj.author = parseAuthor(obj.author)
85 }
86 if (obj.committer) {
87 obj.committer = parseAuthor(obj.committer)
88 }
89 return obj
90 }
91
92 static renderHeaders(obj) {
93 let headers = ''

Callers 2

headersMethod · 0.95
_findMergeBaseFunction · 0.80

Calls 3

parseAuthorFunction · 0.90
sliceMethod · 0.80
justHeadersMethod · 0.45

Tested by

no test coverage detected