|
11 | 11 | from dbx_python_cli.utils.repo import ( |
12 | 12 | find_all_repos, |
13 | 13 | find_repo_by_name, |
| 14 | + find_repo_by_path, |
14 | 15 | get_base_dir, |
15 | 16 | get_build_commands, |
16 | 17 | get_config, |
@@ -560,12 +561,31 @@ def install_callback( |
560 | 561 |
|
561 | 562 | selected_group = repo_group |
562 | 563 | else: |
563 | | - # Find the repository across all groups |
564 | | - repo = find_repo_by_name(repo_name, base_dir, config) |
565 | | - if not repo: |
566 | | - typer.echo(f"❌ Error: Repository '{repo_name}' not found", err=True) |
567 | | - typer.echo("\nUse 'dbx install --list' to see available repositories") |
568 | | - raise typer.Exit(1) |
| 564 | + # Detect path-like inputs: ".", "..", absolute paths, relative paths with / |
| 565 | + _is_path_like = ( |
| 566 | + repo_name in (".", "..") |
| 567 | + or repo_name.startswith(("./", "../", "/", "~/")) |
| 568 | + or "/" in repo_name |
| 569 | + or Path(repo_name).is_dir() |
| 570 | + ) |
| 571 | + |
| 572 | + if _is_path_like: |
| 573 | + repo = find_repo_by_path(repo_name, base_dir, config) |
| 574 | + if not repo: |
| 575 | + typer.echo( |
| 576 | + f"❌ Error: No managed repository found at '{Path(repo_name).resolve()}'", |
| 577 | + err=True, |
| 578 | + ) |
| 579 | + typer.echo("\nUse 'dbx install --list' to see available repositories") |
| 580 | + raise typer.Exit(1) |
| 581 | + repo_name = repo["name"] |
| 582 | + else: |
| 583 | + # Find the repository across all groups |
| 584 | + repo = find_repo_by_name(repo_name, base_dir, config) |
| 585 | + if not repo: |
| 586 | + typer.echo(f"❌ Error: Repository '{repo_name}' not found", err=True) |
| 587 | + typer.echo("\nUse 'dbx install --list' to see available repositories") |
| 588 | + raise typer.Exit(1) |
569 | 589 |
|
570 | 590 | repo_path = repo["path"] |
571 | 591 | selected_group = repo["group"] |
@@ -824,29 +844,48 @@ def install_callback( |
824 | 844 | "group": venv_group, |
825 | 845 | } |
826 | 846 | else: |
827 | | - # Find the repository (will return highest priority match if multiple exist) |
828 | | - repo = find_repo_by_name(repo_name, base_dir, config) |
829 | | - if not repo: |
830 | | - typer.echo(f"❌ Error: Repository '{repo_name}' not found", err=True) |
831 | | - typer.echo("\nRun 'dbx install --list' to see available repositories") |
832 | | - raise typer.Exit(1) |
| 847 | + # Detect path-like inputs: ".", "..", absolute paths, relative paths with / |
| 848 | + _is_path_like = ( |
| 849 | + repo_name in (".", "..") |
| 850 | + or repo_name.startswith(("./", "../", "/", "~/")) |
| 851 | + or "/" in repo_name |
| 852 | + or Path(repo_name).is_dir() |
| 853 | + ) |
833 | 854 |
|
834 | | - # Check if repo exists in multiple groups (suppress warning if one is a global group) |
835 | | - all_repos = find_all_repos(base_dir, config) |
836 | | - matching_repos = [r for r in all_repos if r["name"] == repo_name] |
837 | | - if len(matching_repos) > 1: |
838 | | - groups = [r["group"] for r in matching_repos] |
839 | | - global_group_names = set(get_global_groups(config)) |
840 | | - # Only warn if none of the groups are global groups |
841 | | - if not any(g in global_group_names for g in groups): |
842 | | - typer.echo( |
843 | | - f"⚠️ Warning: Repository '{repo_name}' found in multiple groups: {', '.join(groups)}", |
844 | | - err=True, |
845 | | - ) |
| 855 | + if _is_path_like: |
| 856 | + repo = find_repo_by_path(repo_name, base_dir, config) |
| 857 | + if not repo: |
846 | 858 | typer.echo( |
847 | | - f"⚠️ Using '{repo['group']}' group. Use -g to specify a different group.\n", |
| 859 | + f"❌ Error: No managed repository found at '{Path(repo_name).resolve()}'", |
848 | 860 | err=True, |
849 | 861 | ) |
| 862 | + typer.echo("\nRun 'dbx install --list' to see available repositories") |
| 863 | + raise typer.Exit(1) |
| 864 | + repo_name = repo["name"] |
| 865 | + else: |
| 866 | + # Find the repository (will return highest priority match if multiple exist) |
| 867 | + repo = find_repo_by_name(repo_name, base_dir, config) |
| 868 | + if not repo: |
| 869 | + typer.echo(f"❌ Error: Repository '{repo_name}' not found", err=True) |
| 870 | + typer.echo("\nRun 'dbx install --list' to see available repositories") |
| 871 | + raise typer.Exit(1) |
| 872 | + |
| 873 | + # Check if repo exists in multiple groups (suppress warning if one is a global group) |
| 874 | + all_repos = find_all_repos(base_dir, config) |
| 875 | + matching_repos = [r for r in all_repos if r["name"] == repo_name] |
| 876 | + if len(matching_repos) > 1: |
| 877 | + groups = [r["group"] for r in matching_repos] |
| 878 | + global_group_names = set(get_global_groups(config)) |
| 879 | + # Only warn if none of the groups are global groups |
| 880 | + if not any(g in global_group_names for g in groups): |
| 881 | + typer.echo( |
| 882 | + f"⚠️ Warning: Repository '{repo_name}' found in multiple groups: {', '.join(groups)}", |
| 883 | + err=True, |
| 884 | + ) |
| 885 | + typer.echo( |
| 886 | + f"⚠️ Using '{repo['group']}' group. Use -g to specify a different group.\n", |
| 887 | + err=True, |
| 888 | + ) |
850 | 889 |
|
851 | 890 | repo_path = Path(repo["path"]) |
852 | 891 | # Default to repo's own group |
|
0 commit comments