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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 "Please ensure Git is correctly installed."); | 42 "Please ensure Git is correctly installed."); |
43 } | 43 } |
44 | 44 |
45 return ensureDir(join(systemCacheRoot, 'cache')); | 45 return ensureDir(join(systemCacheRoot, 'cache')); |
46 }).then((_) => _ensureRepoCache(id)) | 46 }).then((_) => _ensureRepoCache(id)) |
47 .then((_) => _revisionCachePath(id)) | 47 .then((_) => _revisionCachePath(id)) |
48 .then((path) { | 48 .then((path) { |
49 revisionCachePath = path; | 49 revisionCachePath = path; |
50 return exists(revisionCachePath); | 50 return exists(revisionCachePath); |
51 }).then((exists) { | 51 }).then((exists) { |
52 if (exists) return new Future.immediate(null); | 52 if (exists) return; |
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 new Future.immediate(null); | 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 /// Ensures [description] is a Git URL. | 63 /// Ensures [description] is a Git URL. |
64 void validateDescription(description, {bool fromLockFile: false}) { | 64 void validateDescription(description, {bool fromLockFile: false}) { |
65 // A single string is assumed to be a Git URL. | 65 // A single string is assumed to be a Git URL. |
66 if (description is String) return; | 66 if (description is String) return; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 return description['ref']; | 191 return description['ref']; |
192 } | 192 } |
193 | 193 |
194 /// Returns [description] if it's a description, or [PackageId.description] if | 194 /// Returns [description] if it's a description, or [PackageId.description] if |
195 /// it's a [PackageId]. | 195 /// it's a [PackageId]. |
196 _getDescription(description) { | 196 _getDescription(description) { |
197 if (description is PackageId) return description.description; | 197 if (description is PackageId) return description.description; |
198 return description; | 198 return description; |
199 } | 199 } |
200 } | 200 } |
OLD | NEW |