fix: reuse existing migration pull requests
This commit is contained in:
parent
aff2ccc3fc
commit
90c4c1088a
|
|
@ -419,7 +419,7 @@ func (rm *RepoManager) CreatePullRequest(repo, title, head, base string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if status != http.StatusCreated && status != http.StatusUnprocessableEntity {
|
||||
if status != http.StatusCreated && status != http.StatusUnprocessableEntity && status != http.StatusConflict {
|
||||
return fmt.Errorf("unexpected Forgejo pull request status %d", status)
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -426,6 +426,21 @@ func TestMergePullRequest(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCreatePullRequestAcceptsExistingConflict(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
|
||||
if request.Method != http.MethodPost || request.URL.Path != "/api/v1/repos/owner/cluster/pulls" {
|
||||
t.Fatalf("unexpected pull request request: %s %s", request.Method, request.URL.Path)
|
||||
}
|
||||
writer.WriteHeader(http.StatusConflict)
|
||||
}))
|
||||
defer server.Close()
|
||||
manager := NewRepoManager(server.URL, "token", "owner", "user", "manifests", "cluster", "main", "maidn/bootstrap-test")
|
||||
manager.HTTPClient = server.Client()
|
||||
if err := manager.CreatePullRequest("cluster", "title", "maidn/bootstrap-test", "main"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnsurePullRequestChecksExactOpenBranchBeforeCreating(t *testing.T) {
|
||||
requests := 0
|
||||
server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue