MCPcopy Create free account
hub / github.com/github/awesome-copilot / validateImmutableRef

Function validateImmutableRef

eng/external-plugin-validation.mjs:249–271  ·  view source on GitHub ↗
(ref, prefix, errors)

Source from the content-addressed store, hash-verified

247}
248
249function 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
273function validateCommitSha(sha, prefix, errors) {
274 if (!isNonEmptyString(sha)) {

Callers 1

validateGitHubSourceFunction · 0.85

Calls 1

isNonEmptyStringFunction · 0.85

Tested by

no test coverage detected