From 39303574f2b12536bb2704b60fdee129bf68c813 Mon Sep 17 00:00:00 2001 From: abuzarmahmood Date: Sun, 6 Jul 2025 22:27:56 +0000 Subject: [PATCH 1/6] fix: ensure consistent repository paths for cloning and searching Co-authored-by: aider (gpt-4o) --- src/bot_tools.py | 3 +-- src/git_utils.py | 2 +- src/response_agent.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/bot_tools.py b/src/bot_tools.py index ec89bf2..8787f1d 100644 --- a/src/bot_tools.py +++ b/src/bot_tools.py @@ -26,8 +26,7 @@ def get_local_repo_path(repo_name: str) -> str: - Path to the local repository """ repo_name_split = repo_name.split('/') - repo_path = os.path.join( - src_dir, 'repos', repo_name_split[0], repo_name_split[1]) + repo_path = os.path.join(base_dir, 'repos', repo_name_split[0], repo_name_split[1]) # Use base_dir if os.path.exists(repo_path): return repo_path else: diff --git a/src/git_utils.py b/src/git_utils.py index b28cc71..d60e673 100644 --- a/src/git_utils.py +++ b/src/git_utils.py @@ -204,7 +204,7 @@ def clone_repository(repo: Repository) -> str: full_repo_name = repo.full_name repo_split = full_repo_name.split('/') - local_path = os.path.join('repos', repo_split[0]) + local_path = os.path.join(base_dir, 'repos', repo_split[0]) # Ensure base_dir is used # Create directory if it doesn't exist os.makedirs(local_path, exist_ok=True) diff --git a/src/response_agent.py b/src/response_agent.py index eeb4bfc..5966eba 100644 --- a/src/response_agent.py +++ b/src/response_agent.py @@ -286,7 +286,7 @@ def summarize_relevant_comments( Returns: Tuple of (summary text, full conversation history) """ - repo_path = bot_tools.get_local_repo_path(repo_name) + repo_path = bot_tools.get_local_repo_path(repo_name) # Ensure consistent path retrieval details = get_issue_details(issue) # user, file_assistant, edit_assistant = create_agents() From bd78647e1fbe3d8c128c70a1255655acf0a63037 Mon Sep 17 00:00:00 2001 From: abuzarmahmood Date: Sun, 6 Jul 2025 22:28:01 +0000 Subject: [PATCH 2/6] fix: define base_dir to resolve undefined name error in clone_repository Co-authored-by: aider (gpt-4o) --- src/git_utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/git_utils.py b/src/git_utils.py index d60e673..5cca455 100644 --- a/src/git_utils.py +++ b/src/git_utils.py @@ -15,7 +15,12 @@ from github import Github from github.Issue import Issue from github.Repository import Repository +import os from github.IssueComment import IssueComment + +# Determine base directory +src_dir = os.path.dirname(os.path.abspath(__file__)) +base_dir = os.path.dirname(src_dir) from github.PullRequest import PullRequest from dotenv import load_dotenv import re From 04fa2317ec89f764fba7ceafa5ccf521cb5ed9af Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 6 Jul 2025 22:28:11 +0000 Subject: [PATCH 3/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/bot_tools.py | 4 +++- src/git_utils.py | 11 ++++++----- src/response_agent.py | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/bot_tools.py b/src/bot_tools.py index 8787f1d..599a0cd 100644 --- a/src/bot_tools.py +++ b/src/bot_tools.py @@ -26,7 +26,9 @@ def get_local_repo_path(repo_name: str) -> str: - Path to the local repository """ repo_name_split = repo_name.split('/') - repo_path = os.path.join(base_dir, 'repos', repo_name_split[0], repo_name_split[1]) # Use base_dir + repo_path = os.path.join( + # Use base_dir + base_dir, 'repos', repo_name_split[0], repo_name_split[1]) if os.path.exists(repo_path): return repo_path else: diff --git a/src/git_utils.py b/src/git_utils.py index 5cca455..12862f1 100644 --- a/src/git_utils.py +++ b/src/git_utils.py @@ -1,6 +1,10 @@ """ Utility functions for interacting with GitHub API """ +import string +import re +from dotenv import load_dotenv +from github.PullRequest import PullRequest from typing import List, Dict, Optional, Tuple, Union import os import subprocess @@ -21,10 +25,6 @@ # Determine base directory src_dir = os.path.dirname(os.path.abspath(__file__)) base_dir = os.path.dirname(src_dir) -from github.PullRequest import PullRequest -from dotenv import load_dotenv -import re -import string def clean_response(response: str) -> str: @@ -209,7 +209,8 @@ def clone_repository(repo: Repository) -> str: full_repo_name = repo.full_name repo_split = full_repo_name.split('/') - local_path = os.path.join(base_dir, 'repos', repo_split[0]) # Ensure base_dir is used + # Ensure base_dir is used + local_path = os.path.join(base_dir, 'repos', repo_split[0]) # Create directory if it doesn't exist os.makedirs(local_path, exist_ok=True) diff --git a/src/response_agent.py b/src/response_agent.py index 5966eba..0a259bb 100644 --- a/src/response_agent.py +++ b/src/response_agent.py @@ -286,7 +286,8 @@ def summarize_relevant_comments( Returns: Tuple of (summary text, full conversation history) """ - repo_path = bot_tools.get_local_repo_path(repo_name) # Ensure consistent path retrieval + repo_path = bot_tools.get_local_repo_path( + repo_name) # Ensure consistent path retrieval details = get_issue_details(issue) # user, file_assistant, edit_assistant = create_agents() From c13c04e9019560d9d4a5cdd536e383042f1618e2 Mon Sep 17 00:00:00 2001 From: abuzarmahmood Date: Sun, 6 Jul 2025 22:34:58 +0000 Subject: [PATCH 4/6] fix: ensure consistent repository paths in cloning and retrieval functions Co-authored-by: aider (gpt-4o) --- src/bot_tools.py | 4 +--- src/git_utils.py | 3 +-- src/response_agent.py | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/bot_tools.py b/src/bot_tools.py index 599a0cd..b1356e4 100644 --- a/src/bot_tools.py +++ b/src/bot_tools.py @@ -26,9 +26,7 @@ def get_local_repo_path(repo_name: str) -> str: - Path to the local repository """ repo_name_split = repo_name.split('/') - repo_path = os.path.join( - # Use base_dir - base_dir, 'repos', repo_name_split[0], repo_name_split[1]) + repo_path = os.path.join(base_dir, 'repos', repo_name_split[0], repo_name_split[1]) if os.path.exists(repo_path): return repo_path else: diff --git a/src/git_utils.py b/src/git_utils.py index 12862f1..351f824 100644 --- a/src/git_utils.py +++ b/src/git_utils.py @@ -209,8 +209,7 @@ def clone_repository(repo: Repository) -> str: full_repo_name = repo.full_name repo_split = full_repo_name.split('/') - # Ensure base_dir is used - local_path = os.path.join(base_dir, 'repos', repo_split[0]) + local_path = os.path.join(base_dir, 'repos', repo_split[0], repo_split[1]) # Create directory if it doesn't exist os.makedirs(local_path, exist_ok=True) diff --git a/src/response_agent.py b/src/response_agent.py index 0a259bb..eeb4bfc 100644 --- a/src/response_agent.py +++ b/src/response_agent.py @@ -286,8 +286,7 @@ def summarize_relevant_comments( Returns: Tuple of (summary text, full conversation history) """ - repo_path = bot_tools.get_local_repo_path( - repo_name) # Ensure consistent path retrieval + repo_path = bot_tools.get_local_repo_path(repo_name) details = get_issue_details(issue) # user, file_assistant, edit_assistant = create_agents() From 29b33b662f4575839af6ab61e7eb262057c9b7f2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 6 Jul 2025 22:35:06 +0000 Subject: [PATCH 5/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/bot_tools.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bot_tools.py b/src/bot_tools.py index b1356e4..19211c7 100644 --- a/src/bot_tools.py +++ b/src/bot_tools.py @@ -26,7 +26,8 @@ def get_local_repo_path(repo_name: str) -> str: - Path to the local repository """ repo_name_split = repo_name.split('/') - repo_path = os.path.join(base_dir, 'repos', repo_name_split[0], repo_name_split[1]) + repo_path = os.path.join( + base_dir, 'repos', repo_name_split[0], repo_name_split[1]) if os.path.exists(repo_path): return repo_path else: From ddfcdbbc4b3e6e966202334950a4dff3b1597e98 Mon Sep 17 00:00:00 2001 From: Abuzar Mahmood Date: Mon, 7 Jul 2025 10:43:57 -0400 Subject: [PATCH 6/6] refactor(repo-path): simplify repository path construction - Modified `get_local_repo_path` in `bot_tools.py` to streamline path construction using the repository name directly. - Updated `clone_repository` in `git_utils.py` to use a consistent approach for determining the local path without splitting the repository name. - These changes enhance maintainability and readability of the code managing repository paths. --- src/bot_tools.py | 7 ++++--- src/git_utils.py | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bot_tools.py b/src/bot_tools.py index 19211c7..f0fb530 100644 --- a/src/bot_tools.py +++ b/src/bot_tools.py @@ -25,9 +25,10 @@ def get_local_repo_path(repo_name: str) -> str: Returns: - Path to the local repository """ - repo_name_split = repo_name.split('/') - repo_path = os.path.join( - base_dir, 'repos', repo_name_split[0], repo_name_split[1]) + local_path = os.path.join(base_dir, 'repos') + + # Construct full path for clone + repo_path = os.path.join(local_path, repo_name) if os.path.exists(repo_path): return repo_path else: diff --git a/src/git_utils.py b/src/git_utils.py index 351f824..2489c6b 100644 --- a/src/git_utils.py +++ b/src/git_utils.py @@ -208,14 +208,13 @@ def clone_repository(repo: Repository) -> str: import git full_repo_name = repo.full_name - repo_split = full_repo_name.split('/') - local_path = os.path.join(base_dir, 'repos', repo_split[0], repo_split[1]) + local_path = os.path.join(base_dir, 'repos') # Create directory if it doesn't exist os.makedirs(local_path, exist_ok=True) # Construct full path for clone - repo_dir = os.path.join(local_path, repo.name) + repo_dir = os.path.join(local_path, full_repo_name) # Clone if doesn't exist, or return existing path if not os.path.exists(repo_dir):