Chromium Code Reviews| Index: tools/release/update_node.py |
| diff --git a/tools/release/update_node.py b/tools/release/update_node.py |
| index d4d2eafa114794a27294bf21d16ba9929a9eca38..422ddf73fe44f7d9334d518e1e378151b834f3c0 100755 |
| --- a/tools/release/update_node.py |
| +++ b/tools/release/update_node.py |
| @@ -34,7 +34,7 @@ ADD_TO_GITIGNORE = [ "/testing/gtest/*", |
| def RunGclient(path): |
| assert os.path.isdir(path) |
| print ">> Running gclient sync" |
| - subprocess.check_call("gclient sync --nohooks", cwd=path, shell=True) |
| + subprocess.check_call(["gclient", "sync", "--nohooks"], cwd=path) |
| def UninitGit(path): |
| target = os.path.join(path, ".git") |
| @@ -53,15 +53,15 @@ def UpdateTarget(repository, options): |
| UninitGit(target) |
| git_commands = [ |
| - "git init", # initialize target repo |
| - "git remote add origin %s" % source, # point to the source repo |
| - "git fetch origin HEAD", # sync to the current branch |
| - "git reset --hard FETCH_HEAD", # reset to the current branch |
| - "git clean -fd" # delete removed files |
| + ["git", "init"], # initialize target repo |
| + ["git", "remote", "add", "origin", source], # point to the source repo |
| + ["git", "fetch", "origin", "HEAD"], # sync to the current branch |
| + ["git", "reset", "--hard", "FETCH_HEAD"], # reset to the current branch |
| + ["git", "clean", "-fd"], # delete removed files |
| ] |
| try: |
| for command in git_commands: |
| - subprocess.check_call(command, cwd=target, shell=True); |
| + subprocess.check_call(command, cwd=target) |
| except: |
| raise |
| finally: |
| @@ -87,12 +87,32 @@ def UpdateGitIgnore(options): |
| for x in content: |
| gitignore.write("%s\n" % x) |
| +def CreateCommit(options): |
| + print ">> Creating commit." |
| + # Find git hash from source. |
| + process = subprocess.Popen(["git", "rev-parse", "HEAD"], cwd=options.v8_path, |
| + stdout=subprocess.PIPE) |
| + githash, error = process.communicate() |
| + if error is not None: |
|
Michael Achenbach
2017/03/14 10:50:42
I think error might be unused because you don't pi
Yang
2017/03/14 12:42:19
Changed to check_output
|
| + raise Exception("No commit hash found.") |
| + githash = githash.strip() |
| + # Create commit at target. |
| + git_commands = [ |
| + ["git", "checkout", "-b", "update_v8_to_%s" % githash[0:8]], # new branch |
|
Michael Achenbach
2017/03/14 10:50:42
In order to run this automatically, we might need
Yang
2017/03/14 12:42:19
Added these points to the issue.
|
| + ["git", "add", "."], # add files |
| + ["git", "commit", "-m", "Update V8 to %s" % githash] # new commit |
|
Michael Achenbach
2017/03/14 10:50:42
Maybe in the message, the small git hash is enough
Yang
2017/03/14 12:42:19
Done.
|
| + ] |
| + for command in git_commands: |
| + subprocess.check_call(command, cwd=options.node_path) |
| + |
| def ParseOptions(args): |
| parser = argparse.ArgumentParser(description="Update V8 in Node.js") |
| parser.add_argument("v8_path", help="Path to V8 checkout") |
| parser.add_argument("node_path", help="Path to Node.js checkout") |
| parser.add_argument("--gclient", dest="gclient", |
| action="store_true", help="Run gclient sync") |
| + parser.add_argument("--commit", dest="commit", |
|
Michael Achenbach
2017/03/14 10:50:42
nit: dest is redundant here, also above.
Yang
2017/03/14 12:42:19
Done.
|
| + action="store_true", help="Create commit") |
| options = parser.parse_args(args) |
| assert os.path.isdir(options.v8_path) |
| options.v8_path = os.path.abspath(options.v8_path) |
| @@ -110,6 +130,8 @@ def Main(args): |
| UpdateGitIgnore(options) |
| for repo in SUB_REPOSITORIES: |
| UpdateTarget(repo, options) |
| + if options.commit: |
| + CreateCommit(options) |
| if __name__ == "__main__": |
| Main(sys.argv[1:]) |