Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: tools/release/update_node.py

Issue 2744663005: Add script to update relevant changes to Node.js. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2017 the V8 project authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import argparse
7 import os
8 import shutil
9 import subprocess
10
11 TARGET_SUBDIR = os.path.join("deps", "v8")
12 REPOSITORIES = [ [""],
13 ["testing", "gtest"],
14 ["third_party", "jinja2"],
15 ["third_party", "markupsafe"] ]
16
17 def RunGclient(path):
18 assert os.path.isdir(path)
19 print ">> Running gclient sync"
20 subprocess.call("gclient sync --nohooks",
21 cwd=path, shell=True, stdout=None)
Michael Achenbach 2017/03/10 13:35:06 nit: stdout=None is the default, can be dropped.
Yang 2017/03/13 08:25:49 Done.
22
23 def UpdateTarget(repository, options):
24 source = os.path.join(options.v8_path, *repository)
25 target = os.path.join(options.node_path, TARGET_SUBDIR, *repository)
26 print ">> Updating target directory %s" % source
Michael Achenbach 2017/03/10 13:35:05 nit - readability: it's a bit confusing to read "t
Yang 2017/03/13 08:25:49 You are right. It should print target first and so
27 print ">> from active branch at %s" % target
28 git_commands = [
Michael Achenbach 2017/03/10 13:35:05 Is there any assumption about the directory state,
Yang 2017/03/13 08:25:49 Done.
29 "git init", # initialize target repo
30 "git remote add origin %s" % source, # point to the source repo
Michael Achenbach 2017/03/10 13:35:06 Does this work if the git repro in source folder u
Yang 2017/03/13 08:25:49 I'm not familiar with git cache. Isn't it provided
Michael Achenbach 2017/03/13 10:33:23 Not sure if everything works as expected when maki
31 "git fetch origin HEAD", # sync to the current branch
32 "git reset --hard FETCH_HEAD", # reset to the current branch
33 "git clean -fd" # delete removed files
34 ]
35 try:
36 for command in git_commands:
37 subprocess.call(command, cwd=target, shell=True, stdout=None)
Michael Achenbach 2017/03/10 13:35:06 nit: drop stdout, like above
Yang 2017/03/13 08:25:49 Done.
38 except:
39 print ">> Failed!"
Michael Achenbach 2017/03/10 13:35:06 Do we need this?
Yang 2017/03/13 08:25:49 Removed
40 raise
41 finally:
42 # Un-init git.
43 print ">> Cleaning up"
44 shutil.rmtree(os.path.join(target, ".git"))
45 print
46
47 def UpdateGitIgnore(options):
48 file_name = os.path.join(options.node_path, TARGET_SUBDIR, ".gitignore")
49 assert os.path.isfile(file_name)
50 print ">> Updating .gitignore with lines"
51 with open(file_name, "a") as gitignore:
Michael Achenbach 2017/03/10 13:35:05 Won't this append over and over again? What if the
Yang 2017/03/13 08:25:49 Done.
52 for repository in REPOSITORIES:
53 sub_repo = "/".join(repository)
54 if not sub_repo is "":
55 line = "!/" + sub_repo
56 print line
57 gitignore.write(line + "\n")
58
59 def ParseOptions():
60 parser = argparse.ArgumentParser(description="Update V8 in Node.js")
61 parser.add_argument("v8_path", help="Path to V8 checkout")
62 parser.add_argument("node_path", help="Path to Node.js checkout")
63 parser.add_argument("--gclient", dest="gclient",
64 action="store_true", help="Run gclient sync")
65 options = parser.parse_args()
66 assert os.path.isdir(options.v8_path)
67 options.v8_path = os.path.abspath(options.v8_path)
68 assert os.path.isdir(options.node_path)
69 options.node_path = os.path.abspath(options.node_path)
70 return options
71
72 def Main():
73 options = ParseOptions()
74 if options.gclient:
75 RunGclient(options.v8_path)
76 [UpdateTarget(repo, options) for repo in REPOSITORIES]
Michael Achenbach 2017/03/10 13:35:05 I'm having a one-line fetish too, but maybe here i
Yang 2017/03/13 08:25:49 Done.
77 UpdateGitIgnore(options)
78
79 if __name__ == "__main__":
80 Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698