| Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 1 # This Source Code Form is subject to the terms of the Mozilla Public | 1 # This Source Code Form is subject to the terms of the Mozilla Public | 
| 2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 
| 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 
| 4 | 4 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.
 
 | |
| 5 import os | 5 import os | 
| 6 import re | 6 import re | 
| 7 import codecs | 7 import codecs | 
| 8 import subprocess | 8 import subprocess | 
| 9 import tarfile | 9 import tarfile | 
| 10 import json | 10 import json | 
| 11 | 11 | 
| 12 from packager import readMetadata, getDefaultFileName | 12 from packager import readMetadata, getDefaultFileName | 
| 13 | 13 | 
| 14 | 14 | 
| (...skipping 23 matching lines...) Expand all Loading... | |
| 38 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgig nore'): | 38 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgig nore'): | 
| 39 continue | 39 continue | 
| 40 filedata = repoarchive.extractfile(fileinfo) | 40 filedata = repoarchive.extractfile(fileinfo) | 
| 41 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name ) | 41 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name ) | 
| 42 archive.addfile(fileinfo, filedata) | 42 archive.addfile(fileinfo, filedata) | 
| 43 finally: | 43 finally: | 
| 44 process.stdout.close() | 44 process.stdout.close() | 
| 45 process.wait() | 45 process.wait() | 
| 46 | 46 | 
| 47 | 47 | 
| 48 def repo_has_uncommitted(): | |
| 49 """Checks if the given repository is clean""" | |
| 50 buff = subprocess.check_output(['hg', 'status']) | |
| 51 | |
| 52 if len(buff): | |
| 53 print('Dirty / uncommitted changes in repository!') | |
| 54 return True | |
| 55 | |
| 56 return False | |
| 57 | |
| 58 | |
| 59 def repo_has_outgoing(): | |
| 60 """Checks whether there would be outgoing changesets to the given path""" | |
| 61 try: | |
| 62 subprocess.check_output(['hg', 'outgoing']) | |
| 63 print('Detected outgoing changesets!') | |
| 64 return True | |
| 65 except subprocess.CalledProcessError: | |
| 66 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.
 
 | |
| 67 | |
| 68 | |
| 69 def repo_has_incoming(repo_paths): | |
| 70 """Checks whether the local repositories are up-to-date""" | |
| 71 incoming = False | |
| 72 | |
| 73 for repo_path in repo_paths: | |
| 74 try: | |
| 75 subprocess.check_output(['hg', 'incoming', '-R', repo_path]) | |
| 76 print('Detected incoming changesets in "{}"'.format(repo_path)) | |
| 77 incoming = True | |
| 78 except subprocess.CalledProcessError: | |
| 79 pass | |
| 80 | |
| 81 return incoming | |
| 82 | |
| 83 | |
| 84 def continue_with_outgoing(): | |
| 85 """Asks the user if he wants to continue despite facing warnings""" | |
| 86 | |
| 87 print('If you proceed with the release, they will be included in the ' | |
| 88 'release and pushed.') | |
| 89 print('Are you sure about continuing the release-process?') | |
| 90 | |
| 91 while True: | |
| 92 choice = raw_input('Please choose (yes / no): ').lower() | |
| 93 | |
| 94 if choice == 'yes': | |
| 95 return True | |
| 96 if choice == 'no': | |
| 97 return False | |
| 98 | |
| 99 print('Please answer "yes" or "no"!') | |
| 100 | |
| 101 | |
| 48 def run(baseDir, type, version, keyFile, downloadsRepo): | 102 def run(baseDir, type, version, keyFile, downloadsRepo): | 
| 103 # run repository-checks and bail out early, in case the user does not | |
| 104 # explicitly want to continue OR if the check would cause the process to | |
| 105 # abort anyway | |
| 106 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.
 
 | |
| 107 if repo_has_uncommitted(): | |
| 108 return False | |
| 109 if repo_has_incoming(): | |
| 110 return False | |
| 111 if repo_has_outgoing(): | |
| 112 return continue_with_outgoing() | |
| 113 | |
| 114 if not can_safely_release(): | |
| 115 print('Aborting release.') | |
| 116 return 1 | |
| 117 | |
| 49 if type == 'gecko': | 118 if type == 'gecko': | 
| 50 import buildtools.packagerGecko as packager | 119 import buildtools.packagerGecko as packager | 
| 51 elif type == 'safari': | 120 elif type == 'safari': | 
| 52 import buildtools.packagerSafari as packager | 121 import buildtools.packagerSafari as packager | 
| 53 elif type == 'edge': | 122 elif type == 'edge': | 
| 54 import buildtools.packagerEdge as packager | 123 import buildtools.packagerEdge as packager | 
| 55 elif type == 'chrome': | 124 elif type == 'chrome': | 
| 56 import buildtools.packagerChrome as packager | 125 import buildtools.packagerChrome as packager | 
| 57 | 126 | 
| 58 # Replace version number in metadata file "manually", ConfigParser will mess | 127 # Replace version number in metadata file "manually", ConfigParser will mess | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 create_sourcearchive(baseDir, archivePath) | 185 create_sourcearchive(baseDir, archivePath) | 
| 117 downloads.append(archivePath) | 186 downloads.append(archivePath) | 
| 118 | 187 | 
| 119 # Now add the downloads and commit | 188 # Now add the downloads and commit | 
| 120 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 189 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 
| 121 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)]) | 190 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)]) | 
| 122 | 191 | 
| 123 # Push all changes | 192 # Push all changes | 
| 124 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 193 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 
| 125 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 194 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 
| OLD | NEW |