| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # coding: utf-8 | 2 # coding: utf-8 |
| 3 | 3 |
| 4 # This Source Code Form is subject to the terms of the Mozilla Public | 4 # This Source Code Form is subject to the terms of the Mozilla Public |
| 5 # License, v. 2.0. If a copy of the MPL was not distributed with this | 5 # License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 6 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 | 7 |
| 8 import sys | 8 import sys |
| 9 import os | 9 import os |
| 10 import posixpath | 10 import posixpath |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 source = source.rstrip("/") | 90 source = source.rstrip("/") |
| 91 if not source.endswith(".git"): | 91 if not source.endswith(".git"): |
| 92 source += ".git" | 92 source += ".git" |
| 93 subprocess.check_call(["git", "clone", "--quiet", source, target]) | 93 subprocess.check_call(["git", "clone", "--quiet", source, target]) |
| 94 | 94 |
| 95 def get_revision_id(self, repo, rev="HEAD"): | 95 def get_revision_id(self, repo, rev="HEAD"): |
| 96 command = ["git", "rev-parse", "--revs-only", rev + '^{commit}'] | 96 command = ["git", "rev-parse", "--revs-only", rev + '^{commit}'] |
| 97 return subprocess.check_output(command, cwd=repo).strip() | 97 return subprocess.check_output(command, cwd=repo).strip() |
| 98 | 98 |
| 99 def pull(self, repo): | 99 def pull(self, repo): |
| 100 # First perform a fetch so we have a list of remote branch names | |
| 101 subprocess.check_call(["git", "fetch", "--quiet", "origin"], cwd=repo) | |
| 102 # Next we need to ensure all remote branches are tracked | |
| 103 remotes = subprocess.check_output(["git", "branch", "--remotes"], cwd=repo) | |
| 104 for match in re.finditer(r"origin/(\S+)", remotes): | |
|
Sebastian Noack
2015/05/06 12:18:55
This regex will match "notorigin/foo" as well. Tha
Sebastian Noack
2015/05/06 12:45:00
Alternatively, not using a regex, might result in
kzar
2015/05/06 12:51:04
Done.
kzar
2015/05/06 12:51:04
I will stick with the regexp, one line in the outp
| |
| 105 remote, local = match.group(0), match.group(1) | |
|
Sebastian Noack
2015/05/06 12:18:55
With the regex suggested above, you can simply cal
kzar
2015/05/06 12:51:04
Done.
| |
| 106 if local != "HEAD": | |
| 107 with open(os.devnull, "w") as devnull: | |
|
Sebastian Noack
2015/05/06 12:18:55
Nit: Please use "wb", no need to have newlines uni
kzar
2015/05/06 12:51:04
Done.
| |
| 108 subprocess.call(["git", "branch", "--track", local, remote], | |
| 109 cwd=repo, stdout=devnull, stderr=devnull) | |
| 110 # Finally we need to actually fetch all the remote branches and tags | |
| 100 subprocess.check_call(["git", "fetch", "--quiet", "--all", "--tags"], cwd=re po) | 111 subprocess.check_call(["git", "fetch", "--quiet", "--all", "--tags"], cwd=re po) |
|
Sebastian Noack
2015/05/06 12:18:55
Please specify "origin" instead "--all" here like
Sebastian Noack
2015/05/06 12:18:55
If you move the --tags option to the first "git fe
kzar
2015/05/06 12:51:04
Done.
| |
| 101 | 112 |
| 102 def update(self, repo, rev): | 113 def update(self, repo, rev): |
| 103 subprocess.check_call(["git", "checkout", "--quiet", rev], cwd=repo) | 114 subprocess.check_call(["git", "checkout", "--quiet", rev], cwd=repo) |
| 104 | 115 |
| 105 def ignore(self, target, repo): | 116 def ignore(self, target, repo): |
| 106 module = os.path.relpath(target, repo) | 117 module = os.path.relpath(target, repo) |
| 107 exclude_file = os.path.join(repo, ".git", "info", "exclude") | 118 exclude_file = os.path.join(repo, ".git", "info", "exclude") |
| 108 _ensure_line_exists(exclude_file, module) | 119 _ensure_line_exists(exclude_file, module) |
| 109 | 120 |
| 110 def postprocess_url(self, url): | 121 def postprocess_url(self, url): |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 args = parser.parse_args() | 315 args = parser.parse_args() |
| 305 | 316 |
| 306 if args.quiet: | 317 if args.quiet: |
| 307 logging.disable(logging.INFO) | 318 logging.disable(logging.INFO) |
| 308 | 319 |
| 309 repos = args.repos | 320 repos = args.repos |
| 310 if not len(repos): | 321 if not len(repos): |
| 311 repos = [os.path.dirname(__file__)] | 322 repos = [os.path.dirname(__file__)] |
| 312 for repo in repos: | 323 for repo in repos: |
| 313 resolve_deps(repo) | 324 resolve_deps(repo) |
| OLD | NEW |