Fix verifyCommits error when push a new branch (#26664)

> ### Description
> If a new branch is pushed, and the repository has a rule that would
require signed commits for the new branch, the commit is rejected with a
500 error regardless of whether it's signed.
> 
> When pushing a new branch, the "old" commit is the empty ID
(0000000000000000000000000000000000000000). verifyCommits has no
provision for this and passes an invalid commit range to git rev-list.
Prior to 1.19 this wasn't an issue because only pre-existing individual
branches could be protected.
> 
> I was able to reproduce with
[try.gitea.io/CraigTest/test](https://try.gitea.io/CraigTest/test),
which is set up with a blanket rule to require commits on all branches.


Fix #25565
Very thanks to @Craig-Holmquist-NTI for reporting the bug and suggesting
an valid solution!

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
CaiCandong
2023-08-30 10:27:53 +08:00
committed by GitHub
parent 508de3a58d
commit 815d267c80
43 changed files with 270 additions and 20 deletions

View File

@@ -0,0 +1 @@
ref: refs/heads/main

View File

@@ -0,0 +1,6 @@
[core]
repositoryformatversion = 0
filemode = false
bare = true
symlinks = false
ignorecase = true

View File

@@ -0,0 +1 @@
d766f2917716d45be24bfa968b8409544941be32 refs/heads/main

View File

@@ -0,0 +1 @@
0000000000000000000000000000000000000000 d766f2917716d45be24bfa968b8409544941be32 Gitea <gitea@fake.local> 1693148474 +0800 push

View File

@@ -0,0 +1 @@
0000000000000000000000000000000000000000 d766f2917716d45be24bfa968b8409544941be32 Gitea <gitea@fake.local> 1693148474 +0800 push

View File

@@ -0,0 +1,2 @@
x•ŽK
1Ù ÒéüAÄS¸ï$Í"32 ooð®ŠWð òÞ{!žæ`˜JC%¡.˜ $Ár]sѱe$ïmòâMƒ·)£÷±(O`ªbtlÐE[:;4–àHÐ1_û<5F>”rayýáþl“é÷~“ÊE­L@cå€Xv…Mþã":µMÛƒG«_}À?Ý

View File

@@ -0,0 +1,2 @@
x<>1
!ES{ŠéAwGGa 9EúQg W·Èí#¹AªÞû©ÕZ§/£€³Œp±ì(¤(<28>ó®óBhÈÛ¼&áŸãÝ:pLY`ûÍãU†ð-µzŸÁ°ô†×ZM:<3A>†ü¡¨Êå€óxJ/ûG}:µ3

View File

@@ -0,0 +1,3 @@
x•ŽA
Â0E]ç³$™L“ ˆx•L2µ]´<C2B4>
ÞÞê

View File

@@ -0,0 +1,3 @@
xË®«FE3æ+zn%44æ!%Qxƒ<78>Û€s˜AÓ` 8Øæëã{£Ì2IM¶j•ª´¥Údèûf²Ìý2<C3BD>"‡$§e‰¶
-(â ­Ä!´ÝJ"åaŲ@•BaîùHo3 ŸVØòå<$<24>/)å$JøJDB¡•H¤§˜ü{¾ RRðûOù«nfšÿF†þOÀ‰
âq[°<>2„̇~ŒÍô¬Ô÷zjjðë<C3B0>ÒLÛÅÀ·}prm¬Fqhþä `@Ø«¦ªš®ª¥Õ˜fî?3Ç[7г…ê¨Ð) ^™þuÿÖ¿,µ<>Æl7©zÝÿr|&«Ou4<75>Ø9Ó:µÎQjôû·êÕ1x±õå6ÍQ‡÷ƒÀ%Áåtû‰sò¸íV‰| ( V¿<56>,aL,ù«G~²Ç<16>¹<C2B9>r¥ùûî@·`·Àþ$[! XËŠep©Œæ[8 oýä(« k£Z´Î³yóeÐ¹ÙÆÄ«Y²¿kÖd€¯6•3¾;3ÜÔ RÔi ÞdYÓDk91V]/Cê#º¾&ÿêpo´Fáb¯¶}§¹ô¦òuW&]+m xaqdÜIõX¯þ3

View File

@@ -0,0 +1,3 @@
x•ŽA
Â0E]ç³$™L“ ˆx•L2µ]´<C2B4>
ÞÞê

View File

@@ -0,0 +1 @@
d766f2917716d45be24bfa968b8409544941be32