| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2015 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 | 6 |
| 7 """Wrapper for updating and calling infra.git tools. | 7 """Wrapper for updating and calling infra.git tools. |
| 8 | 8 |
| 9 This tool does a two things: | 9 This tool does a two things: |
| 10 * Maintains a infra.git checkout pinned at "deployed" in the home dir | 10 * Maintains a infra.git checkout pinned at "deployed" in the home dir |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 """Checks to see if we need to update the ~/.chrome-infra/infra checkout.""" | 35 """Checks to see if we need to update the ~/.chrome-infra/infra checkout.""" |
| 36 try: | 36 try: |
| 37 cmd = [sys.executable, GCLIENT, 'revinfo'] | 37 cmd = [sys.executable, GCLIENT, 'revinfo'] |
| 38 subprocess.check_call( | 38 subprocess.check_call( |
| 39 cmd, cwd=os.path.join(TARGET_DIR), stdout=subprocess.PIPE) | 39 cmd, cwd=os.path.join(TARGET_DIR), stdout=subprocess.PIPE) |
| 40 except subprocess.CalledProcessError: | 40 except subprocess.CalledProcessError: |
| 41 return True # Gclient failed, definitely need to update. | 41 return True # Gclient failed, definitely need to update. |
| 42 except OSError: | 42 except OSError: |
| 43 return True # Gclient failed, definitely need to update. | 43 return True # Gclient failed, definitely need to update. |
| 44 | 44 |
| 45 if not os.path.isdir(INFRA_DIR): |
| 46 return True |
| 47 |
| 45 local_rev = get_git_rev(INFRA_DIR, 'HEAD') | 48 local_rev = get_git_rev(INFRA_DIR, 'HEAD') |
| 46 | 49 |
| 47 subprocess.check_call( | 50 subprocess.check_call( |
| 48 ['git', 'fetch', 'origin'], cwd=INFRA_DIR, | 51 ['git', 'fetch', 'origin'], cwd=INFRA_DIR, |
| 49 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 52 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 50 origin_rev = get_git_rev(INFRA_DIR, 'origin/%s' % (branch,)) | 53 origin_rev = get_git_rev(INFRA_DIR, 'origin/%s' % (branch,)) |
| 51 return origin_rev != local_rev | 54 return origin_rev != local_rev |
| 52 | 55 |
| 53 | 56 |
| 54 def ensure_infra(branch): | 57 def ensure_infra(branch): |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 args.args.pop(0) | 111 args.args.pop(0) |
| 109 if extras: | 112 if extras: |
| 110 args.args = extras + args.args | 113 args.args = extras + args.args |
| 111 | 114 |
| 112 if need_to_update(args.infra_branch): | 115 if need_to_update(args.infra_branch): |
| 113 ensure_infra(args.infra_branch) | 116 ensure_infra(args.infra_branch) |
| 114 return run(args.args) | 117 return run(args.args) |
| 115 | 118 |
| 116 if __name__ == '__main__': | 119 if __name__ == '__main__': |
| 117 sys.exit(main()) | 120 sys.exit(main()) |
| OLD | NEW |