OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #library('git_source'); | 5 #library('git_source'); |
6 | 6 |
7 #import('io.dart'); | 7 #import('io.dart'); |
8 #import('package.dart'); | 8 #import('package.dart'); |
9 #import('source.dart'); | 9 #import('source.dart'); |
10 #import('source_registry.dart'); | 10 #import('source_registry.dart'); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 var ref = _getEffectiveRef(id); | 57 var ref = _getEffectiveRef(id); |
58 if (ref == 'HEAD') return new Future.immediate(null); | 58 if (ref == 'HEAD') return new Future.immediate(null); |
59 return _checkOut(revisionCachePath, ref); | 59 return _checkOut(revisionCachePath, ref); |
60 }).chain((_) => Package.load(revisionCachePath, systemCache.sources)); | 60 }).chain((_) => Package.load(revisionCachePath, systemCache.sources)); |
61 } | 61 } |
62 | 62 |
63 /** | 63 /** |
64 * The package name of a Git repo is the name of the directory into which | 64 * The package name of a Git repo is the name of the directory into which |
65 * it'll be cloned. | 65 * it'll be cloned. |
66 */ | 66 */ |
67 String packageName(description) => | 67 String packageName(description) { |
68 basename(_getUrl(description)).replaceFirst(const RegExp("\.git\$"), ""); | 68 return basename(_getUrl(description) |
| 69 .replaceFirst(const RegExp(@"(\.git)?/?$"), "")); |
| 70 } |
69 | 71 |
70 /** | 72 /** |
71 * Ensures [description] is a Git URL. | 73 * Ensures [description] is a Git URL. |
72 */ | 74 */ |
73 void validateDescription(description, [bool fromLockFile = false]) { | 75 void validateDescription(description, [bool fromLockFile = false]) { |
74 // A single string is assumed to be a Git URL. | 76 // A single string is assumed to be a Git URL. |
75 if (description is String) return; | 77 if (description is String) return; |
76 if (description is! Map || !description.containsKey('url')) { | 78 if (description is! Map || !description.containsKey('url')) { |
77 throw new FormatException("The description must be a Git URL or a map " | 79 throw new FormatException("The description must be a Git URL or a map " |
78 "with a 'url' key."); | 80 "with a 'url' key."); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 226 |
225 /** | 227 /** |
226 * Returns [description] if it's a description, or [PackageId.description] if | 228 * Returns [description] if it's a description, or [PackageId.description] if |
227 * it's a [PackageId]. | 229 * it's a [PackageId]. |
228 */ | 230 */ |
229 _getDescription(description) { | 231 _getDescription(description) { |
230 if (description is PackageId) return description.description; | 232 if (description is PackageId) return description.description; |
231 return description; | 233 return description; |
232 } | 234 } |
233 } | 235 } |
OLD | NEW |