@@ -21,6 +21,7 @@ import (
2121 "errors"
2222 "fmt"
2323 "net/url"
24+ "path/filepath"
2425 "regexp"
2526 "slices"
2627 "strings"
@@ -354,6 +355,7 @@ type ProfileLibraryReference struct {
354355 Version * semver.Version
355356 IsDependency bool
356357 InstallDir * paths.Path
358+ GitURL * url.URL
357359}
358360
359361// UnmarshalYAML decodes a ProfileLibraryReference from YAML source.
@@ -375,6 +377,19 @@ func (l *ProfileLibraryReference) UnmarshalYAML(unmarshal func(interface{}) erro
375377 }
376378 l .IsDependency = true
377379 // Fallback
380+ } else if gitUrl , ok := dataMap ["git" ]; ok {
381+ if gitUrlStr , ok := gitUrl .(string ); ! ok {
382+ return fmt .Errorf ("%s: %s" , i18n .Tr ("invalid library reference" ), dataMap )
383+ } else if parsedUrl , err := url .Parse (gitUrlStr ); err != nil {
384+ return fmt .Errorf ("%s: %w" , i18n .Tr ("invalid git URL" ), err )
385+ } else {
386+ l .GitURL = parsedUrl
387+ if l .Library = filepath .Base (parsedUrl .Path ); l .Library == "" {
388+ l .Library = "lib"
389+ }
390+ l .Library = strings .TrimSuffix (l .Library , ".git" )
391+ return nil
392+ }
378393 } else {
379394 return fmt .Errorf ("%s: %s" , i18n .Tr ("invalid library reference" ), dataMap )
380395 }
@@ -401,6 +416,9 @@ func (l *ProfileLibraryReference) AsYaml() string {
401416 if l .InstallDir != nil {
402417 return fmt .Sprintf (" - dir: %s\n " , l .InstallDir )
403418 }
419+ if l .GitURL != nil {
420+ return fmt .Sprintf (" - git: %s\n " , l .GitURL )
421+ }
404422 dep := ""
405423 if l .IsDependency {
406424 dep = "dependency: "
@@ -412,6 +430,9 @@ func (l *ProfileLibraryReference) String() string {
412430 if l .InstallDir != nil {
413431 return "@dir:" + l .InstallDir .String ()
414432 }
433+ if l .GitURL != nil {
434+ return "@git:" + l .GitURL .String ()
435+ }
415436 dep := ""
416437 if l .IsDependency {
417438 dep = " (dep)"
@@ -431,6 +452,14 @@ func (l *ProfileLibraryReference) Match(other *ProfileLibraryReference) bool {
431452 if other .InstallDir != nil {
432453 return false
433454 }
455+
456+ if l .GitURL != nil {
457+ return other .GitURL != nil && l .GitURL .String () == other .GitURL .String ()
458+ }
459+ if other .GitURL != nil {
460+ return false
461+ }
462+
434463 if l .Library != other .Library {
435464 return false
436465 }
@@ -494,6 +523,15 @@ func (l *ProfileLibraryReference) InternalUniqueIdentifier() string {
494523 f .Assert (l .InstallDir == nil ,
495524 "InternalUniqueIdentifier should not be called for library references with an install directory" )
496525
526+ if l .GitURL != nil {
527+ id := "git-" + utils .SanitizeName (l .GitURL .Host + l .GitURL .Path + "#" + l .GitURL .Fragment )
528+ if len (id ) > 50 {
529+ id = id [:50 ]
530+ }
531+ h := sha256 .Sum256 ([]byte (l .GitURL .String ()))
532+ return id + "-" + hex .EncodeToString (h [:])[:8 ]
533+ }
534+
497535 id := l .Library + "@" + l .Version .String ()
498536 h := sha256 .Sum256 ([]byte (id ))
499537 res := fmt .Sprintf ("%s_%s" , id , hex .EncodeToString (h [:])[:16 ])
0 commit comments