Skip to content

extract stamps the invoking repo's HEAD into built_at_commit when run against another repo #2696

Closed

Description

@C0KERNEL

Description

When graphify extract <target> is invoked from a working directory inside a different git repository, the resulting graph.json (and therefore GRAPH_REPORT.md) records the invoking repo's HEAD as built_at_commit, not the target's.

This is the same cwd-anchoring mistake that #2316 fixed for watch/update — it survives in the extract path:

Impact

Reproduction (deterministic, no API key needed)

mkdir A B
git -C A init && git -C A commit --allow-empty -m target
git -C B init && git -C B commit --allow-empty -m invoker
mkdir -p A/graphify-out
cd B
python - <<'EOF'
import json, networkx as nx
from graphify.export import to_json
G = nx.Graph(); G.add_node("n", label="n")
to_json(G, {0: ["n"]}, "../A/graphify-out/graph.json", force=True)
print(json.load(open("../A/graphify-out/graph.json"))["built_at_commit"])
EOF
git -C ../A rev-parse HEAD   # expected value
git rev-parse HEAD           # actual stamped value (invoker's HEAD)

The stamped value is B's HEAD; it should be A's. The same happens end-to-end via graphify extract ../A run from inside B.

Expected

built_at_commit identifies the HEAD of the repository the graph describes, regardless of where the command was invoked from — matching the behavior watch/update already have since #2316.

Environment

Observed on 0.9.39 (uv tool install) and confirmed present on the current v8 tip (0.9.41, e4bfd2a) by code inspection: export.py _git_head() takes no cwd, and the extract-path to_json call passes no built_at_commit.

I have a fix with a regression test ready and can open a PR.

Activity

  1. C0KERNEL commented on Aug 13, 2026

    @C0KERNEL
    ContributorAuthor

    Resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions