@@ -219,25 +219,15 @@ func (lmi *Installer) InstallGitLib(argURL string, overwrite bool) error {
219
219
if ref != "" {
220
220
depth = 0
221
221
}
222
- repo , err := git .PlainClone (tmpInstallPath .String (), false , & git.CloneOptions {
223
- URL : gitURL ,
224
- Depth : depth ,
225
- Progress : os .Stdout ,
226
- })
227
- if err != nil {
222
+ if _ , err := git .PlainClone (tmpInstallPath .String (), false , & git.CloneOptions {
223
+ URL : gitURL ,
224
+ Depth : depth ,
225
+ Progress : os .Stdout ,
226
+ ReferenceName : ref ,
227
+ }); err != nil {
228
228
return err
229
229
}
230
230
231
- if ref != "" {
232
- if h , err := repo .ResolveRevision (ref ); err != nil {
233
- return err
234
- } else if w , err := repo .Worktree (); err != nil {
235
- return err
236
- } else if err := w .Checkout (& git.CheckoutOptions {Hash : plumbing .NewHash (h .String ())}); err != nil {
237
- return err
238
- }
239
- }
240
-
241
231
// We don't want the installed library to be a git repository thus we delete this folder
242
232
tmpInstallPath .Join (".git" ).RemoveAll ()
243
233
@@ -251,7 +241,7 @@ func (lmi *Installer) InstallGitLib(argURL string, overwrite bool) error {
251
241
252
242
// parseGitArgURL tries to recover a library name from a git URL.
253
243
// Returns an error in case the URL is not a valid git URL.
254
- func parseGitArgURL (argURL string ) (string , string , plumbing.Revision , error ) {
244
+ func parseGitArgURL (argURL string ) (string , string , plumbing.ReferenceName , error ) {
255
245
// On Windows handle paths with backslashes in the form C:\Path\to\library
256
246
if path := paths .New (argURL ); path != nil && path .Exist () {
257
247
return path .Base (), argURL , "" , nil
@@ -289,7 +279,7 @@ func parseGitArgURL(argURL string) (string, string, plumbing.Revision, error) {
289
279
return "" , "" , "" , errors .New (i18n .Tr ("invalid git url" ))
290
280
}
291
281
// fragment == "1.0.3"
292
- rev := plumbing .Revision (parsedURL .Fragment )
282
+ rev := plumbing .ReferenceName (parsedURL .Fragment )
293
283
// gitURL == "https://github.com/arduino-libraries/SigFox.git"
294
284
parsedURL .Fragment = ""
295
285
gitURL := parsedURL .String ()
0 commit comments