mirror of
https://github.com/Jguer/yay.git
synced 2025-10-15 00:02:26 -04:00
fix(getpkgbuild): check AUR pkgs exist before GetPKGBUILD (#1921)
check AUR pkgs exist before GetPKGBUILD
This commit is contained in:
parent
7490836991
commit
fad26c078d
6
cmd.go
6
cmd.go
@ -323,10 +323,12 @@ func handleWeb(ctx context.Context, cmdArgs *parser.Arguments) error {
|
|||||||
|
|
||||||
func handleGetpkgbuild(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor download.DBSearcher) error {
|
func handleGetpkgbuild(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor download.DBSearcher) error {
|
||||||
if cmdArgs.ExistsArg("p", "print") {
|
if cmdArgs.ExistsArg("p", "print") {
|
||||||
return printPkgbuilds(dbExecutor, config.Runtime.HTTPClient, cmdArgs.Targets, config.Runtime.Mode, config.AURURL)
|
return printPkgbuilds(dbExecutor, config.Runtime.AURCache,
|
||||||
|
config.Runtime.HTTPClient, cmdArgs.Targets, config.Runtime.Mode, config.AURURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
return getPkgbuilds(ctx, dbExecutor, config, cmdArgs.Targets, cmdArgs.ExistsArg("f", "force"))
|
return getPkgbuilds(ctx, dbExecutor, config.Runtime.AURCache, config,
|
||||||
|
cmdArgs.Targets, cmdArgs.ExistsArg("f", "force"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleUpgrade(ctx context.Context,
|
func handleUpgrade(ctx context.Context,
|
||||||
|
13
get.go
13
get.go
@ -7,6 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/Jguer/aur"
|
||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
|
|
||||||
"github.com/Jguer/yay/v11/pkg/download"
|
"github.com/Jguer/yay/v11/pkg/download"
|
||||||
@ -16,10 +17,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// yay -Gp.
|
// yay -Gp.
|
||||||
func printPkgbuilds(dbExecutor download.DBSearcher, httpClient *http.Client, targets []string,
|
func printPkgbuilds(dbExecutor download.DBSearcher, aurClient aur.QueryClient, httpClient *http.Client, targets []string,
|
||||||
mode parser.TargetMode, aurURL string,
|
mode parser.TargetMode, aurURL string,
|
||||||
) error {
|
) error {
|
||||||
pkgbuilds, err := download.PKGBUILDs(dbExecutor, httpClient, targets, aurURL, mode)
|
pkgbuilds, err := download.PKGBUILDs(dbExecutor, aurClient, httpClient, targets, aurURL, mode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
text.Errorln(err)
|
text.Errorln(err)
|
||||||
}
|
}
|
||||||
@ -40,7 +41,7 @@ func printPkgbuilds(dbExecutor download.DBSearcher, httpClient *http.Client, tar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
text.Warnln(gotext.Get("Unable to find the following packages:"), strings.Join(missing, ", "))
|
text.Warnln(gotext.Get("Unable to find the following packages:"), " ", strings.Join(missing, ", "))
|
||||||
|
|
||||||
return fmt.Errorf("")
|
return fmt.Errorf("")
|
||||||
}
|
}
|
||||||
@ -49,7 +50,7 @@ func printPkgbuilds(dbExecutor download.DBSearcher, httpClient *http.Client, tar
|
|||||||
}
|
}
|
||||||
|
|
||||||
// yay -G.
|
// yay -G.
|
||||||
func getPkgbuilds(ctx context.Context, dbExecutor download.DBSearcher,
|
func getPkgbuilds(ctx context.Context, dbExecutor download.DBSearcher, aurClient aur.QueryClient,
|
||||||
config *settings.Configuration, targets []string, force bool,
|
config *settings.Configuration, targets []string, force bool,
|
||||||
) error {
|
) error {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
@ -57,7 +58,7 @@ func getPkgbuilds(ctx context.Context, dbExecutor download.DBSearcher,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cloned, errD := download.PKGBUILDRepos(ctx, dbExecutor,
|
cloned, errD := download.PKGBUILDRepos(ctx, dbExecutor, aurClient,
|
||||||
config.Runtime.CmdBuilder, targets, config.Runtime.Mode, config.AURURL, wd, force)
|
config.Runtime.CmdBuilder, targets, config.Runtime.Mode, config.AURURL, wd, force)
|
||||||
if errD != nil {
|
if errD != nil {
|
||||||
text.Errorln(errD)
|
text.Errorln(errD)
|
||||||
@ -72,7 +73,7 @@ func getPkgbuilds(ctx context.Context, dbExecutor download.DBSearcher,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
text.Warnln(gotext.Get("Unable to find the following packages:"), strings.Join(missing, ", "))
|
text.Warnln(gotext.Get("Unable to find the following packages:"), " ", strings.Join(missing, ", "))
|
||||||
|
|
||||||
err = fmt.Errorf("")
|
err = fmt.Errorf("")
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ import (
|
|||||||
|
|
||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
|
|
||||||
|
"github.com/Jguer/aur"
|
||||||
|
|
||||||
"github.com/Jguer/yay/v11/pkg/db"
|
"github.com/Jguer/yay/v11/pkg/db"
|
||||||
"github.com/Jguer/yay/v11/pkg/multierror"
|
"github.com/Jguer/yay/v11/pkg/multierror"
|
||||||
"github.com/Jguer/yay/v11/pkg/settings/exe"
|
"github.com/Jguer/yay/v11/pkg/settings/exe"
|
||||||
@ -79,7 +81,7 @@ func getURLName(pkg db.IPackage) string {
|
|||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
func PKGBUILDs(dbExecutor DBSearcher, httpClient *http.Client, targets []string,
|
func PKGBUILDs(dbExecutor DBSearcher, aurClient aur.QueryClient, httpClient *http.Client, targets []string,
|
||||||
aurURL string, mode parser.TargetMode,
|
aurURL string, mode parser.TargetMode,
|
||||||
) (map[string][]byte, error) {
|
) (map[string][]byte, error) {
|
||||||
pkgbuilds := make(map[string][]byte, len(targets))
|
pkgbuilds := make(map[string][]byte, len(targets))
|
||||||
@ -94,7 +96,7 @@ func PKGBUILDs(dbExecutor DBSearcher, httpClient *http.Client, targets []string,
|
|||||||
|
|
||||||
for _, target := range targets {
|
for _, target := range targets {
|
||||||
// Probably replaceable by something in query.
|
// Probably replaceable by something in query.
|
||||||
dbName, name, aur, toSkip := getPackageUsableName(dbExecutor, target, mode)
|
dbName, name, isAUR, toSkip := getPackageUsableName(dbExecutor, aurClient, target, mode)
|
||||||
if toSkip {
|
if toSkip {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -125,7 +127,7 @@ func PKGBUILDs(dbExecutor DBSearcher, httpClient *http.Client, targets []string,
|
|||||||
|
|
||||||
<-sem
|
<-sem
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}(target, dbName, name, aur)
|
}(target, dbName, name, isAUR)
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
@ -133,7 +135,7 @@ func PKGBUILDs(dbExecutor DBSearcher, httpClient *http.Client, targets []string,
|
|||||||
return pkgbuilds, errs.Return()
|
return pkgbuilds, errs.Return()
|
||||||
}
|
}
|
||||||
|
|
||||||
func PKGBUILDRepos(ctx context.Context, dbExecutor DBSearcher,
|
func PKGBUILDRepos(ctx context.Context, dbExecutor DBSearcher, aurClient aur.QueryClient,
|
||||||
cmdBuilder exe.GitCmdBuilder,
|
cmdBuilder exe.GitCmdBuilder,
|
||||||
targets []string, mode parser.TargetMode, aurURL, dest string, force bool,
|
targets []string, mode parser.TargetMode, aurURL, dest string, force bool,
|
||||||
) (map[string]bool, error) {
|
) (map[string]bool, error) {
|
||||||
@ -149,7 +151,7 @@ func PKGBUILDRepos(ctx context.Context, dbExecutor DBSearcher,
|
|||||||
|
|
||||||
for _, target := range targets {
|
for _, target := range targets {
|
||||||
// Probably replaceable by something in query.
|
// Probably replaceable by something in query.
|
||||||
dbName, name, aur, toSkip := getPackageUsableName(dbExecutor, target, mode)
|
dbName, name, isAUR, toSkip := getPackageUsableName(dbExecutor, aurClient, target, mode)
|
||||||
if toSkip {
|
if toSkip {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -194,7 +196,7 @@ func PKGBUILDRepos(ctx context.Context, dbExecutor DBSearcher,
|
|||||||
<-sem
|
<-sem
|
||||||
|
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}(target, dbName, name, aur)
|
}(target, dbName, name, isAUR)
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
@ -203,34 +205,47 @@ func PKGBUILDRepos(ctx context.Context, dbExecutor DBSearcher,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: replace with dep.ResolveTargets.
|
// TODO: replace with dep.ResolveTargets.
|
||||||
func getPackageUsableName(dbExecutor DBSearcher, target string, mode parser.TargetMode) (dbname, pkgname string, aur, toSkip bool) {
|
func getPackageUsableName(dbExecutor DBSearcher, aurClient aur.QueryClient,
|
||||||
aur = true
|
target string, mode parser.TargetMode,
|
||||||
|
) (dbname, pkgname string, isAUR, toSkip bool) {
|
||||||
dbName, name := text.SplitDBFromName(target)
|
dbName, name := text.SplitDBFromName(target)
|
||||||
if dbName != "aur" && mode.AtLeastRepo() {
|
if dbName != "aur" && mode.AtLeastRepo() {
|
||||||
var pkg db.IPackage
|
var pkg db.IPackage
|
||||||
if dbName != "" {
|
if dbName != "" {
|
||||||
pkg = dbExecutor.SatisfierFromDB(name, dbName)
|
pkg = dbExecutor.SatisfierFromDB(name, dbName)
|
||||||
if pkg == nil {
|
|
||||||
// if the user precised a db but the package is not in the db
|
|
||||||
// then it is missing
|
|
||||||
// Mode does not allow AUR packages
|
|
||||||
return dbName, name, aur, true
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
pkg = dbExecutor.SyncPackage(name)
|
pkg = dbExecutor.SyncPackage(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if pkg != nil {
|
if pkg != nil {
|
||||||
aur = false
|
|
||||||
name = getURLName(pkg)
|
name = getURLName(pkg)
|
||||||
dbName = pkg.DB().Name()
|
dbName = pkg.DB().Name()
|
||||||
|
return dbName, name, false, false
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the package is not found in the database and it was expected to be
|
||||||
|
if pkg == nil && dbName != "" {
|
||||||
|
return dbName, name, true, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if aur && mode == parser.ModeRepo {
|
if mode == parser.ModeRepo {
|
||||||
return dbName, name, aur, true
|
return dbName, name, true, true
|
||||||
}
|
}
|
||||||
|
|
||||||
return dbName, name, aur, false
|
pkgs, err := aurClient.Get(context.Background(), &aur.Query{
|
||||||
|
By: aur.Name,
|
||||||
|
Contains: false,
|
||||||
|
Needles: []string{name},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
text.Warnln(err)
|
||||||
|
return dbName, name, true, true
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(pkgs) == 0 {
|
||||||
|
return dbName, name, true, true
|
||||||
|
}
|
||||||
|
|
||||||
|
return "aur", name, true, false
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,9 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"gopkg.in/h2non/gock.v1"
|
"gopkg.in/h2non/gock.v1"
|
||||||
|
|
||||||
|
"github.com/Jguer/aur"
|
||||||
|
|
||||||
|
mockaur "github.com/Jguer/yay/v11/pkg/dep/mock"
|
||||||
"github.com/Jguer/yay/v11/pkg/settings/exe"
|
"github.com/Jguer/yay/v11/pkg/settings/exe"
|
||||||
"github.com/Jguer/yay/v11/pkg/settings/parser"
|
"github.com/Jguer/yay/v11/pkg/settings/parser"
|
||||||
)
|
)
|
||||||
@ -22,6 +25,12 @@ func TestPKGBUILDReposDefinedDBPull(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
|
|
||||||
|
mockClient := &mockaur.MockAUR{
|
||||||
|
GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
|
||||||
|
return []aur.Pkg{{}}, nil // fakes a package found for all
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
os.MkdirAll(filepath.Join(dir, "yay", ".git"), 0o777)
|
os.MkdirAll(filepath.Join(dir, "yay", ".git"), 0o777)
|
||||||
|
|
||||||
targets := []string{"core/yay", "yay-bin", "yay-git"}
|
targets := []string{"core/yay", "yay-bin", "yay-git"}
|
||||||
@ -38,7 +47,7 @@ func TestPKGBUILDReposDefinedDBPull(t *testing.T) {
|
|||||||
searcher := &testDBSearcher{
|
searcher := &testDBSearcher{
|
||||||
absPackagesDB: map[string]string{"yay": "core"},
|
absPackagesDB: map[string]string{"yay": "core"},
|
||||||
}
|
}
|
||||||
cloned, err := PKGBUILDRepos(context.Background(), searcher,
|
cloned, err := PKGBUILDRepos(context.Background(), searcher, mockClient,
|
||||||
cmdBuilder,
|
cmdBuilder,
|
||||||
targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
|
targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
|
||||||
|
|
||||||
@ -53,6 +62,11 @@ func TestPKGBUILDReposDefinedDBClone(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
|
|
||||||
|
mockClient := &mockaur.MockAUR{
|
||||||
|
GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
|
||||||
|
return []aur.Pkg{{}}, nil // fakes a package found for all
|
||||||
|
},
|
||||||
|
}
|
||||||
targets := []string{"core/yay", "yay-bin", "yay-git"}
|
targets := []string{"core/yay", "yay-bin", "yay-git"}
|
||||||
cmdRunner := &testRunner{}
|
cmdRunner := &testRunner{}
|
||||||
cmdBuilder := &testGitBuilder{
|
cmdBuilder := &testGitBuilder{
|
||||||
@ -67,7 +81,7 @@ func TestPKGBUILDReposDefinedDBClone(t *testing.T) {
|
|||||||
searcher := &testDBSearcher{
|
searcher := &testDBSearcher{
|
||||||
absPackagesDB: map[string]string{"yay": "core"},
|
absPackagesDB: map[string]string{"yay": "core"},
|
||||||
}
|
}
|
||||||
cloned, err := PKGBUILDRepos(context.Background(), searcher,
|
cloned, err := PKGBUILDRepos(context.Background(), searcher, mockClient,
|
||||||
cmdBuilder,
|
cmdBuilder,
|
||||||
targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
|
targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
|
||||||
|
|
||||||
@ -82,6 +96,11 @@ func TestPKGBUILDReposClone(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
|
|
||||||
|
mockClient := &mockaur.MockAUR{
|
||||||
|
GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
|
||||||
|
return []aur.Pkg{{}}, nil // fakes a package found for all
|
||||||
|
},
|
||||||
|
}
|
||||||
targets := []string{"yay", "yay-bin", "yay-git"}
|
targets := []string{"yay", "yay-bin", "yay-git"}
|
||||||
cmdRunner := &testRunner{}
|
cmdRunner := &testRunner{}
|
||||||
cmdBuilder := &testGitBuilder{
|
cmdBuilder := &testGitBuilder{
|
||||||
@ -96,7 +115,7 @@ func TestPKGBUILDReposClone(t *testing.T) {
|
|||||||
searcher := &testDBSearcher{
|
searcher := &testDBSearcher{
|
||||||
absPackagesDB: map[string]string{"yay": "core"},
|
absPackagesDB: map[string]string{"yay": "core"},
|
||||||
}
|
}
|
||||||
cloned, err := PKGBUILDRepos(context.Background(), searcher,
|
cloned, err := PKGBUILDRepos(context.Background(), searcher, mockClient,
|
||||||
cmdBuilder,
|
cmdBuilder,
|
||||||
targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
|
targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
|
||||||
|
|
||||||
@ -111,6 +130,11 @@ func TestPKGBUILDReposNotFound(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
|
|
||||||
|
mockClient := &mockaur.MockAUR{
|
||||||
|
GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
|
||||||
|
return []aur.Pkg{{}}, nil // fakes a package found for all
|
||||||
|
},
|
||||||
|
}
|
||||||
targets := []string{"extra/yay", "yay-bin", "yay-git"}
|
targets := []string{"extra/yay", "yay-bin", "yay-git"}
|
||||||
cmdRunner := &testRunner{}
|
cmdRunner := &testRunner{}
|
||||||
cmdBuilder := &testGitBuilder{
|
cmdBuilder := &testGitBuilder{
|
||||||
@ -125,7 +149,7 @@ func TestPKGBUILDReposNotFound(t *testing.T) {
|
|||||||
searcher := &testDBSearcher{
|
searcher := &testDBSearcher{
|
||||||
absPackagesDB: map[string]string{"yay": "core"},
|
absPackagesDB: map[string]string{"yay": "core"},
|
||||||
}
|
}
|
||||||
cloned, err := PKGBUILDRepos(context.Background(), searcher,
|
cloned, err := PKGBUILDRepos(context.Background(), searcher, mockClient,
|
||||||
cmdBuilder,
|
cmdBuilder,
|
||||||
targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
|
targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
|
||||||
|
|
||||||
@ -140,6 +164,11 @@ func TestPKGBUILDReposRepoMode(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
|
|
||||||
|
mockClient := &mockaur.MockAUR{
|
||||||
|
GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
|
||||||
|
return []aur.Pkg{}, nil // fakes a package found for all
|
||||||
|
},
|
||||||
|
}
|
||||||
targets := []string{"yay", "yay-bin", "yay-git"}
|
targets := []string{"yay", "yay-bin", "yay-git"}
|
||||||
cmdRunner := &testRunner{}
|
cmdRunner := &testRunner{}
|
||||||
cmdBuilder := &testGitBuilder{
|
cmdBuilder := &testGitBuilder{
|
||||||
@ -154,7 +183,7 @@ func TestPKGBUILDReposRepoMode(t *testing.T) {
|
|||||||
searcher := &testDBSearcher{
|
searcher := &testDBSearcher{
|
||||||
absPackagesDB: map[string]string{"yay": "core"},
|
absPackagesDB: map[string]string{"yay": "core"},
|
||||||
}
|
}
|
||||||
cloned, err := PKGBUILDRepos(context.Background(), searcher,
|
cloned, err := PKGBUILDRepos(context.Background(), searcher, mockClient,
|
||||||
cmdBuilder,
|
cmdBuilder,
|
||||||
targets, parser.ModeRepo, "https://aur.archlinux.org", dir, false)
|
targets, parser.ModeRepo, "https://aur.archlinux.org", dir, false)
|
||||||
|
|
||||||
@ -168,6 +197,11 @@ func TestPKGBUILDReposRepoMode(t *testing.T) {
|
|||||||
func TestPKGBUILDFull(t *testing.T) {
|
func TestPKGBUILDFull(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
mockClient := &mockaur.MockAUR{
|
||||||
|
GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
|
||||||
|
return []aur.Pkg{{}}, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
gock.New("https://aur.archlinux.org").
|
gock.New("https://aur.archlinux.org").
|
||||||
Get("/cgit/aur.git/plain/PKGBUILD").MatchParam("h", "yay-git").
|
Get("/cgit/aur.git/plain/PKGBUILD").MatchParam("h", "yay-git").
|
||||||
Reply(200).
|
Reply(200).
|
||||||
@ -188,7 +222,7 @@ func TestPKGBUILDFull(t *testing.T) {
|
|||||||
absPackagesDB: map[string]string{"yay": "core"},
|
absPackagesDB: map[string]string{"yay": "core"},
|
||||||
}
|
}
|
||||||
|
|
||||||
fetched, err := PKGBUILDs(searcher, &http.Client{},
|
fetched, err := PKGBUILDs(searcher, mockClient, &http.Client{},
|
||||||
targets, "https://aur.archlinux.org", parser.ModeAny)
|
targets, "https://aur.archlinux.org", parser.ModeAny)
|
||||||
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@ -198,3 +232,37 @@ func TestPKGBUILDFull(t *testing.T) {
|
|||||||
"yay-git": []byte("example_yay-git"),
|
"yay-git": []byte("example_yay-git"),
|
||||||
}, fetched)
|
}, fetched)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GIVEN 2 aur packages and 1 in repo
|
||||||
|
// WHEN aur packages are not found
|
||||||
|
// only repo should be cloned
|
||||||
|
func TestPKGBUILDReposMissingAUR(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
dir := t.TempDir()
|
||||||
|
|
||||||
|
mockClient := &mockaur.MockAUR{
|
||||||
|
GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
|
||||||
|
return []aur.Pkg{}, nil // fakes a package found for all
|
||||||
|
},
|
||||||
|
}
|
||||||
|
targets := []string{"core/yay", "aur/yay-bin", "aur/yay-git"}
|
||||||
|
cmdRunner := &testRunner{}
|
||||||
|
cmdBuilder := &testGitBuilder{
|
||||||
|
index: 0,
|
||||||
|
test: t,
|
||||||
|
parentBuilder: &exe.CmdBuilder{
|
||||||
|
Runner: cmdRunner,
|
||||||
|
GitBin: "/usr/local/bin/git",
|
||||||
|
GitFlags: []string{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
searcher := &testDBSearcher{
|
||||||
|
absPackagesDB: map[string]string{"yay": "core"},
|
||||||
|
}
|
||||||
|
cloned, err := PKGBUILDRepos(context.Background(), searcher, mockClient,
|
||||||
|
cmdBuilder,
|
||||||
|
targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.EqualValues(t, map[string]bool{"core/yay": true}, cloned)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user