fix(extract): resolve bash source edges built from ${VAR} paths (#2079)#2139
fix(extract): resolve bash source edges built from ${VAR} paths (#2079)#2139HerenderKumar wants to merge 1 commit into
Conversation
…hify-Labs#2079) `source "${BENCH_DIR}/lib/x.sh"` (the `dirname "${BASH_SOURCE[0]}"` idiom) took the bare-name branch, which baked the unexpanded `${BENCH_DIR}` text into the target id via `_make_id`. That id matches no node, so the edge was flagged dangling and dropped at export — shared shell libraries looked orphaned and were split into separate communities. Detect a `$`-expansion in the source argument, strip the leading expansion segment(s), and resolve the literal suffix against the script's own directory (which is what the canonical idiom makes the variable). Emit `imports_from` as INFERRED only when it resolves to a real file on disk; skip otherwise instead of emitting a dead id. Bare-name sources keep their existing behavior.
|
Quick note on scope: this PR fixes the source-edge half of the bash sourcing problem — It deliberately leaves a second, related thing alone: a call to a function that's defined in a sourced file still doesn't get a |
#2139) The #2139 ${VAR} source handler now also records bash_sources so resolve_bash_source_edges binds calls into the sourced lib's functions, not just the source edge. Add the end-to-end oracle plus the previously untested _bash_source_suffix guards (mid-path $, whole-var, .. traversal fabricate nothing). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks @HerenderKumar. Shipped in v0.9.26 (cherry-picked to v8 as 0019fc4 to preserve your authorship). During the merge with #2157 I added one integration line so calls into a ${VAR}-sourced library also resolve, not just the source edge. Closed-unmerged here, but it is in the release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.26 |
Fixes #2079
When a bash script sources a file through a variable path like:
graphify was putting the literal
${BENCH_DIR}text into the edge target, so the edge pointed at nothing, got flagged as dangling, and was dropped. The end result was that shared shell libraries looked orphaned and got split off into their own communities.This adds a small branch for variable-built source paths:
${VAR}/$VARpart,dirname "${BASH_SOURCE[0]}"idiom makes the variable point to),Plain
source ./x.shand bare-name sources behave exactly as before.I checked it end-to-end: building the repro repo now links the sourcing script straight to the real library node, with zero dangling edges.
Tests: two new cases in
tests/test_extract.py— the${VAR}idiom resolves to the real file, and an unmatched${VAR}path emits no edge. Full extract + symbol-resolution suites pass (182 passed, 1 skipped).