forked from forgejo/forgejo
Auto merge pull requests when all checks succeeded via API (#9307)
* Fix indention Signed-off-by: kolaente <k@knt.li> * Add option to merge a pr right now without waiting for the checks to succeed Signed-off-by: kolaente <k@knt.li> * Fix lint Signed-off-by: kolaente <k@knt.li> * Add scheduled pr merge to tables used for testing Signed-off-by: kolaente <k@knt.li> * Add status param to make GetPullRequestByHeadBranch reusable Signed-off-by: kolaente <k@knt.li> * Move "Merge now" to a seperate button to make the ui clearer Signed-off-by: kolaente <k@knt.li> * Update models/scheduled_pull_request_merge.go Co-authored-by: 赵智超 <1012112796@qq.com> * Update web_src/js/index.js Co-authored-by: 赵智超 <1012112796@qq.com> * Update web_src/js/index.js Co-authored-by: 赵智超 <1012112796@qq.com> * Re-add migration after merge * Fix frontend lint * Fix version compare * Add vendored dependencies * Add basic tets * Make sure the api route is capable of scheduling PRs for merging * Fix comparing version * make vendor * adopt refactor * apply suggestion: User -> Doer * init var once * Fix Test * Update templates/repo/issue/view_content/comments.tmpl * adopt * nits * next * code format * lint * use same name schema; rm CreateUnScheduledPRToAutoMergeComment * API: can not create schedule twice * Add TestGetBranchNamesForSha * nits * new go routine for each pull to merge * Update models/pull.go Co-authored-by: a1012112796 <1012112796@qq.com> * Update models/scheduled_pull_request_merge.go Co-authored-by: a1012112796 <1012112796@qq.com> * fix & add renaming sugestions * Update services/automerge/pull_auto_merge.go Co-authored-by: a1012112796 <1012112796@qq.com> * fix conflict relicts * apply latest refactors * fix: migration after merge * Update models/error.go Co-authored-by: delvh <dev.lh@web.de> * Update options/locale/locale_en-US.ini Co-authored-by: delvh <dev.lh@web.de> * Update options/locale/locale_en-US.ini Co-authored-by: delvh <dev.lh@web.de> * adapt latest refactors * fix test * use more context * skip potential edgecases * document func usage * GetBranchNamesForSha() -> GetRefsBySha() * start refactoring * ajust to new changes * nit * docu nit * the great check move * move checks for branchprotection into own package * resolve todo now ... * move & rename * unexport if posible * fix * check if merge is allowed before merge on scheduled pull * debugg * wording * improve SetDefaults & nits * NotAllowedToMerge -> DisallowedToMerge * fix test * merge files * use package "errors" * merge files * add string names * other implementation for gogit * adapt refactor * more context for models/pull.go * GetUserRepoPermission use context * more ctx * use context for loading pull head/base-repo * more ctx * more ctx * models.LoadIssueCtx() * models.LoadIssueCtx() * Handle pull_service.Merge in one DB transaction * add TODOs * next * next * next * more ctx * more ctx * Start refactoring structure of old pull code ... * move code into new packages * shorter names ... and finish **restructure** * Update models/branches.go Co-authored-by: zeripath <art27@cantab.net> * finish UpdateProtectBranch * more and fix * update datum * template: use "svg" helper * rename prQueue 2 prPatchCheckerQueue * handle automerge in queue * lock pull on git&db actions ... * lock pull on git&db actions ... * add TODO notes * the regex * transaction in tests * GetRepositoryByIDCtx * shorter table name and lint fix * close transaction bevore notify * Update models/pull.go * next * CheckPullMergable check all branch protections! * Update routers/web/repo/pull.go * CheckPullMergable check all branch protections! * Revert "PullService lock via pullID (#19520)" (for now...) This reverts commit 6cde7c9159a5ea75a10356feb7b8c7ad4c434a9a. * Update services/pull/check.go * Use for a repo action one database transaction * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: delvh <dev.lh@web.de> * Update services/issue/status.go Co-authored-by: delvh <dev.lh@web.de> * Update services/issue/status.go Co-authored-by: delvh <dev.lh@web.de> * use db.WithTx() * gofmt * make pr.GetDefaultMergeMessage() context aware * make MergePullRequestForm.SetDefaults context aware * use db.WithTx() * pull.SetMerged only with context * fix deadlock in `test-sqlite\#TestAPIBranchProtection` * dont forget templates * db.WithTx allow to set the parentCtx * handle db transaction in service packages but not router * issue_service.ChangeStatus just had caused another deadlock :/ it has to do something with how notification package is handled * if we merge a pull in one database transaktion, we get a lock, because merge infoce internal api that cant handle open db sessions to the same repo * ajust to current master * Apply suggestions from code review Co-authored-by: delvh <dev.lh@web.de> * dont open db transaction in router * make generate-swagger * one _success less * wording nit * rm * adapt * remove not needed test files * rm less diff & use attr in JS * ... * Update services/repository/files/commit.go Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> * ajust db schema for PullAutoMerge * skip broken pull refs * more context in error messages * remove webUI part for another pull * remove more WebUI only parts * API: add CancleAutoMergePR * Apply suggestions from code review Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> * fix lint * Apply suggestions from code review * cancle -> cancel Co-authored-by: delvh <dev.lh@web.de> * change queue identifyer * fix swagger * prevent nil issue * fix and dont drop error * as per @zeripath * Update integrations/git_test.go Co-authored-by: delvh <dev.lh@web.de> * Update integrations/git_test.go Co-authored-by: delvh <dev.lh@web.de> * more declarative integration tests (dedup code) * use assert.False/True helper Co-authored-by: 赵智超 <1012112796@qq.com> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
8adba93498
commit
59b30f060a
47 changed files with 869 additions and 26 deletions
1
modules/git/tests/repos/repo5_pulls/HEAD
Normal file
1
modules/git/tests/repos/repo5_pulls/HEAD
Normal file
|
@ -0,0 +1 @@
|
|||
ref: refs/heads/master
|
6
modules/git/tests/repos/repo5_pulls/config
Normal file
6
modules/git/tests/repos/repo5_pulls/config
Normal file
|
@ -0,0 +1,6 @@
|
|||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = true
|
||||
[receive]
|
||||
advertisePushOptions = true
|
1
modules/git/tests/repos/repo5_pulls/description
Normal file
1
modules/git/tests/repos/repo5_pulls/description
Normal file
|
@ -0,0 +1 @@
|
|||
Unnamed repository; edit this file 'description' to name the repository.
|
6
modules/git/tests/repos/repo5_pulls/info/exclude
Normal file
6
modules/git/tests/repos/repo5_pulls/info/exclude
Normal file
|
@ -0,0 +1,6 @@
|
|||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
x%<25>НnУ0<0C>;ы)И0H<30>њ1 P<>]кє(<28>F2ИTх§kЗ7|Иwu]<5D>{Oєв<D194><19>HЈВpЎ<70>8Г$A<>1І"\ЂЊaТRfї<66>fп4л<0B>й#ZL:JЪ\-<2D>Ђ#fO2sАЂN<D082>§Ж6шігЏгчNЛ;яvМХ#њш 3p<>ЋзК5<D09A><35><EFBFBD>pкy^<5E>ЕхyдўL)xклМs_<0F>n№1]ооЇaб_<D0B1>)@X
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
xŹMNÄ0…Y÷Öl„ś'Ť„€ ‰ťi%úŁ4ÜźÄ
Ř<=ů}~˛ó2MccÜM«" ˘ČhÖ¬zޱ÷)q(<28>•CRIŠO¤¸tk¬27Č˝1=˛GrL&]ŘYťBFtÚ'&oŤ„?^¸/–u‰”´ŐčŃŃľ®‚*ÄL<C384>ŘÝ›ŇĹŻ6,¶\ǵĹO©íöô
|
||||
ď˛5řؤžî#xjűěĺ<C49B>‡CžA9<41>VyB÷¨»üóc“˙iëޤ^RŤsŕ<Ĺmo>Ă8·Ž.kly¸¨îC©ič
|
|
@ -0,0 +1,2 @@
|
|||
xŽAJAE]÷)Ь"‚VwWĎt E˛ÄŤz€NU5Ě$ôTö9<C3B6>¸ň&Ţ$'1Ń+¸y|ţ<>Ďçífł6=^XS…NpEĚ…"ÍRĚ1v>W–(Ň®•gD©ŢíJÓÁ@%W’PKZ
|
||||
Řc—2ŠźůšD2)ťr¬®ěímŰ`ä¶ŢYy×fÓÉĽčhđ:j›\Ţü)<29>Ű©»=ăúŚř."ů>ůW˙~6ýź5w<|>>Ü/źž—ÇĂ|
˘mp?<3F>Xó
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
xŽAJAE]÷)Ь!V×ÌtMƒˆ"YâF=@uw5Ì$ô”ûD\yo’“hô
|
||||
nÞâ?ø¼¼ÝlÖÄxbMd ,ƒTŸ<54>˜C7f%äÈuÄ”¼PŒÜ3Jr;i:ÔŽJ,µ`”€5øP)úa¬Ì”µ”1Æž
|
||||
9y³—mƒ9·õÎäU›<EFBFBD>.nàIgƒçYÛâìâOÁ¥ýl×G,<2C>¸:ì=÷q€s$D—›MÿçÍö÷w·«‡ÇÕaÿ_ŸSÑ6¹o9X‚
|
Binary file not shown.
2
modules/git/tests/repos/repo5_pulls/objects/info/packs
Normal file
2
modules/git/tests/repos/repo5_pulls/objects/info/packs
Normal file
|
@ -0,0 +1,2 @@
|
|||
P pack-81423f591973f5d9dab89cc45afa1c544448133e.pack
|
||||
|
Binary file not shown.
Binary file not shown.
5
modules/git/tests/repos/repo5_pulls/packed-refs
Normal file
5
modules/git/tests/repos/repo5_pulls/packed-refs
Normal file
|
@ -0,0 +1,5 @@
|
|||
# pack-refs with: peeled fully-peeled sorted
|
||||
c83380d7056593c51a699d12b9c00627bd5743e9 refs/heads/test-patch-1
|
||||
c83380d7056593c51a699d12b9c00627bd5743e9 refs/pull/1/head
|
||||
111cac04bd7d20301964e27a93698aabb5781b80 refs/pull/1/merge
|
||||
72866af952e98d02a73003501836074b286a78f6 refs/tags/v0.9.99
|
1
modules/git/tests/repos/repo5_pulls/refs/heads/master
Normal file
1
modules/git/tests/repos/repo5_pulls/refs/heads/master
Normal file
|
@ -0,0 +1 @@
|
|||
d8e0bbb45f200e67d9a784ce55bd90821af45ebd
|
|
@ -0,0 +1 @@
|
|||
d8e0bbb45f200e67d9a784ce55bd90821af45ebd
|
|
@ -0,0 +1 @@
|
|||
58a4bcc53ac13e7ff76127e0fb518b5262bf09af
|
1
modules/git/tests/repos/repo5_pulls/refs/pull/4/head
Normal file
1
modules/git/tests/repos/repo5_pulls/refs/pull/4/head
Normal file
|
@ -0,0 +1 @@
|
|||
58a4bcc53ac13e7ff76127e0fb518b5262bf09af
|
Loading…
Add table
Add a link
Reference in a new issue