Merge branch 'main' into call-graph

This commit is contained in:
Paul Gauthier 2023-05-30 13:57:16 -07:00
commit 497b04acd3
2 changed files with 12 additions and 10 deletions

View file

@ -1,4 +1,9 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
@ -9,8 +14,3 @@ repos:
hooks:
- id: flake8
args: ["--show-source"]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]

View file

@ -10,8 +10,7 @@ import tiktoken
from aider import prompts, utils
# Global cache for tags
TAGS_CACHE = {}
# from aider.dump import dump
def to_tree(tags):
@ -50,12 +49,15 @@ def fname_to_components(fname, with_colon):
class RepoMap:
ctags_cmd = ["ctags", "--fields=+S", "--extras=-F", "--output-format=json"]
TAGS_CACHE = None
def __init__(self, use_ctags=None, root=None, main_model="gpt-4"):
if not root:
root = os.getcwd()
self.root = root
self.TAGS_CACHE = dict()
if use_ctags is None:
self.use_ctags = self.check_for_ctags()
else:
@ -136,8 +138,8 @@ class RepoMap:
# Check if the file is in the cache and if the modification time has not changed
file_mtime = os.path.getmtime(filename)
cache_key = filename
if cache_key in TAGS_CACHE and TAGS_CACHE[cache_key]["mtime"] == file_mtime:
return TAGS_CACHE[cache_key]["data"]
if cache_key in self.TAGS_CACHE and self.TAGS_CACHE[cache_key]["mtime"] == file_mtime:
return self.TAGS_CACHE[cache_key]["data"]
cmd = self.ctags_cmd + [filename]
output = subprocess.check_output(cmd).decode("utf-8")
@ -146,7 +148,7 @@ class RepoMap:
data = [json.loads(line) for line in output]
# Update the cache
TAGS_CACHE[cache_key] = {"mtime": file_mtime, "data": data}
self.TAGS_CACHE[cache_key] = {"mtime": file_mtime, "data": data}
return data
def get_tags(self, filename):