(ref, prefix, errors)
| 247 | } |
| 248 | |
| 249 | function validateImmutableRef(ref, prefix, errors) { |
| 250 | if (!isNonEmptyString(ref)) { |
| 251 | errors.push(`${prefix}: "source.ref" must be a non-empty string when provided`); |
| 252 | return; |
| 253 | } |
| 254 | |
| 255 | if (ref.startsWith("refs/heads/")) { |
| 256 | errors.push(`${prefix}: "source.ref" must be a tag or commit SHA, not a branch ref`); |
| 257 | return; |
| 258 | } |
| 259 | |
| 260 | if (["main", "master", "develop", "development", "dev", "trunk"].includes(ref)) { |
| 261 | errors.push(`${prefix}: "source.ref" must be a tag or commit SHA, not a branch name`); |
| 262 | } |
| 263 | |
| 264 | if (ref.startsWith("refs/") && !ref.startsWith("refs/tags/")) { |
| 265 | errors.push(`${prefix}: "source.ref" must be a tag ref or commit SHA`); |
| 266 | } |
| 267 | |
| 268 | if (/^[0-9a-f]+$/i.test(ref) && ref.length !== 40) { |
| 269 | errors.push(`${prefix}: "source.ref" must be a full 40-character commit SHA when referencing a commit`); |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | function validateCommitSha(sha, prefix, errors) { |
| 274 | if (!isNonEmptyString(sha)) { |
no test coverage detected