{"record":{"id":"475b235fc7a623d3","repo":"zed-industries/zed","slug":"could-not-resolve-ref-ref-against-repo-url","errorCode":null,"errorMessage":"could not resolve ref '{ref}' against {repo_url}. Push the commit/tag, or pass a full commit SHA.","messagePattern":"could not resolve ref '(.+?)' against (.+?)\\. Push the commit/tag, or pass a full commit SHA\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"crates/eval_cli/zed_eval/source.py","lineNumber":164,"sourceCode":"            repo_url,\n            ref,\n            f\"refs/tags/{ref}\",\n            f\"refs/heads/{ref}\",\n        ]\n    )\n    entries: list[tuple[str, str]] = []\n    for line in output.splitlines():\n        sha, _, name = line.partition(\"\\t\")\n        if sha and name:\n            entries.append((name, sha))\n    # An annotated tag yields both the tag object and a peeled \"<ref>^{}\" entry\n    # pointing at the underlying commit; the commit is what we want to build.\n    for name, sha in entries:\n        if name.endswith(\"^{}\"):\n            return sha\n    if entries:\n        return entries[0][1]\n    raise ValueError(\n        f\"could not resolve ref '{ref}' against {repo_url}. \"\n        \"Push the commit/tag, or pass a full commit SHA.\"\n    )\n\n\ndef current_ref_name() -> str | None:\n    try:\n        ref_name = git_output([\"rev-parse\", \"--abbrev-ref\", \"HEAD\"])\n    except (OSError, subprocess.CalledProcessError):\n        return None\n    return None if ref_name == \"HEAD\" else ref_name\n\n\ndef current_tracked_patch(base_sha: str) -> str:\n    result = subprocess.run(\n        [\"git\", \"diff\", \"--binary\", base_sha],\n        cwd=repo_root(),\n        check=True,","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/eval_cli/zed_eval/source.py#L146-L182","documentation":"resolve_remote_ref parses `git ls-remote <repo_url> <ref>` output and prefers the peeled '^{}' entry for annotated tags. If the output contains no entries at all, the ref does not exist on the remote, and this ValueError tells you to push the commit/tag or supply a full 40-character commit SHA, which needs no ref resolution.","triggerScenarios":"Passing a branch or commit that was never pushed; giving a local-only short sha where a ref name is expected; a typo in the ref; a tag that exists locally but was never pushed; the ref living on a fork while repo_url points at upstream.","commonSituations":"Building an eval from a local-only branch; forgetting git push --tags; using short shas in automation; wrong remote URL after a repo migration.","solutions":["Push first: git push origin <branch> (and git push origin <tag> for tags)","Or pass the full 40-character commit SHA, which bypasses remote ref resolution","Double-check the ref spelling and that repo_url is the remote you actually pushed to","For annotated tags, ensure the tag object itself is pushed, not just the commit"],"exampleFix":"# before\nbuild_source(base_sha=\"feature-branch\")  # ValueError: could not resolve ref 'feature-branch'\n\n# after\ngit push origin feature-branch\nbuild_source(base_sha=\"feature-branch\")\n# or skip resolution entirely:\nbuild_source(base_sha=\"<full-40-char-sha>\")","handlingStrategy":"validation","validationCode":"import re, subprocess\n\nFULL_SHA = re.compile(r\"^[0-9a-fA-F]{40}$\")\nif not FULL_SHA.match(ref):\n    listing = subprocess.run([\"git\", \"ls-remote\", repo_url, ref], capture_output=True, text=True)\n    if not listing.stdout.strip():\n        raise SystemExit(f\"ref {ref!r} not on {repo_url}; push it or use a full 40-char SHA\")","typeGuard":"import re\n\ndef is_full_commit_sha(ref: str) -> bool:\n    return bool(re.fullmatch(r\"[0-9a-fA-F]{40}\", ref))","tryCatchPattern":"try:\n    sha = resolve_remote_ref(repo_url, ref)\nexcept ValueError as err:\n    raise SystemExit(f\"push {ref} first, or pass a full sha: {err}\")","preventionTips":["Push branches and tags before referencing them in eval sources","Prefer full 40-char shas in automation — they never need remote ref resolution","Verify the remote URL matches where you actually pushed"],"tags":["git","ref-resolution","remote","push"],"backgroundTag":"git-ref-not-found","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}