| 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 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'git.dart' as git; | 8 import 'git.dart' as git; |
| 9 import 'io.dart'; | 9 import 'io.dart'; |
| 10 import 'package.dart'; | 10 import 'package.dart'; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 return _clone(_repoCachePath(id), revisionCachePath, mirror: false); | 53 return _clone(_repoCachePath(id), revisionCachePath, mirror: false); |
| 54 }).then((_) { | 54 }).then((_) { |
| 55 var ref = _getEffectiveRef(id); | 55 var ref = _getEffectiveRef(id); |
| 56 if (ref == 'HEAD') return; | 56 if (ref == 'HEAD') return; |
| 57 return _checkOut(revisionCachePath, ref); | 57 return _checkOut(revisionCachePath, ref); |
| 58 }).then((_) { | 58 }).then((_) { |
| 59 return Package.load(id.name, revisionCachePath, systemCache.sources); | 59 return Package.load(id.name, revisionCachePath, systemCache.sources); |
| 60 }); | 60 }); |
| 61 } | 61 } |
| 62 | 62 |
| 63 Future<String> systemCacheDirectory(PackageId id) => _revisionCachePath(id); |
| 64 |
| 63 /// Ensures [description] is a Git URL. | 65 /// Ensures [description] is a Git URL. |
| 64 void validateDescription(description, {bool fromLockFile: false}) { | 66 void validateDescription(description, {bool fromLockFile: false}) { |
| 65 // A single string is assumed to be a Git URL. | 67 // A single string is assumed to be a Git URL. |
| 66 if (description is String) return; | 68 if (description is String) return; |
| 67 if (description is! Map || !description.containsKey('url')) { | 69 if (description is! Map || !description.containsKey('url')) { |
| 68 throw new FormatException("The description must be a Git URL or a map " | 70 throw new FormatException("The description must be a Git URL or a map " |
| 69 "with a 'url' key."); | 71 "with a 'url' key."); |
| 70 } | 72 } |
| 71 description = new Map.from(description); | 73 description = new Map.from(description); |
| 72 description.remove('url'); | 74 description.remove('url'); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 return description['ref']; | 193 return description['ref']; |
| 192 } | 194 } |
| 193 | 195 |
| 194 /// Returns [description] if it's a description, or [PackageId.description] if | 196 /// Returns [description] if it's a description, or [PackageId.description] if |
| 195 /// it's a [PackageId]. | 197 /// it's a [PackageId]. |
| 196 _getDescription(description) { | 198 _getDescription(description) { |
| 197 if (description is PackageId) return description.description; | 199 if (description is PackageId) return description.description; |
| 198 return description; | 200 return description; |
| 199 } | 201 } |
| 200 } | 202 } |
| OLD | NEW |