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

Allow same globs in multiple slices #62

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions internal/deb/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ func checkExtractOptions(options *ExtractOptions) error {
for extractPath, extractInfos := range options.Extract {
isGlob := strings.ContainsAny(extractPath, "*?")
if isGlob {
if len(extractInfos) != 1 || extractInfos[0].Path != extractPath || extractInfos[0].Mode != 0 {
return fmt.Errorf("when using wildcards source and target paths must match: %s", extractPath)
for _, info := range extractInfos {
if info.Path != extractPath || info.Mode != 0 {
return fmt.Errorf("when using wildcards source and target paths must match: %s", extractPath)
}
}
}
}
Expand Down
22 changes: 20 additions & 2 deletions internal/deb/extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ var extractTests = []extractTest{{
},
error: `cannot extract .*: when using wildcards source and target paths must match: /etc/d\*\*`,
}, {
summary: "Globbing must also have a single target",
summary: "Two slices can declare the same glob",
pkgdata: testutil.PackageData["base-files"],
options: deb.ExtractOptions{
Extract: map[string][]deb.ExtractInfo{
Expand All @@ -181,7 +181,25 @@ var extractTests = []extractTest{{
}},
},
},
error: `cannot extract .*: when using wildcards source and target paths must match: /etc/d\*\*`,
result: map[string]string{
"/etc/": "dir 0755",
"/etc/debian_version": "file 0644 cce26cfe",
"/etc/default/": "dir 0755",
"/etc/dpkg/": "dir 0755",
"/etc/dpkg/origins/": "dir 0755",
"/etc/dpkg/origins/debian": "file 0644 50f35af8",
"/etc/dpkg/origins/ubuntu": "file 0644 d2537b95",
},
globbed: map[string][]string{
"/etc/d**": []string{
"/etc/debian_version",
"/etc/default/",
"/etc/dpkg/",
"/etc/dpkg/origins/",
"/etc/dpkg/origins/debian",
"/etc/dpkg/origins/ubuntu",
},
},
}, {
summary: "Globbing cannot change modes",
pkgdata: testutil.PackageData["base-files"],
Expand Down