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
|
return repoURL + ".git", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetABSPkgbuild retrieves the PKGBUILD file to a dest directory
|
// ABSPKGBUILD retrieves the PKGBUILD file to a dest directory.
|
||||||
func GetABSPkgbuild(httpClient *http.Client, dbName, pkgName string) ([]byte, error) {
|
func ABSPKGBUILD(httpClient *http.Client, dbName, pkgName string) ([]byte, error) {
|
||||||
packageURL, err := getPackageURL(dbName, pkgName)
|
packageURL, err := getPackageURL(dbName, pkgName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -79,8 +79,8 @@ func GetABSPkgbuild(httpClient *http.Client, dbName, pkgName string) ([]byte, er
|
||||||
return pkgBuild, nil
|
return pkgBuild, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ABSPkgbuildRepo retrieves the PKGBUILD repository to a dest directory
|
// ABSPKGBUILDRepo retrieves the PKGBUILD repository to a dest directory
|
||||||
func ABSPkgbuildRepo(cmdRunner exe.Runner, cmdBuilder exe.GitCmdBuilder, dbName, pkgName, dest string, force bool) error {
|
func ABSPKGBUILDRepo(cmdRunner exe.Runner, cmdBuilder exe.GitCmdBuilder, dbName, pkgName, dest string, force bool) error {
|
||||||
pkgURL, err := getPackageRepoURL(dbName)
|
pkgURL, err := getPackageRepoURL(dbName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -126,7 +126,7 @@ func TestGetABSPkgbuild(t *testing.T) {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
ABSPackageURL = PKGBuild.URL
|
ABSPackageURL = PKGBuild.URL
|
||||||
PKGBuild.Config.Handler = tt.args.handler
|
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 {
|
if tt.wantErr {
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
var AURPackageURL = "https://aur.archlinux.org/cgit/aur.git"
|
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 := url.Values{}
|
||||||
values.Set("h", pkgName)
|
values.Set("h", pkgName)
|
||||||
pkgURL := AURPackageURL + "/plain/PKGBUILD?" + values.Encode()
|
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.
|
// 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)
|
pkgURL := fmt.Sprintf("%s/%s.git", aurURL, pkgName)
|
||||||
|
|
||||||
return downloadGitRepo(cmdRunner, cmdBuilder, pkgURL, pkgName, dest, force)
|
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) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
AURPackageURL = PKGBuild.URL
|
AURPackageURL = PKGBuild.URL
|
||||||
PKGBuild.Config.Handler = tt.args.handler
|
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 {
|
if tt.wantErr {
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,7 +29,7 @@ func downloadGitRepo(cmdRunner exe.Runner,
|
||||||
if _, err := os.Stat(filepath.Join(finalDir, ".git")); os.IsNotExist(err) {
|
if _, err := os.Stat(filepath.Join(finalDir, ".git")); os.IsNotExist(err) {
|
||||||
if _, errD := os.Stat(finalDir); force && errD == nil {
|
if _, errD := os.Stat(finalDir); force && errD == nil {
|
||||||
if errR := os.RemoveAll(finalDir); errR != 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 {
|
if aur {
|
||||||
pkgbuild, err = GetAURPkgbuild(httpClient, pkgName)
|
pkgbuild, err = AURPKGBUILD(httpClient, pkgName)
|
||||||
} else {
|
} else {
|
||||||
pkgbuild, err = GetABSPkgbuild(httpClient, dbName, pkgName)
|
pkgbuild, err = ABSPKGBUILD(httpClient, dbName, pkgName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -181,9 +181,9 @@ func PKGBUILDRepos(dbExecutor db.Executor,
|
||||||
)
|
)
|
||||||
|
|
||||||
if aur {
|
if aur {
|
||||||
err = AURPkgbuildRepo(cmdRunner, cmdBuilder, aurURL, pkgName, dest, force)
|
err = AURPKGBUILDRepo(cmdRunner, cmdBuilder, aurURL, pkgName, dest, force)
|
||||||
} else {
|
} else {
|
||||||
err = ABSPkgbuildRepo(cmdRunner, cmdBuilder, dbName, pkgName, dest, force)
|
err = ABSPKGBUILDRepo(cmdRunner, cmdBuilder, dbName, pkgName, dest, force)
|
||||||
}
|
}
|
||||||
|
|
||||||
success := err == nil
|
success := err == nil
|
||||||
|
@ -191,8 +191,7 @@ func PKGBUILDRepos(dbExecutor db.Executor,
|
||||||
mux.Lock()
|
mux.Lock()
|
||||||
cloned[target] = success
|
cloned[target] = success
|
||||||
mux.Unlock()
|
mux.Unlock()
|
||||||
}
|
} else {
|
||||||
if !success {
|
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +204,9 @@ func PKGBUILDRepos(dbExecutor db.Executor,
|
||||||
gotext.Get("(%d/%d) Downloaded PKGBUILD from ABS: %s",
|
gotext.Get("(%d/%d) Downloaded PKGBUILD from ABS: %s",
|
||||||
len(cloned), len(targets), text.Cyan(pkgName)))
|
len(cloned), len(targets), text.Cyan(pkgName)))
|
||||||
}
|
}
|
||||||
|
|
||||||
<-sem
|
<-sem
|
||||||
|
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}(target, dbName, name, aur)
|
}(target, dbName, name, aur)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue