diff --git a/bots-common/gitea_utils.go b/bots-common/gitea_utils.go index 40ff94d..e4c937f 100644 --- a/bots-common/gitea_utils.go +++ b/bots-common/gitea_utils.go @@ -240,7 +240,7 @@ func (gitea *GiteaTransport) CreateRepositoryIfNotExist(git *GitHandler, org Org return repo.Payload, nil } -func (gitea *GiteaTransport) CreatePullRequest(repo *models.Repository, srcId, targetId, title, body string) (*models.PullRequest, error) { +func (gitea *GiteaTransport) CreatePullRequestIfNotExist(repo *models.Repository, srcId, targetId, title, body string) (*models.PullRequest, error) { prOptions := models.CreatePullRequestOption{ Base: repo.DefaultBranch, Head: srcId, @@ -248,6 +248,13 @@ func (gitea *GiteaTransport) CreatePullRequest(repo *models.Repository, srcId, t Body: body, } + if pr, err := gitea.client.Repository.RepoGetPullRequestByBaseHead( + repository.NewRepoGetPullRequestByBaseHeadParams().WithOwner(repo.Owner.UserName).WithRepo(repo.Name).WithBase(repo.DefaultBranch).WithHead(srcId), + gitea.transport.DefaultAuthentication, + ); err == nil { + return pr.Payload, nil + } + pr, err := gitea.client.Repository.RepoCreatePullRequest( repository. NewRepoCreatePullRequestParams(). @@ -485,4 +492,3 @@ func (gitea *GiteaTransport) GetRecentCommits(org, repo, branch string, commitNo return commits.Payload, nil } -