Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 | 5 from __future__ import print_function |
Sebastian Noack
2017/08/16 09:16:13
There should be a blank line below the license dis
tlucas
2017/08/16 10:24:24
Done.
| |
5 | 6 |
6 import os | 7 import os |
7 import re | 8 import re |
8 import codecs | 9 import codecs |
9 import subprocess | 10 import subprocess |
10 import tarfile | 11 import tarfile |
11 import json | 12 import json |
12 | 13 |
13 from packager import readMetadata, getDefaultFileName | 14 from packager import readMetadata, getDefaultFileName |
14 | 15 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 try: | 63 try: |
63 subprocess.check_output(['hg', 'outgoing']) | 64 subprocess.check_output(['hg', 'outgoing']) |
64 print('Detected outgoing changesets!') | 65 print('Detected outgoing changesets!') |
65 return True | 66 return True |
66 except subprocess.CalledProcessError as e: | 67 except subprocess.CalledProcessError as e: |
67 if e.returncode == 1: | 68 if e.returncode == 1: |
68 return False | 69 return False |
69 raise | 70 raise |
70 | 71 |
71 | 72 |
72 def repo_has_incoming(repo_paths): | 73 def repo_has_incoming(*repo_paths): |
73 """Checks whether the local repositories are up-to-date""" | 74 """Checks whether the local repositories are up-to-date""" |
74 incoming = False | 75 incoming = False |
75 | 76 |
76 for repo_path in repo_paths: | 77 for repo_path in repo_paths: |
77 try: | 78 try: |
78 subprocess.check_output(['hg', 'incoming', '-R', repo_path]) | 79 subprocess.check_output(['hg', 'incoming', '-R', repo_path]) |
79 print('Detected incoming changesets in "{}"'.format(repo_path)) | 80 print('Detected incoming changesets in "{}"'.format(repo_path)) |
80 incoming = True | 81 incoming = True |
81 except subprocess.CalledProcessError as e: | 82 except subprocess.CalledProcessError as e: |
82 if e.returncode != 1: | 83 if e.returncode != 1: |
83 raise | 84 raise |
84 | 85 |
85 return incoming | 86 return incoming |
86 | 87 |
87 | 88 |
88 def continue_with_outgoing(): | 89 def continue_with_outgoing(): |
89 """Asks the user if he wants to continue despite facing warnings""" | 90 """Asks the user if they want to continue despite facing warnings""" |
90 | 91 |
91 print('If you proceed with the release, they will be included in the ' | 92 print('If you proceed with the release, they will be included in the ' |
92 'release and pushed.') | 93 'release and pushed.') |
93 print('Are you sure about continuing the release-process?') | 94 print('Are you sure about continuing the release process?') |
94 | 95 |
95 while True: | 96 while True: |
96 choice = raw_input('Please choose (yes / no): ').lower() | 97 choice = raw_input('Please choose (yes / no): ').lower().strip() |
97 | 98 |
98 if choice == 'yes': | 99 if choice == 'yes': |
99 return True | 100 return True |
100 if choice == 'no': | 101 if choice == 'no': |
101 return False | 102 return False |
102 | 103 |
103 print('Please answer "yes" or "no"!') | |
104 | 104 |
105 | 105 def can_safely_release(*repo_paths): |
106 def can_safely_release(): | 106 """Run repository-checks in order to bail out early if necessary""" |
107 # run repository-checks and bail out early, in case the user does not | |
Sebastian Noack
2017/08/16 09:16:13
Perhaps this comment should rather be a docstring?
tlucas
2017/08/16 10:24:24
Done, also reduced the sentence to a minimum.
| |
108 # explicitly want to continue OR if the check would cause the process to | |
109 # abort anyway | |
110 if repo_has_uncommitted(): | 107 if repo_has_uncommitted(): |
111 return False | 108 return False |
112 if repo_has_incoming(): | 109 if repo_has_incoming(*repo_paths): |
113 return False | 110 return False |
114 if repo_has_outgoing(): | 111 if repo_has_outgoing(): |
115 return continue_with_outgoing() | 112 return continue_with_outgoing() |
116 | 113 |
117 | 114 |
118 def run(baseDir, type, version, keyFile, downloadsRepo): | 115 def run(baseDir, type, version, keyFile, downloadsRepo): |
119 if not can_safely_release(): | 116 if not can_safely_release(baseDir, downloadsRepo): |
120 print('Aborting release.') | 117 print('Aborting release.') |
121 return 1 | 118 return 1 |
122 | 119 |
123 if type == 'gecko': | 120 if type == 'gecko': |
124 import buildtools.packagerGecko as packager | 121 import buildtools.packagerGecko as packager |
125 elif type == 'safari': | 122 elif type == 'safari': |
126 import buildtools.packagerSafari as packager | 123 import buildtools.packagerSafari as packager |
127 elif type == 'edge': | 124 elif type == 'edge': |
128 import buildtools.packagerEdge as packager | 125 import buildtools.packagerEdge as packager |
129 elif type == 'chrome': | 126 elif type == 'chrome': |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 create_sourcearchive(baseDir, archivePath) | 187 create_sourcearchive(baseDir, archivePath) |
191 downloads.append(archivePath) | 188 downloads.append(archivePath) |
192 | 189 |
193 # Now add the downloads and commit | 190 # Now add the downloads and commit |
194 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 191 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) |
195 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)]) | 192 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)]) |
196 | 193 |
197 # Push all changes | 194 # Push all changes |
198 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 195 subprocess.check_call(['hg', 'push', '-R', baseDir]) |
199 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 196 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) |
LEFT | RIGHT |