| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Script that attempts to push to a special git repository to verify that git | 6 """Script that attempts to push to a special git repository to verify that git |
| 7 credentials are configured correctly. It also verifies that gclient solution is | 7 credentials are configured correctly. It also verifies that gclient solution is |
| 8 configured to use git checkout. | 8 configured to use git checkout. |
| 9 | 9 |
| 10 It will be added as gclient hook shortly before Chromium switches to git and | 10 It will be added as gclient hook shortly before Chromium switches to git and |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 """Read information about 'src' gclient solution from .gclient file. | 143 """Read information about 'src' gclient solution from .gclient file. |
| 144 | 144 |
| 145 Returns tuple: | 145 Returns tuple: |
| 146 (url, deps_file, managed) | 146 (url, deps_file, managed) |
| 147 or | 147 or |
| 148 (None, None, None) if no such solution. | 148 (None, None, None) if no such solution. |
| 149 """ | 149 """ |
| 150 try: | 150 try: |
| 151 env = {} | 151 env = {} |
| 152 execfile(GCLIENT_CONFIG, env, env) | 152 execfile(GCLIENT_CONFIG, env, env) |
| 153 for sol in env['solutions']: | 153 for sol in (env.get('solutions') or []): |
| 154 if sol['name'] == 'src': | 154 if sol.get('name') == 'src': |
| 155 return sol.get('url'), sol.get('deps_file'), sol.get('managed') | 155 return sol.get('url'), sol.get('deps_file'), sol.get('managed') |
| 156 return None, None, None | 156 return None, None, None |
| 157 except Exception: | 157 except Exception: |
| 158 logging.exception('Failed to read .gclient solution') | 158 logging.exception('Failed to read .gclient solution') |
| 159 return None, None, None | 159 return None, None, None |
| 160 | 160 |
| 161 | 161 |
| 162 def scan_configuration(): | 162 def scan_configuration(): |
| 163 """Scans local environment for git related configuration values.""" | 163 """Scans local environment for git related configuration values.""" |
| 164 # Git checkout? | 164 # Git checkout? |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 report_url, | 346 report_url, |
| 347 verbose, | 347 verbose, |
| 348 push_works=push_works, | 348 push_works=push_works, |
| 349 push_log='\n'.join(runner.log), | 349 push_log='\n'.join(runner.log), |
| 350 push_duration_ms=int((time.time() - started) * 1000)) | 350 push_duration_ms=int((time.time() - started) * 1000)) |
| 351 return uploaded and not flake | 351 return uploaded and not flake |
| 352 | 352 |
| 353 | 353 |
| 354 def check_gclient_config(conf): | 354 def check_gclient_config(conf): |
| 355 """Shows warning if gclient solution is not properly configured for git.""" | 355 """Shows warning if gclient solution is not properly configured for git.""" |
| 356 # Ignore configs that do not have 'src' solution at all. |
| 357 if not conf['gclient_url']: |
| 358 return |
| 356 current = { | 359 current = { |
| 357 'name': 'src', | 360 'name': 'src', |
| 358 'deps_file': conf['gclient_deps'], | 361 'deps_file': conf['gclient_deps'], |
| 359 'managed': conf['gclient_managed'], | 362 'managed': conf['gclient_managed'], |
| 360 'url': conf['gclient_url'], | 363 'url': conf['gclient_url'], |
| 361 } | 364 } |
| 362 if current != GOOD_GCLIENT_SOLUTION: | 365 if current != GOOD_GCLIENT_SOLUTION: |
| 363 print '-' * 80 | 366 print '-' * 80 |
| 364 print 'Your gclient solution is not set to use supported git workflow!' | 367 print 'Your gclient solution is not set to use supported git workflow!' |
| 365 print | 368 print |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 write_last_configuration(config) | 482 write_last_configuration(config) |
| 480 else: | 483 else: |
| 481 logging.warning('Check failed and will be retried on the next run') | 484 logging.warning('Check failed and will be retried on the next run') |
| 482 except Exception: | 485 except Exception: |
| 483 logging.exception('Unexpected exception when performing git access check') | 486 logging.exception('Unexpected exception when performing git access check') |
| 484 return 0 | 487 return 0 |
| 485 | 488 |
| 486 | 489 |
| 487 if __name__ == '__main__': | 490 if __name__ == '__main__': |
| 488 sys.exit(main(sys.argv[1:])) | 491 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |