From 450314b9a38cb556045e4a1a72dc7765ee37b430 Mon Sep 17 00:00:00 2001 From: hiiwave Date: Sat, 21 Sep 2019 08:22:39 +0800 Subject: [PATCH 1/4] Fix #321 --- watson/cli.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/watson/cli.py b/watson/cli.py index 47b3c9c7..432339aa 100644 --- a/watson/cli.py +++ b/watson/cli.py @@ -202,6 +202,8 @@ def start(ctx, watson, confirm_new_project, confirm_new_tag, args, gap_=True): project = ' '.join( itertools.takewhile(lambda s: not s.startswith('+'), args) ) + if not project: + raise _watson.WatsonError("No project given.") # Confirm creation of new project if that option is set if (watson.config.getboolean('options', 'confirm_new_project') or @@ -1128,6 +1130,8 @@ def add(watson, args, from_, to, confirm_new_project, confirm_new_tag): project = ' '.join( itertools.takewhile(lambda s: not s.startswith('+'), args) ) + if not project: + raise _watson.WatsonError("No project given.") # Confirm creation of new project if that option is set if (watson.config.getboolean('options', 'confirm_new_project') or From c60daa2c67a3f5d6c96beb6bca7afd9d1ff96335 Mon Sep 17 00:00:00 2001 From: hiiwave Date: Sun, 22 Sep 2019 08:25:01 +0800 Subject: [PATCH 2/4] fixup! Fix #321 --- CHANGELOG.md | 1 + watson/cli.py | 4 ++-- watson/watson.py | 3 --- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e4f84e2..a5860b00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Stylize prompt to create new project or tag (#310). - Aggregate calculates wrong time if used with `--current` (#293) +- `watson start` now correctly checks if project is empty (#322) ## [1.8.0] - 2019-08-26 diff --git a/watson/cli.py b/watson/cli.py index 432339aa..ed15c246 100644 --- a/watson/cli.py +++ b/watson/cli.py @@ -203,7 +203,7 @@ def start(ctx, watson, confirm_new_project, confirm_new_tag, args, gap_=True): itertools.takewhile(lambda s: not s.startswith('+'), args) ) if not project: - raise _watson.WatsonError("No project given.") + raise click.ClickException("No project given.") # Confirm creation of new project if that option is set if (watson.config.getboolean('options', 'confirm_new_project') or @@ -1131,7 +1131,7 @@ def add(watson, args, from_, to, confirm_new_project, confirm_new_tag): itertools.takewhile(lambda s: not s.startswith('+'), args) ) if not project: - raise _watson.WatsonError("No project given.") + raise click.ClickException("No project given.") # Confirm creation of new project if that option is set if (watson.config.getboolean('options', 'confirm_new_project') or diff --git a/watson/watson.py b/watson/watson.py index 62dc2c1f..bd3d2384 100644 --- a/watson/watson.py +++ b/watson/watson.py @@ -252,9 +252,6 @@ def add(self, project, from_date, to_date, tags): return frame def start(self, project, tags=None, restart=False, gap=True): - if not project: - raise WatsonError("No project given.") - if self.is_started: raise WatsonError( u"Project {} is already started.".format( From d8a9ccf115c41745b82efeb25e5c2ad94401b897 Mon Sep 17 00:00:00 2001 From: hiiwave Date: Fri, 27 Sep 2019 02:10:13 +0800 Subject: [PATCH 3/4] Update CHANGELOG for consistency --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5860b00..e8cc0fd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Stylize prompt to create new project or tag (#310). - Aggregate calculates wrong time if used with `--current` (#293) -- `watson start` now correctly checks if project is empty (#322) +- `start` now correctly checks if project is empty (#322) ## [1.8.0] - 2019-08-26 From 734a1f2b5b4037c59ee2cd80bf068b4f0bb342b9 Mon Sep 17 00:00:00 2001 From: hiiwave Date: Mon, 30 Sep 2019 16:51:50 +0800 Subject: [PATCH 4/4] Update CHANGELOG.md Co-Authored-By: Julien Maupetit --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8cc0fd4..e1b6ba13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Stylize prompt to create new project or tag (#310). - Aggregate calculates wrong time if used with `--current` (#293) -- `start` now correctly checks if project is empty (#322) +- The `start` command now correctly checks if project is empty (#322) ## [1.8.0] - 2019-08-26