mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
Merge branch 'main' into fix-flake8
This commit is contained in:
commit
c7c5d5ab84
9 changed files with 108 additions and 19 deletions
|
@ -344,6 +344,18 @@ def get_parser(default_config_files, git_root):
|
|||
default=True,
|
||||
help="Enable/disable commits when repo is found dirty (default: True)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--attribute-author",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
default=True,
|
||||
help="Attribute aider code changes in the git author name (default: True)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--attribute-committer",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
default=True,
|
||||
help="Attribute aider commits in the git committer name (default: True)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--dry-run",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
|
|
|
@ -218,6 +218,8 @@ class Coder:
|
|||
auto_test=False,
|
||||
lint_cmds=None,
|
||||
test_cmd=None,
|
||||
attribute_author=True,
|
||||
attribute_committer=True,
|
||||
):
|
||||
if not fnames:
|
||||
fnames = []
|
||||
|
@ -275,6 +277,8 @@ class Coder:
|
|||
git_dname,
|
||||
aider_ignore_file,
|
||||
models=main_model.commit_message_models(),
|
||||
attribute_author=attribute_author,
|
||||
attribute_committer=attribute_committer,
|
||||
)
|
||||
self.root = self.repo.root
|
||||
except FileNotFoundError:
|
||||
|
|
|
@ -212,6 +212,7 @@ def parse_lint_cmds(lint_cmds, io):
|
|||
return
|
||||
return res
|
||||
|
||||
|
||||
def generate_search_path_list(default_fname, git_root, command_line_file):
|
||||
files = []
|
||||
default_file = Path(default_fname)
|
||||
|
@ -223,12 +224,15 @@ def generate_search_path_list(default_fname, git_root, command_line_file):
|
|||
files.append(default_file.resolve())
|
||||
files = list(map(str, files))
|
||||
files = list(dict.fromkeys(files))
|
||||
|
||||
|
||||
return files
|
||||
|
||||
|
||||
|
||||
def register_models(git_root, model_settings_fname, io):
|
||||
model_settings_files = generate_search_path_list(".aider.models.yml", git_root, model_settings_fname)
|
||||
|
||||
model_settings_files = generate_search_path_list(
|
||||
".aider.models.yml", git_root, model_settings_fname
|
||||
)
|
||||
|
||||
try:
|
||||
files_loaded = models.register_models(model_settings_files)
|
||||
if len(files_loaded) > 0:
|
||||
|
@ -238,11 +242,14 @@ def register_models(git_root, model_settings_fname, io):
|
|||
except Exception as e:
|
||||
io.tool_error(f"Error loading aider model settings: {e}")
|
||||
return 1
|
||||
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def register_litellm_models(git_root, model_metadata_fname, io):
|
||||
model_metatdata_files = generate_search_path_list(".aider.litellm.models.json", git_root, model_metadata_fname)
|
||||
model_metatdata_files = generate_search_path_list(
|
||||
".aider.litellm.models.json", git_root, model_metadata_fname
|
||||
)
|
||||
|
||||
try:
|
||||
model_metadata_files_loaded = models.register_litellm_models(model_metatdata_files)
|
||||
|
@ -253,7 +260,8 @@ def register_litellm_models(git_root, model_metadata_fname, io):
|
|||
except Exception as e:
|
||||
io.tool_error(f"Error loading litellm models: {e}")
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
def main(argv=None, input=None, output=None, force_git_root=None, return_coder=False):
|
||||
if argv is None:
|
||||
argv = sys.argv[1:]
|
||||
|
@ -393,7 +401,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
|
||||
register_models(git_root, args.model_settings_file, io)
|
||||
register_litellm_models(git_root, args.model_metadata_file, io)
|
||||
|
||||
|
||||
main_model = models.Model(args.model, weak_model=args.weak_model)
|
||||
|
||||
lint_cmds = parse_lint_cmds(args.lint_cmd, io)
|
||||
|
@ -430,6 +438,8 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
auto_test=args.auto_test,
|
||||
lint_cmds=lint_cmds,
|
||||
test_cmd=args.test_cmd,
|
||||
attribute_author=args.attribute_author,
|
||||
attribute_committer=args.attribute_committer,
|
||||
)
|
||||
|
||||
except ValueError as err:
|
||||
|
|
|
@ -16,10 +16,22 @@ class GitRepo:
|
|||
aider_ignore_spec = None
|
||||
aider_ignore_ts = 0
|
||||
|
||||
def __init__(self, io, fnames, git_dname, aider_ignore_file=None, models=None):
|
||||
def __init__(
|
||||
self,
|
||||
io,
|
||||
fnames,
|
||||
git_dname,
|
||||
aider_ignore_file=None,
|
||||
models=None,
|
||||
attribute_author=True,
|
||||
attribute_committer=True,
|
||||
):
|
||||
self.io = io
|
||||
self.models = models
|
||||
|
||||
self.attribute_author = attribute_author
|
||||
self.attribute_committer = attribute_committer
|
||||
|
||||
if git_dname:
|
||||
check_fnames = [git_dname]
|
||||
elif fnames:
|
||||
|
@ -90,11 +102,12 @@ class GitRepo:
|
|||
|
||||
original_user_name = self.repo.config_reader().get_value("user", "name")
|
||||
original_committer_name_env = os.environ.get("GIT_COMMITTER_NAME")
|
||||
|
||||
committer_name = f"{original_user_name} (aider)"
|
||||
os.environ["GIT_COMMITTER_NAME"] = committer_name
|
||||
|
||||
if aider_edits:
|
||||
if self.attribute_committer:
|
||||
os.environ["GIT_COMMITTER_NAME"] = committer_name
|
||||
|
||||
if aider_edits and self.attribute_author:
|
||||
original_auther_name_env = os.environ.get("GIT_AUTHOR_NAME")
|
||||
os.environ["GIT_AUTHOR_NAME"] = committer_name
|
||||
|
||||
|
@ -102,18 +115,20 @@ class GitRepo:
|
|||
commit_hash = self.repo.head.commit.hexsha[:7]
|
||||
self.io.tool_output(f"Commit {commit_hash} {commit_message}")
|
||||
|
||||
# Restore the original GIT_COMMITTER_NAME
|
||||
if aider_edits:
|
||||
# Restore the env
|
||||
|
||||
if self.attribute_committer:
|
||||
if original_committer_name_env is not None:
|
||||
os.environ["GIT_COMMITTER_NAME"] = original_committer_name_env
|
||||
else:
|
||||
del os.environ["GIT_COMMITTER_NAME"]
|
||||
|
||||
if aider_edits and self.attribute_author:
|
||||
if original_auther_name_env is not None:
|
||||
os.environ["GIT_AUTHOR_NAME"] = original_auther_name_env
|
||||
else:
|
||||
del os.environ["GIT_AUTHOR_NAME"]
|
||||
|
||||
if original_committer_name_env is not None:
|
||||
os.environ["GIT_COMMITTER_NAME"] = original_committer_name_env
|
||||
else:
|
||||
del os.environ["GIT_COMMITTER_NAME"]
|
||||
|
||||
return commit_hash, commit_message
|
||||
|
||||
def get_rel_repo_dir(self):
|
||||
|
|
|
@ -154,6 +154,12 @@
|
|||
## Enable/disable commits when repo is found dirty (default: True)
|
||||
#dirty-commits: true
|
||||
|
||||
## Attribute aider code changes in the git author name (default: True)
|
||||
#attribute-author: true
|
||||
|
||||
## Attribute aider commits in the git committer name (default: True)
|
||||
#attribute-committer: true
|
||||
|
||||
## Perform a dry run without modifying files (default: False)
|
||||
#dry-run: false
|
||||
|
||||
|
|
|
@ -162,6 +162,12 @@
|
|||
## Enable/disable commits when repo is found dirty (default: True)
|
||||
#AIDER_DIRTY_COMMITS=true
|
||||
|
||||
## Attribute aider code changes in the git author name (default: True)
|
||||
#AIDER_ATTRIBUTE_AUTHOR=true
|
||||
|
||||
## Attribute aider commits in the git committer name (default: True)
|
||||
#AIDER_ATTRIBUTE_COMMITTER=true
|
||||
|
||||
## Perform a dry run without modifying files (default: False)
|
||||
#AIDER_DRY_RUN=false
|
||||
|
||||
|
|
|
@ -182,6 +182,12 @@ cog.outl("```")
|
|||
## Enable/disable commits when repo is found dirty (default: True)
|
||||
#dirty-commits: true
|
||||
|
||||
## Attribute aider code changes in the git author name (default: True)
|
||||
#attribute-author: true
|
||||
|
||||
## Attribute aider commits in the git committer name (default: True)
|
||||
#attribute-committer: true
|
||||
|
||||
## Perform a dry run without modifying files (default: False)
|
||||
#dry-run: false
|
||||
|
||||
|
|
|
@ -195,6 +195,12 @@ cog.outl("```")
|
|||
## Enable/disable commits when repo is found dirty (default: True)
|
||||
#AIDER_DIRTY_COMMITS=true
|
||||
|
||||
## Attribute aider code changes in the git author name (default: True)
|
||||
#AIDER_ATTRIBUTE_AUTHOR=true
|
||||
|
||||
## Attribute aider commits in the git committer name (default: True)
|
||||
#AIDER_ATTRIBUTE_COMMITTER=true
|
||||
|
||||
## Perform a dry run without modifying files (default: False)
|
||||
#AIDER_DRY_RUN=false
|
||||
|
||||
|
|
|
@ -5,10 +5,16 @@ description: Details about all of aider's settings.
|
|||
---
|
||||
|
||||
# Options reference
|
||||
{: .no_toc }
|
||||
|
||||
You can use `aider --help` to see all the available options,
|
||||
or review them below.
|
||||
|
||||
- TOC
|
||||
{:toc}
|
||||
|
||||
## Usage summary
|
||||
|
||||
<!--[[[cog
|
||||
from aider.args import get_md_help
|
||||
cog.out(get_md_help())
|
||||
|
@ -35,6 +41,8 @@ usage: aider [-h] [--llm-history-file] [--openai-api-key]
|
|||
[--gitignore | --no-gitignore] [--aiderignore]
|
||||
[--auto-commits | --no-auto-commits]
|
||||
[--dirty-commits | --no-dirty-commits]
|
||||
[--attribute-author | --no-attribute-author]
|
||||
[--attribute-committer | --no-attribute-committer]
|
||||
[--dry-run | --no-dry-run] [--commit] [--lint]
|
||||
[--lint-cmd] [--auto-lint | --no-auto-lint]
|
||||
[--test-cmd] [--auto-test | --no-auto-test] [--test]
|
||||
|
@ -292,6 +300,22 @@ Aliases:
|
|||
- `--dirty-commits`
|
||||
- `--no-dirty-commits`
|
||||
|
||||
### `--attribute-author`
|
||||
Attribute aider code changes in the git author name (default: True)
|
||||
Default: True
|
||||
Environment variable: `AIDER_ATTRIBUTE_AUTHOR`
|
||||
Aliases:
|
||||
- `--attribute-author`
|
||||
- `--no-attribute-author`
|
||||
|
||||
### `--attribute-committer`
|
||||
Attribute aider commits in the git committer name (default: True)
|
||||
Default: True
|
||||
Environment variable: `AIDER_ATTRIBUTE_COMMITTER`
|
||||
Aliases:
|
||||
- `--attribute-committer`
|
||||
- `--no-attribute-committer`
|
||||
|
||||
### `--dry-run`
|
||||
Perform a dry run without modifying files (default: False)
|
||||
Default: False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue