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

Side by Side Diff: gclient.py

Issue 1406053003: Error out in `gclient config` if --name is relative (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Comments Created 5 years, 2 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 | Annotate | Revision Log
« 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
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
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 if any(x in ('..', '.', '/', '\\') for x in name.split(os.sep)):
1893 parser.error('Do not include relative path components in --name.')
1894
1889 deps_file = options.deps_file 1895 deps_file = options.deps_file
1890 safesync_url = '' 1896 safesync_url = ''
1891 if len(args) > 1: 1897 if len(args) > 1:
1892 safesync_url = args[1] 1898 safesync_url = args[1]
1893 client.SetDefaultConfig(name, deps_file, base_url, safesync_url, 1899 client.SetDefaultConfig(name, deps_file, base_url, safesync_url,
1894 managed=not options.unmanaged, 1900 managed=not options.unmanaged,
1895 cache_dir=options.cache_dir) 1901 cache_dir=options.cache_dir)
1896 client.SaveConfig() 1902 client.SaveConfig()
1897 return 0 1903 return 0
1898 1904
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 2315
2310 2316
2311 if '__main__' == __name__: 2317 if '__main__' == __name__:
2312 try: 2318 try:
2313 sys.exit(main(sys.argv[1:])) 2319 sys.exit(main(sys.argv[1:]))
2314 except KeyboardInterrupt: 2320 except KeyboardInterrupt:
2315 sys.stderr.write('interrupted\n') 2321 sys.stderr.write('interrupted\n')
2316 sys.exit(1) 2322 sys.exit(1)
2317 2323
2318 # vim: ts=2:sw=2:tw=80:et: 2324 # vim: ts=2:sw=2:tw=80:et:
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