Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plugins] Use reflikes for plugins #1845

Merged
merged 24 commits into from
Feb 29, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into landau/shift-plugins-to-config
  • Loading branch information
mikeland73 committed Feb 28, 2024
commit 8f7d32921b9580b5c07e7d158ced88acffb351dd
19 changes: 9 additions & 10 deletions nix/flake/flakeref.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func parseURLRef(ref string) (parsed Ref, fragment string, err error) {
// [flake:]<flake-id>(/<rev-or-ref>(/rev)?)?

parsed.Type = TypeIndirect
split, err := splitPathOrOpaque(refURL, false)
split, err := splitPathOrOpaque(refURL, -1)
if err != nil {
return Ref{}, "", redact.Errorf("parse flake reference URL path: %v", err)
}
Expand Down Expand Up @@ -206,7 +206,11 @@ func parseGitHubRef(refURL *url.URL, parsed *Ref) error {
// github:<owner>/<repo>(/<rev-or-ref>)?(\?<params>)?

parsed.Type = TypeGitHub
split, err := splitPathOrOpaque(refURL, true)

// Only split up to 3 times (owner, repo, ref/rev) so that we handle
// refs that have slashes in them. For example,
// "github:jetpack-io/devbox/gcurtis/flakeref" parses as "gcurtis/flakeref".
split, err := splitPathOrOpaque(refURL, 3)
if err != nil {
return err
}
Expand Down Expand Up @@ -381,7 +385,8 @@ func isArchive(path string) bool {
// the opaque instead. Splitting happens before unescaping the path or opaque,
// ensuring that path elements with an encoded '/' (%2F) are not split.
// For example, "/dir/file%2Fname" becomes the elements "dir" and "file/name".
func splitPathOrOpaque(u *url.URL, allowSlashesIfRef bool) ([]string, error) {
// The count limits the number of substrings per [strings.SplitN]
func splitPathOrOpaque(u *url.URL, n int) ([]string, error) {
upath := u.EscapedPath()
if upath == "" {
upath = u.Opaque
Expand All @@ -398,13 +403,7 @@ func splitPathOrOpaque(u *url.URL, allowSlashesIfRef bool) ([]string, error) {
upath = path.Clean(upath)

var err error
var split []string
if allowSlashesIfRef {
split = strings.SplitN(upath, "/", 3)
} else {
split = strings.Split(upath, "/")
}

split := strings.SplitN(upath, "/", n)
for i := range split {
split[i], err = url.PathUnescape(split[i])
if err != nil {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.