From 996fdcfd3480e02da5f4c04a934255cba59f98f5 Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Tue, 8 Aug 2023 11:22:17 +0200 Subject: [PATCH] `pub add` Rely on git sources validation of --git-url (#3951) --- lib/src/command/add.dart | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/src/command/add.dart b/lib/src/command/add.dart index 6ee94b731..e436b2c01 100644 --- a/lib/src/command/add.dart +++ b/lib/src/command/add.dart @@ -522,25 +522,22 @@ Specify multiple sdk packages with descriptors.'''); if (gitUrl == null) { usageException('The `--git-url` is required for git dependencies.'); } - Uri parsed; + + /// Process the git options to return the simplest representation to be + /// added to the pubspec. try { - parsed = Uri.parse(gitUrl); + ref = PackageRef( + packageName, + GitDescription( + url: gitUrl.toString(), + containingDir: p.current, + ref: argResults.gitRef, + path: argResults.gitPath, + ), + ); } on FormatException catch (e) { usageException('The --git-url must be a valid url: ${e.message}.'); } - - /// Process the git options to return the simplest representation to be - /// added to the pubspec. - - ref = PackageRef( - packageName, - GitDescription( - url: parsed.toString(), - containingDir: p.current, - ref: argResults.gitRef, - path: argResults.gitPath, - ), - ); } else if (path != null) { ref = PackageRef( packageName,