Skip to content

Commit 21cdd4d

Browse files
authored
Revert "Merge pull request #4650 from dart-lang/merge-cherry_pick_tag_pattern_fix" (#4651)
This reverts commit f486823, reversing changes made to 469eb61.
1 parent f486823 commit 21cdd4d

File tree

13 files changed

+52
-8
lines changed

13 files changed

+52
-8
lines changed

lib/pub.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'src/entrypoint.dart';
88
import 'src/exceptions.dart';
99
import 'src/http.dart';
1010
import 'src/pub_embeddable_command.dart';
11+
import 'src/source/git.dart';
1112
import 'src/system_cache.dart';
1213

1314
export 'src/executable.dart'
@@ -67,3 +68,39 @@ class ResolutionFailedException implements Exception {
6768
String message;
6869
ResolutionFailedException._(this.message);
6970
}
71+
72+
/// Given a Git repo that contains a pub package, gets the name of the pub
73+
/// package.
74+
///
75+
/// Will download the repo to the system cache under the assumption that the
76+
/// package will be downloaded afterwards.
77+
///
78+
/// [url] points to the git repository. If it is a relative url, it is resolved
79+
/// as a file url relative to the path [relativeTo].
80+
///
81+
/// [ref] is the commit, tag, or branch name where the package should be looked
82+
/// up when fetching the name. If omitted, 'HEAD' is used.
83+
///
84+
/// [tagPattern] is a string containing `'{{version}}'` as a substring, the
85+
/// latest tag matching the pattern will be used for fetching the name.
86+
///
87+
/// Only one of [ref] and [tagPattern] can be used.
88+
///
89+
/// If [isOffline], only the already cached versions of the repo is used.
90+
Future<String> getPackageNameFromGitRepo(
91+
String url, {
92+
String? ref,
93+
String? path,
94+
String? tagPattern,
95+
String? relativeTo,
96+
bool isOffline = false,
97+
}) async {
98+
return await GitSource.instance.getPackageNameFromRepo(
99+
url,
100+
ref,
101+
path,
102+
SystemCache(isOffline: isOffline),
103+
relativeTo: relativeTo,
104+
tagPattern: tagPattern,
105+
);
106+
}

lib/src/command/add.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ For example (follow the same format including spaces):
167167
defaultsTo: true,
168168
help:
169169
'Also update dependencies in `example/` after modifying pubspec.yaml in the root package (if it exists).',
170-
hide: true,
171170
);
172171
}
173172

lib/src/command/downgrade.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class DowngradeCommand extends PubCommand {
4848
'example',
4949
defaultsTo: true,
5050
help: 'Also run in `example/` (if it exists).',
51-
hide: true,
5251
);
5352

5453
argParser.addOption(

lib/src/command/get.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class GetCommand extends PubCommand {
5656
'example',
5757
defaultsTo: true,
5858
help: 'Also run in `example/` (if it exists).',
59-
hide: true,
6059
);
6160

6261
argParser.addOption(

lib/src/command/login.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ class LoginCommand extends PubCommand {
6464
try {
6565
switch (json.decode(userInfoRequest.body)) {
6666
case {'name': final String? name, 'email': final String email}:
67-
return _UserInfo(name, email);
67+
return _UserInfo(name: name, email: email);
68+
case {'email': final String email}:
69+
return _UserInfo(name: null, email: email);
6870
default:
6971
log.fine(
7072
'Bad response from $userInfoEndpoint: ${userInfoRequest.body}',
@@ -84,7 +86,7 @@ class LoginCommand extends PubCommand {
8486
class _UserInfo {
8587
final String? name;
8688
final String email;
87-
_UserInfo(this.name, this.email);
89+
_UserInfo({required this.name, required this.email});
8890
@override
8991
String toString() => ['<$email>', name ?? ''].join(' ');
9092
}

lib/src/command/remove.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ To remove a dependency override of a package prefix the package name with
5959
'example',
6060
defaultsTo: true,
6161
help: 'Also update dependencies in `example/` (if it exists).',
62-
hide: true,
6362
);
6463

6564
argParser.addOption(

lib/src/command/upgrade.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ class UpgradeCommand extends PubCommand {
8989
'example',
9090
defaultsTo: true,
9191
help: 'Also run in `example/` (if it exists).',
92-
hide: true,
9392
);
9493

9594
argParser.addOption(

lib/src/source/git.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class GitSource extends CachedSource {
290290
String? ref,
291291
String? path,
292292
SystemCache cache, {
293-
required String relativeTo,
293+
required String? relativeTo,
294294
required String? tagPattern,
295295
}) async {
296296
assert(

test/testdata/goldens/help_test/pub add --help.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Usage: pub add [options] [<section>:]<package>[:descriptor] [<section>:]<package
4343
-n, --dry-run Report what dependencies would change but don't change any.
4444
--[no-]precompile Build executables in immediate dependencies.
4545
-C, --directory=<dir> Run this in the directory <dir>.
46+
--[no-]example Also update dependencies in `example/` after modifying pubspec.yaml in the root package (if it exists).
47+
(defaults to on)
4648

4749
Run "pub help" to see global options.
4850
See https://dart.dev/tools/pub/cmd/pub-add for detailed documentation.

test/testdata/goldens/help_test/pub downgrade --help.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Usage: pub downgrade [dependencies...]
1010
-h, --help Print this usage information.
1111
--[no-]offline Use cached packages instead of accessing the network.
1212
-n, --dry-run Report what dependencies would change but don't change any.
13+
--[no-]example Also run in `example/` (if it exists).
14+
(defaults to on)
1315
-C, --directory=<dir> Run this in the directory <dir>.
1416
--tighten Updates lower bounds in pubspec.yaml to match the resolved version.
1517

0 commit comments

Comments
 (0)