LEFT | RIGHT |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # This Source Code Form is subject to the terms of the Mozilla Public | 3 # This Source Code Form is subject to the terms of the Mozilla Public |
4 # License, v. 2.0. If a copy of the MPL was not distributed with this | 4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
6 | 6 |
7 import sys | 7 import sys |
8 import os | 8 import os |
9 import posixpath | 9 import posixpath |
10 import re | 10 import re |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if subprocess.call(['git', 'branch', '--track', local, remote], | 117 if subprocess.call(['git', 'branch', '--track', local, remote], |
118 cwd=repo, stdout=devnull, stderr=devnull) ==
0: | 118 cwd=repo, stdout=devnull, stderr=devnull) ==
0: |
119 newly_tracked = True | 119 newly_tracked = True |
120 # Finally fetch any newly tracked remote branches | 120 # Finally fetch any newly tracked remote branches |
121 if newly_tracked: | 121 if newly_tracked: |
122 subprocess.check_call(['git', 'fetch', '--quiet', 'origin'], cwd=rep
o) | 122 subprocess.check_call(['git', 'fetch', '--quiet', 'origin'], cwd=rep
o) |
123 | 123 |
124 def update(self, repo, rev, revname): | 124 def update(self, repo, rev, revname): |
125 subprocess.check_call(['git', 'checkout', '--quiet', revname], cwd=repo) | 125 subprocess.check_call(['git', 'checkout', '--quiet', revname], cwd=repo) |
126 | 126 |
| 127 def parse_repo_path(self, dot_git_path): |
| 128 # .git for submodule is a file with actual repo path like so: |
| 129 # gitdir: ../.git/some_path/some_other_path |
| 130 with open(dot_git_path, 'r') as f: |
| 131 return f.read().replace('\n', '')[8:] # skip 'gitdir: ' (8 first charact
ers) |
| 132 |
127 def ignore(self, target, repo): | 133 def ignore(self, target, repo): |
128 module = os.path.sep + os.path.relpath(target, repo) | 134 module = os.path.relpath(target, repo) |
129 exclude_file = os.path.join(repo, '.git', 'info', 'exclude') | 135 dot_git_path = os.path.join(repo, ".git") |
130 _ensure_line_exists(exclude_file, module) | 136 exclude_file = os.path.join(dot_git_path, "info", "exclude") |
| 137 if os.path.isfile(dot_git_path): |
| 138 logging.warning("%s seems to be Git submodule" % dot_git_path) |
| 139 new_repo = self.parse_repo_path(dot_git_path) |
| 140 logging.warning('actual repo path is %s' % new_repo) |
| 141 exclude_file = os.path.join(new_repo, "info", "exclude") |
| 142 _ensure_line_exists(exclude_file, module) |
131 | 143 |
132 def postprocess_url(self, url): | 144 def postprocess_url(self, url): |
133 # Handle alternative syntax of SSH URLS | 145 # Handle alternative syntax of SSH URLS |
134 if '@' in url and ':' in url and not urlparse.urlsplit(url).scheme: | 146 if '@' in url and ':' in url and not urlparse.urlsplit(url).scheme: |
135 return 'ssh://' + url.replace(':', '/', 1) | 147 return 'ssh://' + url.replace(':', '/', 1) |
136 return url | 148 return url |
137 | 149 |
138 repo_types = OrderedDict(( | 150 repo_types = OrderedDict(( |
139 ('hg', Mercurial()), | 151 ('hg', Mercurial()), |
140 ('git', Git()), | 152 ('git', Git()), |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 args = parser.parse_args() | 383 args = parser.parse_args() |
372 | 384 |
373 if args.quiet: | 385 if args.quiet: |
374 logging.disable(logging.INFO) | 386 logging.disable(logging.INFO) |
375 | 387 |
376 repos = args.repos | 388 repos = args.repos |
377 if not len(repos): | 389 if not len(repos): |
378 repos = [os.path.dirname(__file__)] | 390 repos = [os.path.dirname(__file__)] |
379 for repo in repos: | 391 for repo in repos: |
380 resolve_deps(repo) | 392 resolve_deps(repo) |
LEFT | RIGHT |