(stdout: string)
| 147 | */ |
| 148 | |
| 149 | export 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 | }; |
searching dependent graphs…