Commit 6d0c0ffe authored by Stephanie Kim's avatar Stephanie Kim Committed by LUCI CQ

Add previous_got_revision and previous_got_revision_cp to output

As chrome browser infra works to improve CQ times, we would like to
easily glance at builds and see how many new commits were checked out.
Currently you have to open up bot_update stdout to see the previous
HEAD revision and go from there. Having this conveniently outputted
would be very convenient.

If the bot has previously checked out the repo, output which revision
and commit position were checked out.

example LED build showing new output: https://ci.chromium.org/swarming/task/51592e46d6a70e10?server=chromium-swarm.appspot.com

Change-Id: Ib8a6f152a593446ce4082477bc9ada44f1fd1fc3
Bug: 1170568
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2644829Reviewed-by: 's avatarJosip Sokcevic <sokcevic@google.com>
Commit-Queue: Stephanie Kim <kimstephanie@google.com>
parent 76d0e6ac
......@@ -839,7 +839,8 @@ def get_commit_position(git_path, revision='HEAD'):
return None
def parse_got_revision(gclient_output, got_revision_mapping):
def parse_got_revision(gclient_output, got_revision_mapping,
prev_checkout_info):
"""Translate git gclient revision mapping to build properties."""
properties = {}
solutions_output = {
......@@ -862,9 +863,16 @@ def parse_got_revision(gclient_output, got_revision_mapping):
revision = git('rev-parse', 'HEAD', cwd=dir_name).strip()
commit_position = get_commit_position(dir_name)
prev_revision, prev_cp = prev_checkout_info.get(dir_name.rstrip('/'),
(None, None))
properties[property_name] = revision
if prev_revision:
properties['prev_%s' % property_name] = prev_revision
if commit_position:
properties['%s_cp' % property_name] = commit_position
if prev_cp:
properties['prev_%s_cp' % property_name] = prev_cp
return properties
......@@ -1105,6 +1113,16 @@ def prepare(options, git_slns, active):
print('Fetching Git checkout at %s@%s' % (first_sln, revisions[first_sln]))
return revisions, step_text
def current_checkout_info(solutions):
r = {}
build_dir = os.getcwd()
for sln in solutions:
sln_dir = path.join(build_dir, sln['name'])
if path.isdir(sln_dir) and not is_broken_repo_dir(sln_dir):
r[sln['name']] = (git('rev-parse', 'HEAD', cwd=sln_dir).strip(),
get_commit_position(sln_dir))
return r
def checkout(options, git_slns, specs, revisions, step_text):
print('Using Python version: %s' % (sys.version,))
......@@ -1128,6 +1146,8 @@ def checkout(options, git_slns, specs, revisions, step_text):
# create file, no content
pass
prev_checkout_info = current_checkout_info(git_slns)
should_delete_dirty_file = False
try:
......@@ -1201,7 +1221,8 @@ def checkout(options, git_slns, specs, revisions, step_text):
if not revision_mapping:
revision_mapping['got_revision'] = first_sln
got_revisions = parse_got_revision(gclient_output, revision_mapping)
got_revisions = parse_got_revision(gclient_output, revision_mapping,
prev_checkout_info)
if not got_revisions:
# TODO(hinoka): We should probably bail out here, but in the interest
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment