OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Meta checkout manager supporting both Subversion and GIT.""" | 6 """Meta checkout manager supporting both Subversion and GIT.""" |
7 # Files | 7 # Files |
8 # .gclient : Current client configuration, written by 'config' command. | 8 # .gclient : Current client configuration, written by 'config' command. |
9 # Format is a Python script defining 'solutions', a list whose | 9 # Format is a Python script defining 'solutions', a list whose |
10 # entries each are maps binding the strings "name" and "url" | 10 # entries each are maps binding the strings "name" and "url" |
(...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1879 client.SetConfig(options.spec) | 1879 client.SetConfig(options.spec) |
1880 else: | 1880 else: |
1881 base_url = args[0].rstrip('/') | 1881 base_url = args[0].rstrip('/') |
1882 if not options.name: | 1882 if not options.name: |
1883 name = base_url.split('/')[-1] | 1883 name = base_url.split('/')[-1] |
1884 if name.endswith('.git'): | 1884 if name.endswith('.git'): |
1885 name = name[:-4] | 1885 name = name[:-4] |
1886 else: | 1886 else: |
1887 # specify an alternate relpath for the given URL. | 1887 # specify an alternate relpath for the given URL. |
1888 name = options.name | 1888 name = options.name |
1889 if not os.path.abspath(os.path.join(os.getcwd(), name)).startswith( | |
1890 os.getcwd()): | |
1891 parser.error('Do not pass a relative path for --name.') | |
1892 pieces = name.split(os.sep) | |
Lei Zhang
2015/10/20 00:55:21
just roll |pieces| into any() ?
agable
2015/10/20 01:05:27
Done.
| |
1893 if any(x in ('..', '.', '/', '\\') for x in pieces): | |
1894 parser.error('Do not include relative path components in --name.') | |
1895 | |
1889 deps_file = options.deps_file | 1896 deps_file = options.deps_file |
1890 safesync_url = '' | 1897 safesync_url = '' |
1891 if len(args) > 1: | 1898 if len(args) > 1: |
1892 safesync_url = args[1] | 1899 safesync_url = args[1] |
1893 client.SetDefaultConfig(name, deps_file, base_url, safesync_url, | 1900 client.SetDefaultConfig(name, deps_file, base_url, safesync_url, |
1894 managed=not options.unmanaged, | 1901 managed=not options.unmanaged, |
1895 cache_dir=options.cache_dir) | 1902 cache_dir=options.cache_dir) |
1896 client.SaveConfig() | 1903 client.SaveConfig() |
1897 return 0 | 1904 return 0 |
1898 | 1905 |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2309 | 2316 |
2310 | 2317 |
2311 if '__main__' == __name__: | 2318 if '__main__' == __name__: |
2312 try: | 2319 try: |
2313 sys.exit(main(sys.argv[1:])) | 2320 sys.exit(main(sys.argv[1:])) |
2314 except KeyboardInterrupt: | 2321 except KeyboardInterrupt: |
2315 sys.stderr.write('interrupted\n') | 2322 sys.stderr.write('interrupted\n') |
2316 sys.exit(1) | 2323 sys.exit(1) |
2317 | 2324 |
2318 # vim: ts=2:sw=2:tw=80:et: | 2325 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |