| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 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 | 6 |
| 7 """Forcibly update the local checkout.""" | 7 """Forcibly update the local checkout.""" |
| 8 | 8 |
| 9 | 9 |
| 10 | 10 |
| 11 import os | 11 import os |
| 12 import shlex | 12 import shlex |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 import misc | 15 import misc |
| 16 | 16 |
| 17 sys.path.append(os.path.join(misc.BUILDBOT_PATH, 'site_config')) | 17 sys.path.append(os.path.join(misc.BUILDBOT_PATH, 'site_config')) |
| 18 sys.path.append(os.path.join(misc.BUILDBOT_PATH, 'third_party', | 18 sys.path.append(os.path.join(misc.BUILDBOT_PATH, 'third_party', |
| 19 'chromium_buildbot', 'scripts')) | 19 'chromium_buildbot', 'scripts')) |
| 20 | 20 |
| 21 from git_utils import GIT | |
| 22 import gclient_utils | 21 import gclient_utils |
| 22 import git_utils |
| 23 import shell_utils | 23 import shell_utils |
| 24 import skia_vars | 24 import skia_vars |
| 25 | 25 |
| 26 | 26 |
| 27 BUILDBOT_GIT_URL = skia_vars.GetGlobalVariable('buildbot_git_url') | 27 BUILDBOT_GIT_URL = skia_vars.GetGlobalVariable('buildbot_git_url') |
| 28 GOT_REVISION_PATTERN = 'Skiabot scripts updated to %s' | 28 GOT_REVISION_PATTERN = 'Skiabot scripts updated to %s' |
| 29 | 29 |
| 30 | 30 |
| 31 def force_update(): | 31 def force_update(): |
| 32 with misc.ChDir(os.path.join(misc.BUILDBOT_PATH, os.pardir)): | 32 with misc.ChDir(os.path.join(misc.BUILDBOT_PATH, os.pardir)): |
| 33 # Be sure that we sync to the most recent commit. | 33 # Be sure that we sync to the most recent commit. |
| 34 buildbot_revision = None | 34 buildbot_revision = None |
| 35 try: | 35 try: |
| 36 # TODO(borenet): Make this a function in git_utils. Something like, | 36 output = git_utils.GetRemoteMasterHash(BUILDBOT_GIT_URL) |
| 37 # "GetRemoteMasterHash" | |
| 38 output = shell_utils.run([GIT, 'ls-remote', | |
| 39 BUILDBOT_GIT_URL, '--verify', | |
| 40 'refs/heads/master']) | |
| 41 if output: | 37 if output: |
| 42 buildbot_revision = shlex.split(output)[0] | 38 buildbot_revision = shlex.split(output)[0] |
| 43 except shell_utils.CommandFailedException: | 39 except shell_utils.CommandFailedException: |
| 44 pass | 40 pass |
| 45 if not buildbot_revision: | 41 if not buildbot_revision: |
| 46 buildbot_revision = 'origin/master' | 42 buildbot_revision = 'origin/master' |
| 47 | 43 |
| 48 gclient_utils.Sync(revisions=[('buildbot', buildbot_revision)], | 44 gclient_utils.Sync(revisions=[('buildbot', buildbot_revision)], |
| 49 verbose=True, force=True) | 45 verbose=True, force=True) |
| 50 got_revision = gclient_utils.GetCheckedOutHash() | 46 got_revision = gclient_utils.GetCheckedOutHash() |
| 51 print GOT_REVISION_PATTERN % got_revision | 47 print GOT_REVISION_PATTERN % got_revision |
| 52 | 48 |
| 53 return gclient_utils.GetCheckedOutHash() | 49 return gclient_utils.GetCheckedOutHash() |
| 54 | 50 |
| 55 | 51 |
| 56 if __name__ == '__main__': | 52 if __name__ == '__main__': |
| 57 force_update() | 53 force_update() |
| OLD | NEW |