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

Fix automerge will not work because of some events haven't been triggered #30780

Merged
merged 37 commits into from May 21, 2024

Conversation

lunny
Copy link
Member

@lunny lunny commented Apr 30, 2024

Replace #25741
Close #24445
Close #30658
Close #20646
Depends on #30805

Since #25741 has been rewritten totally, to make the contribution easier, I will continue the work in this PR. Thanks @6543

@lunny lunny added type/bug backport/v1.21 This PR should be backported to Gitea 1.21 backport/v1.22 This PR should be backported to Gitea 1.22 labels Apr 30, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 30, 2024
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 30, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Apr 30, 2024
@lunny lunny added this to the 1.23.0 milestone May 1, 2024
@lunny lunny marked this pull request as draft May 2, 2024 02:06
@lunny lunny marked this pull request as ready for review May 7, 2024 08:40
@yp05327
Copy link
Contributor

yp05327 commented May 8, 2024

I think we need some tests.

@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 21, 2024
@wxiaoguang wxiaoguang removed the backport/v1.21 This PR should be backported to Gitea 1.21 label May 21, 2024
wxiaoguang
wxiaoguang previously approved these changes May 21, 2024
@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 May 21, 2024
@@ -111,6 +104,33 @@ func MergeScheduledPullRequest(ctx context.Context, sha string, repo *repo_model
return nil
}

// StartPRCheckAndAutoMerge start an automerge check and auto merge task for a pull request
func StartPRCheckAndAutoMerge(ctx context.Context, pull *issues_model.PullRequest) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not make StartPRCheckAndAutoMergeBySHA call StartPRCheckAndAutoMerge to avoid duplicate code?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are two different functions. I think less code are duplicated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I don't see why sha should be passed into addToQueue

It seems that the sha is only used for logging. Ideally only call addToQueue(pr.ID) should be enough, and a lot of code could be simplified?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the SHA will prevent when both an automerge task and a newly push are triggered. So the previous triggered automerge task will be ignored.

if headCommitID != sha {
		log.Warn("Head commit id of auto merge %-v does not match sha [%s], it may means the head branch has been updated. Just ignore this request because a new request expected in the queue", pr, sha)
		return
	}

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually such check doesn't seem right and only makes some problem harder to debug.

Because, the head commit ID could change again after that check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's not perfect. It needs more refactor like I said before. But since it's a bugfix, I will not do it in this PR.

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

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

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

Doesn't seem quite right, but just do it.

@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 May 21, 2024
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@lunny lunny merged commit c6cf96d into go-gitea:main May 21, 2024
26 checks passed
@lunny lunny deleted the lunny/fix_automerge branch May 21, 2024 15:23
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request May 21, 2024
…ered (go-gitea#30780)

Replace go-gitea#25741
Close go-gitea#24445
Close go-gitea#30658
Close go-gitea#20646
~Depends on go-gitea#30805~

Since go-gitea#25741 has been rewritten totally, to make the contribution
easier, I will continue the work in this PR. Thanks @6543

---------

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label May 21, 2024
lunny added a commit that referenced this pull request May 22, 2024
…ered (#30780) (#31039)

Backport #30780 by @lunny

Replace #25741
Close #24445
Close #30658
Close #20646
~Depends on #30805~

Since #25741 has been rewritten totally, to make the contribution
easier, I will continue the work in this PR. Thanks @6543

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
zjjhot added a commit to zjjhot/gitea that referenced this pull request May 22, 2024
* giteaofficial/main:
  Add nix flake for dev shell (go-gitea#30967)
  [skip ci] Updated translations via Crowdin
  Fix wrong display of recently pushed notification (go-gitea#25812)
  use existing oauth grant for public client (go-gitea#31015)
  Fix automerge will not work because of some events haven't been triggered (go-gitea#30780)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/done All backports for this PR have been created backport/v1.22 This PR should be backported to Gitea 1.22 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/bug
Projects
None yet
6 participants