mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +00:00
Merge branch 'main' into call-graph
This commit is contained in:
commit
497b04acd3
2 changed files with 12 additions and 10 deletions
|
@ -1,4 +1,9 @@
|
||||||
repos:
|
repos:
|
||||||
|
- repo: https://github.com/pycqa/isort
|
||||||
|
rev: 5.12.0
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
args: ["--profile", "black"]
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 23.3.0
|
rev: 23.3.0
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -9,8 +14,3 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
args: ["--show-source"]
|
args: ["--show-source"]
|
||||||
- repo: https://github.com/pycqa/isort
|
|
||||||
rev: 5.12.0
|
|
||||||
hooks:
|
|
||||||
- id: isort
|
|
||||||
args: ["--profile", "black"]
|
|
||||||
|
|
|
@ -10,8 +10,7 @@ import tiktoken
|
||||||
|
|
||||||
from aider import prompts, utils
|
from aider import prompts, utils
|
||||||
|
|
||||||
# Global cache for tags
|
# from aider.dump import dump
|
||||||
TAGS_CACHE = {}
|
|
||||||
|
|
||||||
|
|
||||||
def to_tree(tags):
|
def to_tree(tags):
|
||||||
|
@ -50,12 +49,15 @@ def fname_to_components(fname, with_colon):
|
||||||
|
|
||||||
class RepoMap:
|
class RepoMap:
|
||||||
ctags_cmd = ["ctags", "--fields=+S", "--extras=-F", "--output-format=json"]
|
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"):
|
def __init__(self, use_ctags=None, root=None, main_model="gpt-4"):
|
||||||
if not root:
|
if not root:
|
||||||
root = os.getcwd()
|
root = os.getcwd()
|
||||||
self.root = root
|
self.root = root
|
||||||
|
|
||||||
|
self.TAGS_CACHE = dict()
|
||||||
|
|
||||||
if use_ctags is None:
|
if use_ctags is None:
|
||||||
self.use_ctags = self.check_for_ctags()
|
self.use_ctags = self.check_for_ctags()
|
||||||
else:
|
else:
|
||||||
|
@ -136,8 +138,8 @@ class RepoMap:
|
||||||
# Check if the file is in the cache and if the modification time has not changed
|
# Check if the file is in the cache and if the modification time has not changed
|
||||||
file_mtime = os.path.getmtime(filename)
|
file_mtime = os.path.getmtime(filename)
|
||||||
cache_key = filename
|
cache_key = filename
|
||||||
if cache_key in TAGS_CACHE and TAGS_CACHE[cache_key]["mtime"] == file_mtime:
|
if cache_key in self.TAGS_CACHE and self.TAGS_CACHE[cache_key]["mtime"] == file_mtime:
|
||||||
return TAGS_CACHE[cache_key]["data"]
|
return self.TAGS_CACHE[cache_key]["data"]
|
||||||
|
|
||||||
cmd = self.ctags_cmd + [filename]
|
cmd = self.ctags_cmd + [filename]
|
||||||
output = subprocess.check_output(cmd).decode("utf-8")
|
output = subprocess.check_output(cmd).decode("utf-8")
|
||||||
|
@ -146,7 +148,7 @@ class RepoMap:
|
||||||
data = [json.loads(line) for line in output]
|
data = [json.loads(line) for line in output]
|
||||||
|
|
||||||
# Update the cache
|
# Update the cache
|
||||||
TAGS_CACHE[cache_key] = {"mtime": file_mtime, "data": data}
|
self.TAGS_CACHE[cache_key] = {"mtime": file_mtime, "data": data}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_tags(self, filename):
|
def get_tags(self, filename):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue