You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-11-06 09:09:29 +02:00
feat(winget): sync fork before opening PR
closes https://github.com/goreleaser/goreleaser/issues/4720 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
@@ -315,6 +315,20 @@ func doPublish(ctx *context.Context, cl client.Client, wingets []*artifact.Artif
|
||||
return err
|
||||
}
|
||||
|
||||
base := client.Repo{
|
||||
Name: winget.Repository.PullRequest.Base.Name,
|
||||
Owner: winget.Repository.PullRequest.Base.Owner,
|
||||
Branch: winget.Repository.PullRequest.Base.Branch,
|
||||
}
|
||||
|
||||
// try to sync branch
|
||||
fscli, ok := cl.(client.ForkSyncer)
|
||||
if ok && winget.Repository.PullRequest.Enabled {
|
||||
if err := fscli.SyncFork(ctx, repo, base); err != nil {
|
||||
log.WithError(err).Warn("could not sync fork")
|
||||
}
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
if err := cl.CreateFile(
|
||||
ctx,
|
||||
@@ -339,11 +353,7 @@ func doPublish(ctx *context.Context, cl client.Client, wingets []*artifact.Artif
|
||||
return fmt.Errorf("client does not support pull requests")
|
||||
}
|
||||
|
||||
return pcl.OpenPullRequest(ctx, client.Repo{
|
||||
Name: winget.Repository.PullRequest.Base.Name,
|
||||
Owner: winget.Repository.PullRequest.Base.Owner,
|
||||
Branch: winget.Repository.PullRequest.Base.Branch,
|
||||
}, repo, msg, winget.Repository.PullRequest.Draft)
|
||||
return pcl.OpenPullRequest(ctx, base, repo, msg, winget.Repository.PullRequest.Draft)
|
||||
}
|
||||
|
||||
func langserverLineFor(tp artifact.Type) string {
|
||||
|
||||
@@ -127,6 +127,10 @@ func TestRunPipe(t *testing.T) {
|
||||
Branch: "update-{{.Version}}",
|
||||
PullRequest: config.PullRequest{
|
||||
Enabled: true,
|
||||
Base: config.PullRequestBase{
|
||||
Owner: "ms",
|
||||
Name: "winget",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -753,6 +757,7 @@ func TestRunPipe(t *testing.T) {
|
||||
}
|
||||
|
||||
if tt.winget.Repository.PullRequest.Enabled {
|
||||
require.True(t, client.SyncedFork)
|
||||
require.True(t, client.OpenedPullRequest)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user