Skip to content

Commit

Permalink
fix: correctly handle archives with exec starting with ./ (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
femnad authored Jan 27, 2024
1 parent d5bcbdc commit 6aac9c3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

const (
version = "0.31.4"
version = "0.31.5"
)

type args struct {
Expand Down
9 changes: 7 additions & 2 deletions provision/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,21 @@ func getReleaseInfo(archive entity.Release, entries []archiveEntry) (info Releas
return info, fmt.Errorf("error determining root dir for %s", archive.Url)
}

prefix = strings.TrimPrefix(prefix, "./")
hasRootDir = strings.Index(prefix, "/") > -1
target = root
if root == "." {
target = prefix
} else {
target = root
}
} else if archive.Name() != "" {
target = archive.Name()
} else {
target = execs[0].name
}

if len(execs) == 1 {
execCandidate = execs[0].name
execCandidate = strings.TrimPrefix(execs[0].name, "./")
}

execCandidate, err = getExecCandidate(prefix, execCandidate)
Expand Down
16 changes: 16 additions & 0 deletions provision/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@ func Test_getReleaseInfo(t *testing.T) {
target: "qux",
},
},
{
name: "Exec has leading ./",
args: args{
entries: []archiveEntry{
{
info: mockExec("foo"),
name: "./foo",
},
},
},
want: ReleaseInfo{
execCandidate: "foo",
hasRootDir: false,
target: "foo",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 6aac9c3

Please sign in to comment.