You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-05 00:59:04 +02:00
feat(github): allow to PR cross-repo (#4053)
This allows to open pull requests across repositories on nix, brew, krew and scoop. closes #4048 --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
a3bc051933
commit
773cb91a7a
@ -158,23 +158,35 @@ func (c *githubClient) CloseMilestone(ctx *context.Context, repo Repo, title str
|
||||
return err
|
||||
}
|
||||
|
||||
func headString(base, head Repo) string {
|
||||
return strings.Join([]string{
|
||||
firstNonEmpty(head.Owner, base.Owner),
|
||||
firstNonEmpty(head.Name, base.Name),
|
||||
firstNonEmpty(head.Branch, base.Branch),
|
||||
}, ":")
|
||||
}
|
||||
|
||||
func (c *githubClient) OpenPullRequest(
|
||||
ctx *context.Context,
|
||||
repo Repo,
|
||||
base, title string,
|
||||
base, head Repo,
|
||||
title string,
|
||||
) error {
|
||||
c.checkRateLimit(ctx)
|
||||
if base == "" {
|
||||
def, err := c.getDefaultBranch(ctx, repo)
|
||||
if base.Branch == "" {
|
||||
def, err := c.getDefaultBranch(ctx, base)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
base = def
|
||||
base.Branch = def
|
||||
}
|
||||
pr, res, err := c.client.PullRequests.Create(ctx, repo.Owner, repo.Name, &github.NewPullRequest{
|
||||
log := log.
|
||||
WithField("base", headString(base, Repo{})).
|
||||
WithField("head", headString(base, head))
|
||||
log.Info("opening pull request")
|
||||
pr, res, err := c.client.PullRequests.Create(ctx, base.Owner, base.Name, &github.NewPullRequest{
|
||||
Title: github.String(title),
|
||||
Head: github.String(repo.Branch),
|
||||
Base: github.String(base),
|
||||
Base: github.String(base.Branch),
|
||||
Head: github.String(headString(base, head)),
|
||||
Body: github.String("Automatically generated by [GoReleaser](https://goreleaser.com)"),
|
||||
})
|
||||
if err != nil {
|
||||
@ -224,8 +236,7 @@ func (c *githubClient) CreateFile(
|
||||
|
||||
log.
|
||||
WithField("repository", repo.String()).
|
||||
WithField("name", repo.Name).
|
||||
WithField("name", repo.Name).
|
||||
WithField("branch", repo.Branch).
|
||||
Info("pushing")
|
||||
|
||||
if defBranch != branch && branch != "" {
|
||||
|
Reference in New Issue
Block a user