diff --git a/lib/pub.dart b/lib/pub.dart index 12f364cb07..d7b5653e49 100644 --- a/lib/pub.dart +++ b/lib/pub.dart @@ -8,7 +8,6 @@ import 'src/entrypoint.dart'; import 'src/exceptions.dart'; import 'src/http.dart'; import 'src/pub_embeddable_command.dart'; -import 'src/source/git.dart'; import 'src/system_cache.dart'; export 'src/executable.dart' @@ -68,39 +67,3 @@ class ResolutionFailedException implements Exception { String message; ResolutionFailedException._(this.message); } - -/// Given a Git repo that contains a pub package, gets the name of the pub -/// package. -/// -/// Will download the repo to the system cache under the assumption that the -/// package will be downloaded afterwards. -/// -/// [url] points to the git repository. If it is a relative url, it is resolved -/// as a file url relative to the path [relativeTo]. -/// -/// [ref] is the commit, tag, or branch name where the package should be looked -/// up when fetching the name. If omitted, 'HEAD' is used. -/// -/// [tagPattern] is a string containing `'{{version}}'` as a substring, the -/// latest tag matching the pattern will be used for fetching the name. -/// -/// Only one of [ref] and [tagPattern] can be used. -/// -/// If [isOffline], only the already cached versions of the repo is used. -Future getPackageNameFromGitRepo( - String url, { - String? ref, - String? path, - String? tagPattern, - String? relativeTo, - bool isOffline = false, -}) async { - return await GitSource.instance.getPackageNameFromRepo( - url, - ref, - path, - SystemCache(isOffline: isOffline), - relativeTo: relativeTo, - tagPattern: tagPattern, - ); -} diff --git a/lib/src/command/add.dart b/lib/src/command/add.dart index 273c66f906..7c6c701dc3 100644 --- a/lib/src/command/add.dart +++ b/lib/src/command/add.dart @@ -167,6 +167,7 @@ For example (follow the same format including spaces): defaultsTo: true, help: 'Also update dependencies in `example/` after modifying pubspec.yaml in the root package (if it exists).', + hide: true, ); } diff --git a/lib/src/command/downgrade.dart b/lib/src/command/downgrade.dart index d9991381d8..1bdd09230a 100644 --- a/lib/src/command/downgrade.dart +++ b/lib/src/command/downgrade.dart @@ -48,6 +48,7 @@ class DowngradeCommand extends PubCommand { 'example', defaultsTo: true, help: 'Also run in `example/` (if it exists).', + hide: true, ); argParser.addOption( diff --git a/lib/src/command/get.dart b/lib/src/command/get.dart index dd3bbdc15b..4e522c05e7 100644 --- a/lib/src/command/get.dart +++ b/lib/src/command/get.dart @@ -56,6 +56,7 @@ class GetCommand extends PubCommand { 'example', defaultsTo: true, help: 'Also run in `example/` (if it exists).', + hide: true, ); argParser.addOption( diff --git a/lib/src/command/login.dart b/lib/src/command/login.dart index 0a505b660b..04e765b7dc 100644 --- a/lib/src/command/login.dart +++ b/lib/src/command/login.dart @@ -64,9 +64,7 @@ class LoginCommand extends PubCommand { try { switch (json.decode(userInfoRequest.body)) { case {'name': final String? name, 'email': final String email}: - return _UserInfo(name: name, email: email); - case {'email': final String email}: - return _UserInfo(name: null, email: email); + return _UserInfo(name, email); default: log.fine( 'Bad response from $userInfoEndpoint: ${userInfoRequest.body}', @@ -86,7 +84,7 @@ class LoginCommand extends PubCommand { class _UserInfo { final String? name; final String email; - _UserInfo({required this.name, required this.email}); + _UserInfo(this.name, this.email); @override String toString() => ['<$email>', name ?? ''].join(' '); } diff --git a/lib/src/command/remove.dart b/lib/src/command/remove.dart index 7f4ac2af0e..32e75906b3 100644 --- a/lib/src/command/remove.dart +++ b/lib/src/command/remove.dart @@ -59,6 +59,7 @@ To remove a dependency override of a package prefix the package name with 'example', defaultsTo: true, help: 'Also update dependencies in `example/` (if it exists).', + hide: true, ); argParser.addOption( diff --git a/lib/src/command/upgrade.dart b/lib/src/command/upgrade.dart index 44365e870a..a817ff41e0 100644 --- a/lib/src/command/upgrade.dart +++ b/lib/src/command/upgrade.dart @@ -89,6 +89,7 @@ class UpgradeCommand extends PubCommand { 'example', defaultsTo: true, help: 'Also run in `example/` (if it exists).', + hide: true, ); argParser.addOption( diff --git a/lib/src/source/git.dart b/lib/src/source/git.dart index 9087944659..7f03059274 100644 --- a/lib/src/source/git.dart +++ b/lib/src/source/git.dart @@ -290,7 +290,7 @@ class GitSource extends CachedSource { String? ref, String? path, SystemCache cache, { - required String? relativeTo, + required String relativeTo, required String? tagPattern, }) async { assert( diff --git a/test/testdata/goldens/help_test/pub add --help.txt b/test/testdata/goldens/help_test/pub add --help.txt index 4aca35f98c..f6f73fb96e 100644 --- a/test/testdata/goldens/help_test/pub add --help.txt +++ b/test/testdata/goldens/help_test/pub add --help.txt @@ -43,8 +43,6 @@ Usage: pub add [options] [
:][:descriptor] [
:] Run this in the directory . - --[no-]example Also update dependencies in `example/` after modifying pubspec.yaml in the root package (if it exists). - (defaults to on) Run "pub help" to see global options. See https://dart.dev/tools/pub/cmd/pub-add for detailed documentation. diff --git a/test/testdata/goldens/help_test/pub downgrade --help.txt b/test/testdata/goldens/help_test/pub downgrade --help.txt index 0b86d3ed4d..a97139569a 100644 --- a/test/testdata/goldens/help_test/pub downgrade --help.txt +++ b/test/testdata/goldens/help_test/pub downgrade --help.txt @@ -10,8 +10,6 @@ Usage: pub downgrade [dependencies...] -h, --help Print this usage information. --[no-]offline Use cached packages instead of accessing the network. -n, --dry-run Report what dependencies would change but don't change any. - --[no-]example Also run in `example/` (if it exists). - (defaults to on) -C, --directory= Run this in the directory . --tighten Updates lower bounds in pubspec.yaml to match the resolved version. diff --git a/test/testdata/goldens/help_test/pub get --help.txt b/test/testdata/goldens/help_test/pub get --help.txt index 3c68ab101d..dd5aaf5045 100644 --- a/test/testdata/goldens/help_test/pub get --help.txt +++ b/test/testdata/goldens/help_test/pub get --help.txt @@ -12,8 +12,6 @@ Usage: pub get has changed. Useful for CI or deploying to production. --[no-]precompile Build executables in immediate dependencies. - --[no-]example Also run in `example/` (if it exists). - (defaults to on) -C, --directory= Run this in the directory . Run "pub help" to see global options. diff --git a/test/testdata/goldens/help_test/pub remove --help.txt b/test/testdata/goldens/help_test/pub remove --help.txt index 34e1463fcf..2032abfa18 100644 --- a/test/testdata/goldens/help_test/pub remove --help.txt +++ b/test/testdata/goldens/help_test/pub remove --help.txt @@ -16,8 +16,6 @@ Usage: pub remove [...] --[no-]offline Use cached packages instead of accessing the network. -n, --dry-run Report what dependencies would change but don't change any. --[no-]precompile Precompile executables in immediate dependencies. - --[no-]example Also update dependencies in `example/` (if it exists). - (defaults to on) -C, --directory= Run this in the directory . Run "pub help" to see global options. diff --git a/test/testdata/goldens/help_test/pub upgrade --help.txt b/test/testdata/goldens/help_test/pub upgrade --help.txt index 90030c7ca6..ade5a8dc4e 100644 --- a/test/testdata/goldens/help_test/pub upgrade --help.txt +++ b/test/testdata/goldens/help_test/pub upgrade --help.txt @@ -12,8 +12,6 @@ Usage: pub upgrade [dependencies...] --tighten Updates lower bounds in pubspec.yaml to match the resolved version. --unlock-transitive Also upgrades the transitive dependencies of the listed [dependencies] --major-versions Upgrades packages to their latest resolvable versions, and updates pubspec.yaml. - --[no-]example Also run in `example/` (if it exists). - (defaults to on) -C, --directory= Run this in the directory . Run "pub help" to see global options.