Skip to content

Commit

Permalink
Check if pkgbuild merge is possible
Browse files Browse the repository at this point in the history
Sometimes aur pkgbuild repos dont contain any branches
  • Loading branch information
theaino committed May 8, 2024
1 parent 9b41f13 commit 977a545
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion pkg/sync/workdir/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 977a545

Please sign in to comment.