From eb73991a57d0234f07c24e829eace9a05dc493f5 Mon Sep 17 00:00:00 2001 From: Steven J Munn <5297082+stevenjlm@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:32:47 +0000 Subject: [PATCH 1/3] Add skip coption in init commands --- aim/cli/init/commands.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/aim/cli/init/commands.py b/aim/cli/init/commands.py index 54f32af454..8c7c199dc5 100644 --- a/aim/cli/init/commands.py +++ b/aim/cli/init/commands.py @@ -11,7 +11,8 @@ dir_okay=True, writable=True)) @click.option('-y', '--yes', is_flag=True, help='Automatically confirm prompt') -def init(repo, yes): +@click.option('-s', '--skip-if-exists', is_flag=True, help='Skips initialization if the repo already exists') +def init(repo, yes, skip_if_exists): """ Initializes new repository in the --repo directory. Initializes new repository in the current working directory if --repo argument is not provided: @@ -20,8 +21,15 @@ def init(repo, yes): repo_path = clean_repo_path(repo) or os.getcwd() re_init = False if Repo.exists(repo_path): - if yes: + if yes and skip_if_exists: + raise click.BadParameter('Conflicting init options.' + 'Either specify -y/--yes or -s/--skip-if-exists') + elif yes: re_init = True + elif skip_if_exists: + click.echo( + 'Repo exists at {}. Skipped initialization.'.format(repo.root_path)) + return else: re_init = click.confirm('Aim repository is already initialized. ' 'Do you want to re-initialize to empty Aim repository?') From df99674cf5b226241682ea8edeae4c4e3b6edb8c Mon Sep 17 00:00:00 2001 From: Steven J Munn <5297082+stevenjlm@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:01:15 +0000 Subject: [PATCH 2/3] fix option description spelling/grammar --- aim/cli/init/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aim/cli/init/commands.py b/aim/cli/init/commands.py index 8c7c199dc5..584fd007d9 100644 --- a/aim/cli/init/commands.py +++ b/aim/cli/init/commands.py @@ -11,7 +11,7 @@ dir_okay=True, writable=True)) @click.option('-y', '--yes', is_flag=True, help='Automatically confirm prompt') -@click.option('-s', '--skip-if-exists', is_flag=True, help='Skips initialization if the repo already exists') +@click.option('-s', '--skip-if-exists', is_flag=True, help='Skip initialization if the repo already exists') def init(repo, yes, skip_if_exists): """ Initializes new repository in the --repo directory. From dad3737cb4666815a68756448a9c266402b09ce7 Mon Sep 17 00:00:00 2001 From: Steven J Munn <5297082+stevenjlm@users.noreply.github.com> Date: Thu, 4 Jul 2024 17:55:30 +0000 Subject: [PATCH 3/3] update change log --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a9c04c2cc..8b175d7074 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 3.22.1 Jul 4, 2024 + +### Enhancements: +- Add a `-s`/`--skip-if-exists` option to the `init` command to avoid reinitializing a repo if one already exists (stevenjlm) + ## 3.22.0 Jun 20, 2024 ### Enhancements: