fix: honor redownload for explicit AUR targets
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
328f4b4939
commit
abdd8f6eac
2 files changed
+57
No files matched your search
@@ -246,6 +246,9 @@ func (preper *Preparer) needToCloneAURBase(installInfo *dep.InstallInfo, pkgbuil
|
||||
if preper.cfg.ReDownload == "all" {
|
||||
return true
|
||||
}
|
||||
if preper.cfg.ReDownload == "yes" && installInfo.Reason == dep.Explicit {
|
||||
return true
|
||||
}
|
||||
|
||||
srcinfoFile := filepath.Join(pkgbuildDir, ".SRCINFO")
|
||||
if pkgbuild, err := gosrc.ParseFile(srcinfoFile); err == nil {
|
||||
|
||||
@@ -4,11 +4,13 @@ package workdir
|
||||
|
||||
import (
|
||||
"io"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/Jguer/yay/v13/pkg/dep"
|
||||
"github.com/Jguer/yay/v13/pkg/settings"
|
||||
"github.com/Jguer/yay/v13/pkg/text"
|
||||
)
|
||||
@@ -69,3 +71,55 @@ func TestPreDownloadSourcesHooks(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNeedToCloneAURBaseRedownloadModes(t *testing.T) {
|
||||
pkgbuildDir := filepath.Join("..", "..", "..", "testdata", "gourou")
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
reDownload string
|
||||
reason dep.Reason
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "redownload target",
|
||||
reDownload: "yes",
|
||||
reason: dep.Explicit,
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "redownload dependency only when stale",
|
||||
reDownload: "yes",
|
||||
reason: dep.MakeDep,
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "redownload all",
|
||||
reDownload: "all",
|
||||
reason: dep.MakeDep,
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "normal download",
|
||||
reDownload: "no",
|
||||
reason: dep.MakeDep,
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
preper := NewPreparer(nil, nil, &settings.Configuration{
|
||||
ReDownload: tc.reDownload,
|
||||
}, newTestLogger())
|
||||
|
||||
got := preper.needToCloneAURBase(&dep.InstallInfo{
|
||||
AURBase: "gourou",
|
||||
Reason: tc.reason,
|
||||
Version: "0.8.1-4",
|
||||
}, pkgbuildDir)
|
||||
|
||||
assert.Equal(t, tc.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user