diff --git a/aider/args.py b/aider/args.py index 08c9bde76..c51781b07 100644 --- a/aider/args.py +++ b/aider/args.py @@ -595,9 +595,15 @@ def get_parser(default_config_files, git_root): default=None, ) group.add_argument( - "--install-main-branch", - action="store_true", - help="Install the latest version from the main branch", + "--install-branch", + nargs="?", + const=True, + metavar="GIT_URL", + help=( + "Install the latest version from a git branch. If GIT_URL is provided, installs from" + " that URL (e.g., git+https://github.com/user/aider.git@my-branch). If no URL is" + " provided, installs from the Aider-AI main branch." + ), default=False, ) group.add_argument( diff --git a/aider/main.py b/aider/main.py index ea344f0ba..80258edad 100644 --- a/aider/main.py +++ b/aider/main.py @@ -34,7 +34,7 @@ from aider.models import ModelSettings from aider.onboarding import offer_openrouter_oauth, select_default_model from aider.repo import ANY_GIT_ERROR, GitRepo from aider.report import report_uncaught_exceptions -from aider.versioncheck import check_version, install_from_main_branch, install_upgrade +from aider.versioncheck import check_version, install_from_git_branch, install_upgrade from aider.watch import FileWatcher from .dump import dump # noqa: F401 @@ -719,9 +719,13 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F analytics.event("exit", reason="Just checking update") return 0 if not update_available else 1 - if args.install_main_branch: - success = install_from_main_branch(io) - analytics.event("exit", reason="Installed main branch") + # Handle --install-branch [url] + if args.install_branch: + if isinstance(args.install_branch, str): + success = install_from_git_branch(io, remote_url=args.install_branch) + else: # True, meaning the flag was used without a URL + success = install_from_git_branch(io) + analytics.event("exit", reason="Installed git branch") return 0 if success else 1 if args.upgrade: diff --git a/aider/versioncheck.py b/aider/versioncheck.py index ac511a022..b350614f9 100644 --- a/aider/versioncheck.py +++ b/aider/versioncheck.py @@ -12,16 +12,23 @@ from aider.dump import dump # noqa: F401 VERSION_CHECK_FNAME = Path.home() / ".aider" / "caches" / "versioncheck" -def install_from_main_branch(io): +def install_from_git_branch(io, remote_url=None): """ - Install the latest version of aider from the main branch of the GitHub repository. + Install the latest version of aider from the main branch of the GitHub repository + or a specified git remote URL. """ + if remote_url is None: + remote_url = "git+https://github.com/Aider-AI/aider.git@main" + source_description = "the Aider-AI main branch" + else: + source_description = remote_url + return utils.check_pip_install_extra( io, None, - "Install the development version of aider from the main branch?", - ["git+https://github.com/Aider-AI/aider.git"], + f"Install the development version of aider from {source_description}?", + [remote_url], self_update=True, ) diff --git a/aider/website/docs/config/aider_conf.md b/aider/website/docs/config/aider_conf.md index 99bccf401..da45f0b11 100644 --- a/aider/website/docs/config/aider_conf.md +++ b/aider/website/docs/config/aider_conf.md @@ -361,8 +361,8 @@ cog.outl("```") ## Show release notes on first run of new version (default: None, ask user) #show-release-notes: xxx -## Install the latest version from the main branch -#install-main-branch: false +## Install the latest version from a git branch. If GIT_URL is provided, installs from that URL (e.g., git+https://github.com/user/aider.git@my-branch). If no URL is provided, installs from the Aider-AI main branch. +#install-branch: false ## Upgrade aider to the latest version from PyPI #upgrade: false diff --git a/aider/website/docs/config/options.md b/aider/website/docs/config/options.md index 368c4ec7e..7dfbda548 100644 --- a/aider/website/docs/config/options.md +++ b/aider/website/docs/config/options.md @@ -66,8 +66,7 @@ usage: aider [-h] [--model] [--openai-api-key] [--anthropic-api-key] [--analytics | --no-analytics] [--analytics-log] [--analytics-disable] [--just-check-update] [--check-update | --no-check-update] - [--show-release-notes | --no-show-release-notes] - [--install-main-branch] [--upgrade] [--version] + [--show-release-notes | --no-show-release-notes] [--install-branch] [--upgrade] [--version] [--message] [--message-file] [--gui | --no-gui | --browser | --no-browser] [--copy-paste | --no-copy-paste] [--apply] @@ -568,10 +567,10 @@ Aliases: - `--show-release-notes` - `--no-show-release-notes` -### `--install-main-branch` -Install the latest version from the main branch +### `--install-branch [GIT_URL]` +Install the latest version from a git branch. If GIT_URL is provided, installs from that URL (e.g., git+https://github.com/user/aider.git@my-branch). If no URL is provided, installs from the Aider-AI main branch. Default: False -Environment variable: `AIDER_INSTALL_MAIN_BRANCH` +Environment variable: `AIDER_INSTALL_BRANCH` ### `--upgrade` Upgrade aider to the latest version from PyPI