1
0
mirror of https://github.com/Jguer/yay synced 2024-07-01 07:56:37 +00:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Aino L. Spring
3fc021b8ac
Merge ecd25a894f into 9ed9b0b4e1 2024-06-20 14:36:33 +02:00
Marcus B Spencer
9ed9b0b4e1
Update README.md (#2458)
Update the README to prevent partial upgrades.

Partial upgrades are dangerous on Arch Linux.
Partial upgrades may occur when a `-y` operation is given without a corresponding `-u` operation.

Quote from the ArchWiki:
> Do not use:
> `pacman -Sy package`
> `pacman -Sy` followed by `pacman -S` package (Note the absence of `-S**u**` in the installation of the package.)
> `pacman -Syuw` (Note that `pacman -Syuw` does imply the same risks like pacman -Sy`, as it will update the pacman sync database without installing the newer packages.)

https://wiki.archlinux.org/title/System_maintenance#Partial_upgrades_are_unsupported
2024-06-20 14:15:14 +02:00
Aino Spring
ecd25a894f
Fixed tests 2024-05-13 20:16:56 +02:00
Aino Spring
494b22470a
Git env-var config overrides implemented
Signed-off-by: Aino Spring <info@aino-spring.com>
2024-05-13 20:06:28 +02:00
Aino Spring
24845d30a9
Ignore global gitconfig and clone always in origin
Signed-off-by: Aino Spring <info@aino-spring.com>
2024-05-13 20:06:27 +02:00
5 changed files with 27 additions and 7 deletions

View File

@ -35,10 +35,10 @@ If you are migrating from another AUR helper, you can simply install Yay with th
The initial installation of Yay can be done by cloning the PKGBUILD and
building with makepkg:
We start with updating the package lists and make sure we have the `base-devel` package group installed.
We make sure we have the `base-devel` package group installed.
```sh
pacman -Sy --needed git base-devel
pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

View File

@ -272,13 +272,13 @@ func Test_getPackageRepoURL(t *testing.T) {
func TestABSPKGBUILDRepo(t *testing.T) {
t.Parallel()
cmdRunner := &testRunner{}
want := "/usr/local/bin/git --no-replace-objects -C /tmp/doesnt-exist clone --no-progress --single-branch https://gitlab.archlinux.org/archlinux/packaging/packages/linux.git linux"
want := "/usr/local/bin/git --no-replace-objects -C /tmp/doesnt-exist clone --no-progress --origin=origin --single-branch https://gitlab.archlinux.org/archlinux/packaging/packages/linux.git linux"
if os.Getuid() == 0 {
ld := "systemd-run"
if path, _ := exec.LookPath(ld); path != "" {
ld = path
}
want = fmt.Sprintf("%s --service-type=oneshot --pipe --wait --pty --quiet -p DynamicUser=yes -p CacheDirectory=yay -E HOME=/tmp --no-replace-objects -C /tmp/doesnt-exist clone --no-progress --single-branch https://gitlab.archlinux.org/archlinux/packaging/packages/linux.git linux", ld)
want = fmt.Sprintf("%s --service-type=oneshot --pipe --wait --pty --quiet -p DynamicUser=yes -p CacheDirectory=yay -E HOME=/tmp --no-replace-objects -C /tmp/doesnt-exist clone --no-progress --origin=origin --single-branch https://gitlab.archlinux.org/archlinux/packaging/packages/linux.git linux", ld)
}
cmdBuilder := &testGitBuilder{

View File

@ -81,13 +81,13 @@ func TestGetAURPkgbuild(t *testing.T) {
// THEN a clone command should be formed
func TestAURPKGBUILDRepo(t *testing.T) {
t.Parallel()
want := "/usr/local/bin/git --no-replace-objects -C /tmp/doesnt-exist clone --no-progress https://aur.archlinux.org/yay-bin.git yay-bin"
want := "/usr/local/bin/git --no-replace-objects -C /tmp/doesnt-exist clone --no-progress --origin=origin https://aur.archlinux.org/yay-bin.git yay-bin"
if os.Getuid() == 0 {
ld := "systemd-run"
if path, _ := exec.LookPath(ld); path != "" {
ld = path
}
want = fmt.Sprintf("%s --service-type=oneshot --pipe --wait --pty --quiet -p DynamicUser=yes -p CacheDirectory=yay -E HOME=/tmp --no-replace-objects -C /tmp/doesnt-exist clone --no-progress https://aur.archlinux.org/yay-bin.git yay-bin", ld)
want = fmt.Sprintf("%s --service-type=oneshot --pipe --wait --pty --quiet -p DynamicUser=yes -p CacheDirectory=yay -E HOME=/tmp --no-replace-objects -C /tmp/doesnt-exist clone --no-progress --origin=origin https://aur.archlinux.org/yay-bin.git yay-bin", ld)
}
cmdRunner := &testRunner{}

View File

@ -44,7 +44,7 @@ func downloadGitRepo(ctx context.Context, cmdBuilder exe.GitCmdBuilder,
gitArgs = append(gitArgs, pkgURL, pkgName)
cloneArgs := make([]string, 0, len(gitArgs)+4)
cloneArgs = append(cloneArgs, "clone", "--no-progress")
cloneArgs = append(cloneArgs, "clone", "--no-progress", "--origin=origin")
cloneArgs = append(cloneArgs, gitArgs...)
cmd := cmdBuilder.BuildGitCmd(ctx, dest, cloneArgs...)

View File

@ -26,6 +26,9 @@ var gitDenyList = mapset.NewThreadUnsafeSet(
"GIT_WORK_TREE",
"GIT_DIR",
)
var gitConfigOverrides = map[string]string{
"clone.defaultRemoteName": "origin",
}
type GitCmdBuilder interface {
Runner
@ -113,6 +116,20 @@ func gitFilteredEnv() []string {
return env
}
func gitConfigEnv() []string {
var env []string
count := 0
for key, value := range gitConfigOverrides {
env = append(env, fmt.Sprintf("GIT_CONFIG_KEY_%d=%s", count, key))
env = append(env, fmt.Sprintf("GIT_CONFIG_VALUE_%d=%s", count, value))
count++
}
env = append(env, "GIT_CONFIG_COUNT="+strconv.Itoa(count))
return env
}
func (c *CmdBuilder) BuildGitCmd(ctx context.Context, dir string, extraArgs ...string) *exec.Cmd {
args := make([]string, len(c.GitFlags), len(c.GitFlags)+len(extraArgs))
copy(args, c.GitFlags)
@ -128,6 +145,7 @@ func (c *CmdBuilder) BuildGitCmd(ctx context.Context, dir string, extraArgs ...s
cmd := exec.CommandContext(ctx, c.GitBin, args...)
cmd.Env = gitFilteredEnv()
cmd.Env = append(cmd.Env, gitConfigEnv()...)
cmd = c.deElevateCommand(ctx, cmd)
@ -153,6 +171,8 @@ func (c *CmdBuilder) BuildMakepkgCmd(ctx context.Context, dir string, extraArgs
cmd := exec.CommandContext(ctx, c.MakepkgBin, args...)
cmd.Dir = dir
cmd.Env = append(cmd.Env, gitConfigEnv()...)
cmd = c.deElevateCommand(ctx, cmd)
return cmd