-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closing pull request result in code 422- "Cannot change the base branch of a closed pull request" #3456
Comments
Actually, your code worked fine for me without modification, so I would check the settings in your repo if you have permissions to modify the PR in question. Here's my working example (use of package main
import (
"context"
"log"
"os"
dbg "github.com/gmlewis/go-httpdebug/httpdebug"
"github.com/google/go-github/v68/github"
"golang.org/x/oauth2"
)
const (
owner = "gmlewis"
repo = "my-test-repo"
)
func main() {
log.SetFlags(0)
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: os.Getenv("GITHUB_SECRET")},
)
tc := oauth2.NewClient(oauth2.NoContext, ts)
tp := dbg.New(dbg.WithTransport(tc.Transport))
client := github.NewClient(tp.Client())
ctx := context.Background()
prs, _, err := client.PullRequests.List(ctx, owner, repo, nil)
if err != nil {
log.Fatal(err)
}
log.Printf("GML: Got %v PRs.", len(prs))
pull := prs[0]
pull.State = github.String("closed")
// pull.Base = nil // <- if this line is added, error does not appear
if _, _, err := client.PullRequests.Edit(ctx, owner, repo, *pull.Number, pull); err != nil {
log.Fatal(err)
}
log.Printf("Done.")
} Here's the run:
The PR in question was successfully closed: gmlewis/my-test-repo#10 |
Your error message sounds funny though:
sounds like you were trying to close an already-closed pull request... I'm not sure how that happened. |
Closing due to inactivity. |
Steps to reproduce:
This code successfully closes the PR, but results in error:
Is that expected behaviour? Do I use the library correctly?
The text was updated successfully, but these errors were encountered: