fix(download): use git pull --rebase --autostash instead of --ff-only. fixes #1635

This commit is contained in:
jguer 2021-12-12 19:05:48 +01:00
parent bf288822b9
commit 81eeb8c495
No known key found for this signature in database
GPG key ID: 6D6CC9BEA8556B35
3 changed files with 5 additions and 5 deletions

View file

@ -234,13 +234,13 @@ func TestABSPKGBUILDRepoExistsPerms(t *testing.T) {
os.MkdirAll(filepath.Join(dir, "linux", ".git"), 0o777)
want := fmt.Sprintf("/usr/local/bin/git --no-replace-objects -C %s/linux pull --ff-only", dir)
want := fmt.Sprintf("/usr/local/bin/git --no-replace-objects -C %s/linux pull --rebase --autostash", dir)
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 -p DynamicUser=yes -p CacheDirectory=yay -E HOME=/tmp --no-replace-objects -C %s/linux pull --ff-only", ld, dir)
want = fmt.Sprintf("%s --service-type=oneshot --pipe --wait --pty -p DynamicUser=yes -p CacheDirectory=yay -E HOME=/tmp --no-replace-objects -C %s/linux pull --rebase --autostash", ld, dir)
}
cmdRunner := &testRunner{}

View file

@ -113,13 +113,13 @@ func TestAURPKGBUILDRepoExistsPerms(t *testing.T) {
os.MkdirAll(filepath.Join(dir, "yay-bin", ".git"), 0o777)
want := fmt.Sprintf("/usr/local/bin/git --no-replace-objects -C %s/yay-bin pull --ff-only", dir)
want := fmt.Sprintf("/usr/local/bin/git --no-replace-objects -C %s/yay-bin pull --rebase --autostash", dir)
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 -p DynamicUser=yes -p CacheDirectory=yay -E HOME=/tmp --no-replace-objects -C %s/yay-bin pull --ff-only", ld, dir)
want = fmt.Sprintf("%s --service-type=oneshot --pipe --wait --pty -p DynamicUser=yes -p CacheDirectory=yay -E HOME=/tmp --no-replace-objects -C %s/yay-bin pull --rebase --autostash", ld, dir)
}
cmdRunner := &testRunner{}

View file

@ -56,7 +56,7 @@ func downloadGitRepo(ctx context.Context, cmdBuilder exe.GitCmdBuilder,
errOut: gotext.Get("error reading %s", filepath.Join(dest, pkgName, ".git")),
}
default:
cmd := cmdBuilder.BuildGitCmd(ctx, filepath.Join(dest, pkgName), "pull", "--ff-only")
cmd := cmdBuilder.BuildGitCmd(ctx, filepath.Join(dest, pkgName), "pull", "--rebase", "--autostash")
_, stderr, errCmd := cmdBuilder.Capture(cmd)
if errCmd != nil {