Index: releaseAutomation.py |
diff --git a/releaseAutomation.py b/releaseAutomation.py |
index 5578abf1d948fe185e046cdb70ccd4734fa876ed..be56b22f40a916227dab509c19c1ca67def84b95 100644 |
--- a/releaseAutomation.py |
+++ b/releaseAutomation.py |
@@ -1,6 +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 |
import os |
import re |
@@ -45,7 +46,79 @@ 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 as e: |
+ if e.returncode == 1: |
+ return False |
+ raise |
+ |
+ |
+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 as e: |
+ if e.returncode != 1: |
+ raise |
+ |
+ 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(): |
+ 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': |