Skip to content
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

Add option to API to update PullRequest base branch #11666

Merged
merged 21 commits into from
Jun 7, 2020

Conversation

6543
Copy link
Member

@6543 6543 commented May 29, 2020

close #11552

@blaggacao
Copy link

blaggacao commented May 29, 2020

Failing test seem unrelated?

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 29, 2020
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 29, 2020
Copy link

@blaggacao blaggacao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things I took from:

gitea/routers/repo/pull.go

Lines 1190 to 1229 in 5cb201d

if err := pull_service.ChangeTargetBranch(pr, ctx.User, targetBranch); err != nil {
if models.IsErrPullRequestAlreadyExists(err) {
err := err.(models.ErrPullRequestAlreadyExists)
RepoRelPath := ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name
errorMessage := ctx.Tr("repo.pulls.has_pull_request", ctx.Repo.RepoLink, RepoRelPath, err.IssueID)
ctx.Flash.Error(errorMessage)
ctx.JSON(http.StatusConflict, map[string]interface{}{
"error": err.Error(),
"user_error": errorMessage,
})
} else if models.IsErrIssueIsClosed(err) {
errorMessage := ctx.Tr("repo.pulls.is_closed")
ctx.Flash.Error(errorMessage)
ctx.JSON(http.StatusConflict, map[string]interface{}{
"error": err.Error(),
"user_error": errorMessage,
})
} else if models.IsErrPullRequestHasMerged(err) {
errorMessage := ctx.Tr("repo.pulls.has_merged")
ctx.Flash.Error(errorMessage)
ctx.JSON(http.StatusConflict, map[string]interface{}{
"error": err.Error(),
"user_error": errorMessage,
})
} else if models.IsErrBranchesEqual(err) {
errorMessage := ctx.Tr("repo.pulls.nothing_to_compare")
ctx.Flash.Error(errorMessage)
ctx.JSON(http.StatusBadRequest, map[string]interface{}{
"error": err.Error(),
"user_error": errorMessage,
})
} else {
ctx.ServerError("UpdatePullRequestTarget", err)
}
return

routers/api/v1/repo/pull.go Outdated Show resolved Hide resolved
routers/api/v1/repo/pull.go Outdated Show resolved Hide resolved
routers/api/v1/repo/pull.go Show resolved Hide resolved
@6543 6543 force-pushed the api-pull_change-base_11552 branch from 278d782 to 4ce24ee Compare May 29, 2020 10:33
@6543
Copy link
Member Author

6543 commented May 29, 2020

updated tests, now all should PASS :D

@zeripath zeripath added the modifies/api This PR adds API routes or modifies them label May 29, 2020
@zeripath zeripath added this to the 1.13.0 milestone May 29, 2020
@zeripath zeripath changed the title [API] Add Option to Update PullRequest base branch Add option to API to update PullRequest base branch May 29, 2020
@lunny
Copy link
Member

lunny commented May 30, 2020

Is this change compitable with Github API?

@blaggacao
Copy link

What I know: Github provides this feature through it's API.

@6543
Copy link
Member Author

6543 commented May 30, 2020

@blaggacao
Copy link

@zeripath @lunny Anything is blocking second review? Are code owners summoned?

@blaggacao
Copy link

git-town/git-town#1518 has gotten merged, git town now supports gitea, but for full support this PR is pressing, everything else is set up. ⌛ The gun is loaded.

@blaggacao
Copy link

@zeripath You marked this for 1.13.0. Given it's blocking git-town/git-town#1530, any chance to get this shipped earlier?

@techknowlogick
Copy link
Member

@blaggacao as we've already passed the feature freeze, and are now in the RC phase for 1.12 we cannot get it into the 1.12 release.

@blaggacao
Copy link

I see, ok then, let's head for 1.13.0! 🚀

Copy link
Contributor

@zeripath zeripath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notwithstanding my comments re:transactions as this doesn't make the function worse I think we can leave that be.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 6, 2020
@zeripath
Copy link
Contributor

zeripath commented Jun 6, 2020

@techknowlogick it might be reasonable to backport this as you could argue it's a bug that the API doesn't have this when the UI does.

@zeripath
Copy link
Contributor

zeripath commented Jun 7, 2020

make lg-tm work

@zeripath zeripath merged commit 5814079 into go-gitea:master Jun 7, 2020
@6543 6543 deleted the api-pull_change-base_11552 branch June 7, 2020 19:16
6543 added a commit to 6543-forks/gitea that referenced this pull request Jun 7, 2020
@6543
Copy link
Member Author

6543 commented Jun 7, 2020

Backport = #11796

@lafriks lafriks added backport/done All backports for this PR have been created backport/v1.12 labels Jun 7, 2020
lafriks added a commit that referenced this pull request Jun 7, 2020
* EditPull: add option to change base

Close #11552

Co-authored-by: Lauris BH <[email protected]>
@blaggacao
Copy link

Nice, thank you all!

ydelafollye pushed a commit to ydelafollye/gitea that referenced this pull request Jul 31, 2020
abayer pushed a commit to abayer/gitea-go-sdk that referenced this pull request Sep 3, 2020
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable Update PR base branch through API
7 participants