diff mbox

[kteam-tools,1/1,link-to-tracker] Add a sanity check before modifying a TB

Message ID 20170629075745.6634-1-juerg.haefliger@canonical.com
State New
Headers show

Commit Message

Juerg Haefliger June 29, 2017, 7:57 a.m. UTC
The to-be-modified TB should have '<version to be filled>' in its title.
Bail out if that's not the case to prevent accidents (which happened to
me twice already).

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
---
 stable/link-to-tracker | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Juerg Haefliger June 30, 2017, 10:28 a.m. UTC | #1
Scrap that. There are legitimate reasons for doing this, so the sanity
check needs to be smarter. Will send v2.

...Juerg


On 06/29/2017 09:57 AM, Juerg Haefliger wrote:
> The to-be-modified TB should have '<version to be filled>' in its title.
> Bail out if that's not the case to prevent accidents (which happened to
> me twice already).
> 
> Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
> ---
>  stable/link-to-tracker | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/stable/link-to-tracker b/stable/link-to-tracker
> index 356c017c5017..a4df8dfa0cd3 100755
> --- a/stable/link-to-tracker
> +++ b/stable/link-to-tracker
> @@ -165,6 +165,11 @@ class Tracking(object):
>              if not found:
>                  raise AppError('Cannot find tracker bug matching package %s series %s' % (target_package, target_series))
>  
> +            # Sanity check: Bail out if the version is already filled
> +            lpbug = self.launchpad.bugs[bugid]
> +            if 'version to be filled' not in lpbug.title:
> +                raise AppError('Version is already filled for LP #%s (%s)' % (bugid, lpbug.title))
> +
>              # -------------------------------------------------------------------------------------
>              # C H A N G E L O G   W O R K
>  
> @@ -185,10 +190,11 @@ class Tracking(object):
>                      f.write(line)
>              retval = 0
>  
> -            lpbug = self.launchpad.bugs[bugid]
> +            # Update the title of the tracking bug
>              lpbug.title = title
>              lpbug.lp_save()
>  
> +            # Update the state and assignee of the 'prepare-package' task
>              task = tasks_by_name['prepare-package'].lp_task
>              task.status = "In Progress"
>              task.assignee = self.launchpad.me
>
diff mbox

Patch

diff --git a/stable/link-to-tracker b/stable/link-to-tracker
index 356c017c5017..a4df8dfa0cd3 100755
--- a/stable/link-to-tracker
+++ b/stable/link-to-tracker
@@ -165,6 +165,11 @@  class Tracking(object):
             if not found:
                 raise AppError('Cannot find tracker bug matching package %s series %s' % (target_package, target_series))
 
+            # Sanity check: Bail out if the version is already filled
+            lpbug = self.launchpad.bugs[bugid]
+            if 'version to be filled' not in lpbug.title:
+                raise AppError('Version is already filled for LP #%s (%s)' % (bugid, lpbug.title))
+
             # -------------------------------------------------------------------------------------
             # C H A N G E L O G   W O R K
 
@@ -185,10 +190,11 @@  class Tracking(object):
                     f.write(line)
             retval = 0
 
-            lpbug = self.launchpad.bugs[bugid]
+            # Update the title of the tracking bug
             lpbug.title = title
             lpbug.lp_save()
 
+            # Update the state and assignee of the 'prepare-package' task
             task = tasks_by_name['prepare-package'].lp_task
             task.status = "In Progress"
             task.assignee = self.launchpad.me