From f0c7bbec618df7143ac9611b990e670ac9921e50 Mon Sep 17 00:00:00 2001 From: Michael Achenbach Date: Wed, 5 Apr 2017 12:02:58 +0200 Subject: [PATCH] [tools] Make node update script patch application more robust Bug: v8:6154 NOTRY=true Change-Id: I877dfdbab01df6356e83ee81ca75d54a951b9cab Reviewed-on: https://chromium-review.googlesource.com/468886 Reviewed-by: Franziska Hinkelmann Commit-Queue: Michael Achenbach Cr-Commit-Position: refs/heads/master@{#44421} --- tools/release/update_node.py | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/tools/release/update_node.py b/tools/release/update_node.py index 99578d94f6..e05f71234d 100755 --- a/tools/release/update_node.py +++ b/tools/release/update_node.py @@ -43,26 +43,18 @@ def UninitGit(path): print ">> Cleaning up %s" % path shutil.rmtree(target) -def ApplyIndex(source, target): - if not subprocess.check_output(["git", "diff", "--cached"], cwd=source): - print ">> Ignoring empty patch" - return +def CommitPatch(options): + """Makes a dummy commit for the changes in the index. - print ">> Applying patch" - diff_proc = subprocess.Popen( - ["git", "diff", "--cached"], - cwd=source, - stdout=subprocess.PIPE, + On trybots, bot_updated applies the patch to the index. We commit it to make + the fake git clone fetch it into node.js. We can leave the commit, as + bot_update will ensure a clean state on each run. + """ + print ">> Comitting patch" + subprocess.check_call( + ["git", "commit", "--allow-empty", "-m", "placeholder-commit"], + cwd=options.v8_path, ) - apply_proc = subprocess.Popen( - ["git", "apply", "--index"], - cwd=target, - stdin=diff_proc.stdout, - ) - diff_proc.stdout.close() - apply_proc.communicate() - if apply_proc.returncode != 0: - raise Exception("Error applying patch") def UpdateTarget(repository, options): source = os.path.join(options.v8_path, *repository) @@ -84,8 +76,6 @@ def UpdateTarget(repository, options): try: for command in git_commands: subprocess.check_call(command, cwd=target) - if options.with_patch: - ApplyIndex(source, target) except: raise finally: @@ -144,6 +134,9 @@ def Main(args): options = ParseOptions(args) if options.gclient: RunGclient(options.v8_path) + # Commit patch on trybots to main V8 repository. + if options.with_patch: + CommitPatch(options) # Update main V8 repository. UpdateTarget([""], options) # Patch .gitignore before updating sub-repositories.