mirror of
https://github.com/Jguer/yay
synced 2024-08-31 05:39:29 +00:00
chore(download): rename public functions
This commit is contained in:
parent
79b44fd544
commit
413ad23abc
|
@ -53,8 +53,8 @@ func getPackageRepoURL(db string) (string, error) {
|
|||
return repoURL + ".git", err
|
||||
}
|
||||
|
||||
// GetABSPkgbuild retrieves the PKGBUILD file to a dest directory
|
||||
func GetABSPkgbuild(httpClient *http.Client, dbName, pkgName string) ([]byte, error) {
|
||||
// ABSPKGBUILD retrieves the PKGBUILD file to a dest directory.
|
||||
func ABSPKGBUILD(httpClient *http.Client, dbName, pkgName string) ([]byte, error) {
|
||||
packageURL, err := getPackageURL(dbName, pkgName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -79,8 +79,8 @@ func GetABSPkgbuild(httpClient *http.Client, dbName, pkgName string) ([]byte, er
|
|||
return pkgBuild, nil
|
||||
}
|
||||
|
||||
// ABSPkgbuildRepo retrieves the PKGBUILD repository to a dest directory
|
||||
func ABSPkgbuildRepo(cmdRunner exe.Runner, cmdBuilder exe.GitCmdBuilder, dbName, pkgName, dest string, force bool) error {
|
||||
// ABSPKGBUILDRepo retrieves the PKGBUILD repository to a dest directory
|
||||
func ABSPKGBUILDRepo(cmdRunner exe.Runner, cmdBuilder exe.GitCmdBuilder, dbName, pkgName, dest string, force bool) error {
|
||||
pkgURL, err := getPackageRepoURL(dbName)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -126,7 +126,7 @@ func TestGetABSPkgbuild(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
ABSPackageURL = PKGBuild.URL
|
||||
PKGBuild.Config.Handler = tt.args.handler
|
||||
got, err := GetABSPkgbuild(PKGBuild.Client(), tt.args.dbName, tt.args.pkgName)
|
||||
got, err := ABSPKGBUILD(PKGBuild.Client(), tt.args.dbName, tt.args.pkgName)
|
||||
if tt.wantErr {
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
var AURPackageURL = "https://aur.archlinux.org/cgit/aur.git"
|
||||
|
||||
func GetAURPkgbuild(httpClient *http.Client, pkgName string) ([]byte, error) {
|
||||
func AURPKGBUILD(httpClient *http.Client, pkgName string) ([]byte, error) {
|
||||
values := url.Values{}
|
||||
values.Set("h", pkgName)
|
||||
pkgURL := AURPackageURL + "/plain/PKGBUILD?" + values.Encode()
|
||||
|
@ -36,7 +36,7 @@ func GetAURPkgbuild(httpClient *http.Client, pkgName string) ([]byte, error) {
|
|||
}
|
||||
|
||||
// AURPkgbuildRepo retrieves the PKGBUILD repository to a dest directory.
|
||||
func AURPkgbuildRepo(cmdRunner exe.Runner, cmdBuilder exe.GitCmdBuilder, aurURL, pkgName, dest string, force bool) error {
|
||||
func AURPKGBUILDRepo(cmdRunner exe.Runner, cmdBuilder exe.GitCmdBuilder, aurURL, pkgName, dest string, force bool) error {
|
||||
pkgURL := fmt.Sprintf("%s/%s.git", aurURL, pkgName)
|
||||
|
||||
return downloadGitRepo(cmdRunner, cmdBuilder, pkgURL, pkgName, dest, force)
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestGetAURPkgbuild(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
AURPackageURL = PKGBuild.URL
|
||||
PKGBuild.Config.Handler = tt.args.handler
|
||||
got, err := GetAURPkgbuild(PKGBuild.Client(), tt.args.pkgName)
|
||||
got, err := AURPKGBUILD(PKGBuild.Client(), tt.args.pkgName)
|
||||
if tt.wantErr {
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
|
|
|
@ -29,7 +29,7 @@ func downloadGitRepo(cmdRunner exe.Runner,
|
|||
if _, err := os.Stat(filepath.Join(finalDir, ".git")); os.IsNotExist(err) {
|
||||
if _, errD := os.Stat(finalDir); force && errD == nil {
|
||||
if errR := os.RemoveAll(finalDir); errR != nil {
|
||||
return ErrGetPKGBUILDRepo{inner: errR, pkgName: pkgName}
|
||||
return ErrGetPKGBUILDRepo{inner: errR, pkgName: pkgName, errOut: ""}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,9 +105,9 @@ func GetPkgbuilds(dbExecutor db.Executor, httpClient *http.Client, targets []str
|
|||
)
|
||||
|
||||
if aur {
|
||||
pkgbuild, err = GetAURPkgbuild(httpClient, pkgName)
|
||||
pkgbuild, err = AURPKGBUILD(httpClient, pkgName)
|
||||
} else {
|
||||
pkgbuild, err = GetABSPkgbuild(httpClient, dbName, pkgName)
|
||||
pkgbuild, err = ABSPKGBUILD(httpClient, dbName, pkgName)
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
|
@ -181,9 +181,9 @@ func PKGBUILDRepos(dbExecutor db.Executor,
|
|||
)
|
||||
|
||||
if aur {
|
||||
err = AURPkgbuildRepo(cmdRunner, cmdBuilder, aurURL, pkgName, dest, force)
|
||||
err = AURPKGBUILDRepo(cmdRunner, cmdBuilder, aurURL, pkgName, dest, force)
|
||||
} else {
|
||||
err = ABSPkgbuildRepo(cmdRunner, cmdBuilder, dbName, pkgName, dest, force)
|
||||
err = ABSPKGBUILDRepo(cmdRunner, cmdBuilder, dbName, pkgName, dest, force)
|
||||
}
|
||||
|
||||
success := err == nil
|
||||
|
@ -191,8 +191,7 @@ func PKGBUILDRepos(dbExecutor db.Executor,
|
|||
mux.Lock()
|
||||
cloned[target] = success
|
||||
mux.Unlock()
|
||||
}
|
||||
if !success {
|
||||
} else {
|
||||
errs.Add(err)
|
||||
}
|
||||
|
||||
|
@ -205,7 +204,9 @@ func PKGBUILDRepos(dbExecutor db.Executor,
|
|||
gotext.Get("(%d/%d) Downloaded PKGBUILD from ABS: %s",
|
||||
len(cloned), len(targets), text.Cyan(pkgName)))
|
||||
}
|
||||
|
||||
<-sem
|
||||
|
||||
wg.Done()
|
||||
}(target, dbName, name, aur)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue