Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def analyze_diff_and_report(payload: dict):
head_code = head_files[file_path]
if base_code != head_code:
# Ingest code and extract function boundary definitions
base_funcs = extract_functions(base_code, "python")
head_funcs = extract_functions(head_code, "python")
base_funcs = extract_functions(base_code, file_path=file_path)
head_funcs = extract_functions(head_code, file_path=file_path)

# Calculate exact line changes between base and head
base_changed, head_changed = get_changed_line_numbers(base_code, head_code)
Expand Down Expand Up @@ -146,7 +146,7 @@ def analyze_diff_and_report(payload: dict):
if code_bytes:
for c_func_name, c_type in changed_entities:
if c_type in ("modified", "deleted"):
found_funcs = find_functions_using_symbol(code_bytes, c_func_name)
found_funcs = find_functions_using_symbol(code_bytes, c_func_name, file_path=imp_file)
if found_funcs:
if imp_file not in at_risk_functions:
at_risk_functions[imp_file] = []
Expand All @@ -158,7 +158,7 @@ def analyze_diff_and_report(payload: dict):

all_api_routes = {}
for f_path, h_code in head_files.items():
routes = extract_api_routes(h_code)
routes = extract_api_routes(h_code, file_path=f_path)
for f_name, r_info in routes.items():
all_api_routes[(f_path, f_name)] = r_info

Expand Down Expand Up @@ -219,7 +219,7 @@ def format_markdown_report(

md += "### 🔍 Modified Semantic Entities\n"
if not modified_files:
md += "_No Python code modifications detected._\n"
md += "_No supported code modifications detected._\n"
else:
md += "| File | Entity | Change Type |\n"
md += "| --- | --- | --- |\n"
Expand Down Expand Up @@ -337,8 +337,8 @@ async def api_analyze(req: AnalyzeRequest):
else:
head_code = head_files[file_path]
if base_code != head_code:
base_funcs = extract_functions(base_code, "python")
head_funcs = extract_functions(head_code, "python")
base_funcs = extract_functions(base_code, file_path=file_path)
head_funcs = extract_functions(head_code, file_path=file_path)
base_changed, head_changed = get_changed_line_numbers(base_code, head_code)
changed_funcs = []

Expand Down Expand Up @@ -386,7 +386,7 @@ async def api_analyze(req: AnalyzeRequest):
if code_bytes:
for c_func_name, c_type in changed_entities:
if c_type in ("modified", "deleted"):
found_funcs = find_functions_using_symbol(code_bytes, c_func_name)
found_funcs = find_functions_using_symbol(code_bytes, c_func_name, file_path=imp_file)
if found_funcs:
if imp_file not in at_risk_functions:
at_risk_functions[imp_file] = []
Expand All @@ -397,7 +397,7 @@ async def api_analyze(req: AnalyzeRequest):

all_api_routes = {}
for f_path, h_code in head_files.items():
routes = extract_api_routes(h_code)
routes = extract_api_routes(h_code, file_path=f_path)
for f_name, r_info in routes.items():
all_api_routes[(f_path, f_name)] = r_info

Expand Down
17 changes: 9 additions & 8 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from graph_engine import build_dependency_graph, get_impacted_files
from parser import extract_functions, find_functions_using_symbol
import networkx as nx
from languages import registry

def git_list_files(repo_path: str, commit: str) -> list[str]:
"""
Expand All @@ -22,7 +23,7 @@ def git_list_files(repo_path: str, commit: str) -> list[str]:
check=True,
text=True
)
return [line.strip() for line in result.stdout.splitlines() if line.strip().endswith(".py")]
return [line.strip() for line in result.stdout.splitlines() if registry.is_supported(line.strip())]
except subprocess.CalledProcessError as e:
print(f"Error listing files for commit {commit}: {e.stderr.strip()}", file=sys.stderr)
sys.exit(1)
Expand Down Expand Up @@ -58,7 +59,7 @@ def git_diff_files(repo_path: str, base: str, head: str) -> list[str]:
check=True,
text=True
)
return [line.strip() for line in result.stdout.splitlines() if line.strip().endswith(".py")]
return [line.strip() for line in result.stdout.splitlines() if registry.is_supported(line.strip())]
except subprocess.CalledProcessError as e:
print(f"Error running git diff: {e.stderr.strip()}", file=sys.stderr)
sys.exit(1)
Expand Down Expand Up @@ -87,23 +88,23 @@ def run_analysis(repo_path: str, base: str, head: str) -> str:

if not base_code:
# File newly added in head
head_funcs = extract_functions(head_code, "python")
head_funcs = extract_functions(head_code, file_path=file_path)
changed_funcs = [(f_name, "added") for f_name in head_funcs.keys()]
if changed_funcs:
modified_files.append(file_path)
modified_functions_by_file[file_path] = changed_funcs
elif not head_code:
# File deleted in head
base_funcs = extract_functions(base_code, "python")
base_funcs = extract_functions(base_code, file_path=file_path)
changed_funcs = [(f_name, "deleted") for f_name in base_funcs.keys()]
if changed_funcs:
modified_files.append(file_path)
modified_functions_by_file[file_path] = changed_funcs
else:
# File modified
if base_code != head_code:
base_funcs = extract_functions(base_code, "python")
head_funcs = extract_functions(head_code, "python")
base_funcs = extract_functions(base_code, file_path=file_path)
head_funcs = extract_functions(head_code, file_path=file_path)

base_changed, head_changed = get_changed_line_numbers(base_code, head_code)
changed_funcs = []
Expand Down Expand Up @@ -156,7 +157,7 @@ def run_analysis(repo_path: str, base: str, head: str) -> str:
if code_bytes:
for c_func_name, c_type in changed_entities:
if c_type in ("modified", "deleted"):
found_funcs = find_functions_using_symbol(code_bytes, c_func_name)
found_funcs = find_functions_using_symbol(code_bytes, c_func_name, file_path=imp_file)
if found_funcs:
if imp_file not in at_risk_functions:
at_risk_functions[imp_file] = []
Expand All @@ -172,7 +173,7 @@ def run_analysis(repo_path: str, base: str, head: str) -> str:
for imp_file, funcs in at_risk_functions.items():
code_bytes = git_show(repo_path, head, imp_file)
if code_bytes:
routes = extract_api_routes(code_bytes)
routes = extract_api_routes(code_bytes, file_path=imp_file)
for f in funcs:
if f in routes:
impacted_apis.append({
Expand Down
Loading
Loading