diff --git a/local_install_test.go b/local_install_test.go index c9d2fa5e4..a655bf4a9 100644 --- a/local_install_test.go +++ b/local_install_test.go @@ -73,6 +73,7 @@ func TestIntegrationLocalInstall(t *testing.T) { wantCapture := []string{ "makepkg --packagelist", + "git -C testdata/jfin branch --show-current", "git -C testdata/jfin git reset --hard HEAD", "git -C testdata/jfin git merge --no-edit --ff", "makepkg --packagelist", @@ -337,6 +338,7 @@ func TestIntegrationLocalInstallNeeded(t *testing.T) { wantCapture := []string{ "makepkg --packagelist", + "git -C testdata/jfin branch --show-current", "git -C testdata/jfin git reset --hard HEAD", "git -C testdata/jfin git merge --no-edit --ff", "makepkg --packagelist", @@ -510,6 +512,7 @@ func TestIntegrationLocalInstallGenerateSRCINFO(t *testing.T) { wantCapture := []string{ "makepkg --printsrcinfo", "makepkg --packagelist", + "git -C testdata/jfin branch --show-current", "git -C testdata/jfin git reset --hard HEAD", "git -C testdata/jfin git merge --no-edit --ff", "makepkg --packagelist", @@ -795,6 +798,7 @@ func TestIntegrationLocalInstallWithDepsProvides(t *testing.T) { } wantCapture := []string{ + "git -C testdata/cephbin branch --show-current", "git -C testdata/cephbin git reset --hard HEAD", "git -C testdata/cephbin git merge --no-edit --ff", "makepkg --packagelist", @@ -923,8 +927,10 @@ func TestIntegrationLocalInstallTwoSrcInfosWithDeps(t *testing.T) { } wantCapture := []string{ + "git -C testdata/gourou branch --show-current", "git -C testdata/gourou git reset --hard HEAD", "git -C testdata/gourou git merge --no-edit --ff", + "git -C testdata/libzip-git branch --show-current", "git -C testdata/libzip-git git reset --hard HEAD", "git -C testdata/libzip-git git merge --no-edit --ff", "makepkg --packagelist", diff --git a/pkg/sync/workdir/merge.go b/pkg/sync/workdir/merge.go index 593f218f8..cca0347d1 100644 --- a/pkg/sync/workdir/merge.go +++ b/pkg/sync/workdir/merge.go @@ -27,9 +27,27 @@ func gitMerge(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string) error return nil } +func pkgbuildCanMerge(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string) (bool, error) { + stdout, stderr, err := cmdBuilder.Capture( + cmdBuilder.BuildGitCmd(ctx, + dir, "branch", "--show-current")) + if err != nil { + return false, errors.New(gotext.Get("error showing branch %s: %s", dir, stderr)) + } + + return stdout != "", nil +} + func mergePkgbuilds(ctx context.Context, cmdBuilder exe.ICmdBuilder, pkgbuildDirs map[string]string) error { for _, dir := range pkgbuildDirs { - err := gitMerge(ctx, cmdBuilder, dir) + canMerge, err := pkgbuildCanMerge(ctx, cmdBuilder, dir) + if err != nil { + return err + } + if !canMerge { + continue + } + err = gitMerge(ctx, cmdBuilder, dir) if err != nil { return err } diff --git a/sync_test.go b/sync_test.go index 488176c54..fd5a0eb42 100644 --- a/sync_test.go +++ b/sync_test.go @@ -545,6 +545,7 @@ pkgname = python-vosk require.NoError(t, err) wantCapture := []string{ + "/usr/bin/git -C testdata/vosk-api branch --show-current", "/usr/bin/git -C /testdir/vosk-api reset --hard HEAD", "/usr/bin/git -C /testdir/vosk-api merge --no-edit --ff", "makepkg --packagelist", "makepkg --packagelist",