MCPcopy
hub / github.com/yarnpkg/yarn / parseRefs

Function parseRefs

src/util/git/git-ref-resolver.js:149–175  ·  view source on GitHub ↗
(stdout: string)

Source from the content-addressed store, hash-verified

147 */
148
149export const parseRefs = (stdout: string): GitRefs => {
150 // store references
151 const refs = new Map();
152
153 // line delimited
154 const refLines = stdout.split('\n');
155
156 for (const line of refLines) {
157 const match = GIT_REF_LINE_REGEXP.exec(line);
158
159 if (match) {
160 const [, sha, tagName] = match;
161
162 // As documented in gitrevisions:
163 // https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html#_specifying_revisions
164 // "A suffix ^ followed by an empty brace pair means the object could be a tag,
165 // and dereference the tag recursively until a non-tag object is found."
166 // In other words, the hash without ^{} is the hash of the tag,
167 // and the hash with ^{} is the hash of the commit at which the tag was made.
168 const name = removeSuffix(tagName, '^{}');
169
170 refs.set(name, sha);
171 }
172 }
173
174 return refs;
175};

Callers 4

setRefRemoteMethod · 0.90
setRefHostedMethod · 0.90
resolveDefaultBranchMethod · 0.90
parseFunction · 0.90

Calls 1

removeSuffixFunction · 0.90

Tested by 1

parseFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…