| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 def istype(self, repodir): | 82 def istype(self, repodir): |
| 83 return os.path.exists(os.path.join(repodir, ".git")) | 83 return os.path.exists(os.path.join(repodir, ".git")) |
| 84 | 84 |
| 85 def clone(self, source, target): | 85 def clone(self, source, target): |
| 86 source = source.rstrip("/") | 86 source = source.rstrip("/") |
| 87 if not source.endswith(".git"): | 87 if not source.endswith(".git"): |
| 88 source += ".git" | 88 source += ".git" |
| 89 subprocess.check_call(["git", "clone", "--quiet", source, target]) | 89 subprocess.check_call(["git", "clone", "--quiet", source, target]) |
| 90 | 90 |
| 91 def get_revision_id(self, repo, rev="HEAD"): | 91 def get_revision_id(self, repo, rev="HEAD"): |
| 92 command = ["git", "rev-parse", "--revs-only", rev] | 92 command = ["git", "rev-list", "--remotes=*", "--max-count=1", rev] |
|
Wladimir Palant
2015/01/11 23:10:22
Note that I don't really know how to use Git, and
Wladimir Palant
2015/01/11 23:39:28
I noticed that the rev-list with --remotes specifi
| |
| 93 return subprocess.check_output(command, cwd=repo).strip() | 93 process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subproces s.PIPE, cwd=repo) |
| 94 | |
| 95 # Ignore stderr output and return code here: if revision lookup failed we | |
| 96 # should simply return an empty string. | |
| 97 result = process.communicate()[0] | |
| 98 return result.strip() | |
| 94 | 99 |
| 95 def pull(self, repo): | 100 def pull(self, repo): |
| 96 subprocess.check_call(["git", "fetch", "--quiet", "--all", "--tags"], cwd=re po) | 101 subprocess.check_call(["git", "fetch", "--quiet", "--all", "--tags"], cwd=re po) |
| 97 | 102 |
| 98 def update(self, repo, rev): | 103 def update(self, repo, rev): |
| 99 subprocess.check_call(["git", "checkout", "--quiet", rev], cwd=repo) | 104 subprocess.check_call(["git", "checkout", "--quiet", rev], cwd=repo) |
| 100 | 105 |
| 101 def ignore(self, target, repo): | 106 def ignore(self, target, repo): |
| 102 module = os.path.relpath(target, repo) | 107 module = os.path.relpath(target, repo) |
| 103 exclude_file = os.path.join(repo, ".git", "info", "exclude") | 108 exclude_file = os.path.join(repo, ".git", "info", "exclude") |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 for l in file_content: | 281 for l in file_content: |
| 277 print >>f, l | 282 print >>f, l |
| 278 | 283 |
| 279 if __name__ == "__main__": | 284 if __name__ == "__main__": |
| 280 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) | 285 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) |
| 281 repos = sys.argv[1:] | 286 repos = sys.argv[1:] |
| 282 if not len(repos): | 287 if not len(repos): |
| 283 repos = [os.getcwd()] | 288 repos = [os.getcwd()] |
| 284 for repo in repos: | 289 for repo in repos: |
| 285 resolve_deps(repo) | 290 resolve_deps(repo) |
| OLD | NEW |