@@ -219,25 +219,15 @@ func (lmi *Installer) InstallGitLib(argURL string, overwrite bool) error {
219219 if ref != "" {
220220 depth = 0
221221 }
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 {
228228 return err
229229 }
230230
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-
241231 // We don't want the installed library to be a git repository thus we delete this folder
242232 tmpInstallPath .Join (".git" ).RemoveAll ()
243233
@@ -251,7 +241,7 @@ func (lmi *Installer) InstallGitLib(argURL string, overwrite bool) error {
251241
252242// parseGitArgURL tries to recover a library name from a git URL.
253243// 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 ) {
255245 // On Windows handle paths with backslashes in the form C:\Path\to\library
256246 if path := paths .New (argURL ); path != nil && path .Exist () {
257247 return path .Base (), argURL , "" , nil
@@ -289,7 +279,7 @@ func parseGitArgURL(argURL string) (string, string, plumbing.Revision, error) {
289279 return "" , "" , "" , errors .New (i18n .Tr ("invalid git url" ))
290280 }
291281 // fragment == "1.0.3"
292- rev := plumbing .Revision (parsedURL .Fragment )
282+ rev := plumbing .ReferenceName (parsedURL .Fragment )
293283 // gitURL == "https://github.com/arduino-libraries/SigFox.git"
294284 parsedURL .Fragment = ""
295285 gitURL := parsedURL .String ()
0 commit comments