@@ -8,6 +8,7 @@ import 'src/entrypoint.dart';
88import 'src/exceptions.dart' ;
99import 'src/http.dart' ;
1010import 'src/pub_embeddable_command.dart' ;
11+ import 'src/source/git.dart' ;
1112import 'src/system_cache.dart' ;
1213
1314export '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+ }
0 commit comments