(ref flake.Ref)
| 38 | } |
| 39 | |
| 40 | func generateGitPluginName(ref flake.Ref) string { |
| 41 | // Extract repository name from URL and append directory if specified |
| 42 | url := ref.URL |
| 43 | if url == "" { |
| 44 | return "unknown.git" |
| 45 | } |
| 46 | |
| 47 | // Remove query parameters to get clean URL |
| 48 | if strings.Contains(url, "?") { |
| 49 | url = strings.Split(url, "?")[0] |
| 50 | } |
| 51 | |
| 52 | url = strings.TrimSuffix(url, ".git") |
| 53 | |
| 54 | parts := strings.Split(url, "/") |
| 55 | if len(parts) < 2 { |
| 56 | return "unknown.git" |
| 57 | } |
| 58 | |
| 59 | // Use last two path components (e.g., "owner/repo") |
| 60 | repoParts := parts[len(parts)-2:] |
| 61 | |
| 62 | name := strings.Join(repoParts, ".") |
| 63 | name = strings.ReplaceAll(name, "/", ".") |
| 64 | |
| 65 | // Append directory to make name unique when multiple plugins |
| 66 | // from same repo are used |
| 67 | if ref.Dir != "" { |
| 68 | dirName := strings.ReplaceAll(ref.Dir, "/", ".") |
| 69 | name = name + "." + dirName |
| 70 | } |
| 71 | |
| 72 | return name |
| 73 | } |
| 74 | |
| 75 | // getBaseURL extracts the base Git URL without query parameters. |
| 76 | // Query parameters like ?dir=path are used by Nix flakes but not by git clone. |
no outgoing calls