Skip to content

Commit

Permalink
pub add Rely on git sources validation of --git-url (#3951)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdm authored Aug 8, 2023
1 parent d764740 commit 996fdcf
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions lib/src/command/add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 996fdcf

Please sign in to comment.