Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: releaseAutomation.py

Issue 29508667: Issue 4354, 4355 - handle dirty/outdated repos on release (Closed)
Patch Set: Adjusting error message, removing complexity, increasing readability Created Aug. 15, 2017, 2:38 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: releaseAutomation.py
diff --git a/releaseAutomation.py b/releaseAutomation.py
index 5578abf1d948fe185e046cdb70ccd4734fa876ed..83533fbe3fbdfaa13175ddf10fd3ac941f3b5e65 100644
--- a/releaseAutomation.py
+++ b/releaseAutomation.py
@@ -1,7 +1,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
+from __future__ import print_function
Sebastian Noack 2017/08/15 15:54:45 I would add a blank line below __future__ imports.
tlucas 2017/08/16 08:38:15 Done.
import os
import re
import codecs
@@ -45,7 +45,76 @@ def create_sourcearchive(repo, output):
process.wait()
+def repo_has_uncommitted():
+ """Checks if the given repository is clean"""
+ buff = subprocess.check_output(['hg', 'status'])
+
+ if len(buff):
+ print('Dirty / uncommitted changes in repository!')
+ return True
+
+ return False
+
+
+def repo_has_outgoing():
+ """Checks whether there would be outgoing changesets to the given path"""
+ try:
+ subprocess.check_output(['hg', 'outgoing'])
+ print('Detected outgoing changesets!')
+ return True
+ except subprocess.CalledProcessError:
+ return False
Sebastian Noack 2017/08/15 15:54:45 What is if an unexpected exit code occurs? I think
tlucas 2017/08/16 08:38:15 Done.
+
+
+def repo_has_incoming(repo_paths):
+ """Checks whether the local repositories are up-to-date"""
+ incoming = False
+
+ for repo_path in repo_paths:
+ try:
+ subprocess.check_output(['hg', 'incoming', '-R', repo_path])
+ print('Detected incoming changesets in "{}"'.format(repo_path))
+ incoming = True
+ except subprocess.CalledProcessError:
+ pass
+
+ return incoming
+
+
+def continue_with_outgoing():
+ """Asks the user if he wants to continue despite facing warnings"""
+
+ print('If you proceed with the release, they will be included in the '
+ 'release and pushed.')
+ print('Are you sure about continuing the release-process?')
+
+ while True:
+ choice = raw_input('Please choose (yes / no): ').lower()
+
+ if choice == 'yes':
+ return True
+ if choice == 'no':
+ return False
+
+ print('Please answer "yes" or "no"!')
+
+
def run(baseDir, type, version, keyFile, downloadsRepo):
+ # run repository-checks and bail out early, in case the user does not
+ # explicitly want to continue OR if the check would cause the process to
+ # abort anyway
+ def can_safely_release():
Sebastian Noack 2017/08/15 15:54:45 Do you really need a function here? Wouldn't this
tlucas 2017/08/16 08:38:15 I don't, but the equivalent would be: can_safely_
Sebastian Noack 2017/08/16 08:48:35 I guess, it is OK to keep the function. But then t
tlucas 2017/08/16 08:53:23 Agreed, Done.
+ if repo_has_uncommitted():
+ return False
+ if repo_has_incoming():
+ return False
+ if repo_has_outgoing():
+ return continue_with_outgoing()
+
+ if not can_safely_release():
+ print('Aborting release.')
+ return 1
+
if type == 'gecko':
import buildtools.packagerGecko as packager
elif type == 'safari':
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld