From 8e00e25dcf06d6f92463554c9e06dd2c35ddf57d Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 15:23:05 +0100 Subject: [PATCH 01/21] Fix commit retrieval by tag It is not correct to return tag data like the tag's message when commit data requested. This changes fixes commit retrieval by tag for both the latest commit in the UI and the commit info on tag webhook events. Fixes: https://github.com/go-gitea/gitea/issues/21687 Replaces: https://github.com/go-gitea/gitea/pull/21693 --- modules/git/repo_commit_gogit.go | 38 ------------------------------ modules/git/repo_commit_nogogit.go | 4 ---- 2 files changed, 42 deletions(-) diff --git a/modules/git/repo_commit_gogit.go b/modules/git/repo_commit_gogit.go index 14fec3f9c6bd0..0b2460d746182 100644 --- a/modules/git/repo_commit_gogit.go +++ b/modules/git/repo_commit_gogit.go @@ -68,38 +68,6 @@ func (repo *Repository) IsCommitExist(name string) bool { return err == nil } -func convertPGPSignatureForTag(t *object.Tag) *CommitGPGSignature { - if t.PGPSignature == "" { - return nil - } - - var w strings.Builder - var err error - - if _, err = fmt.Fprintf(&w, - "object %s\ntype %s\ntag %s\ntagger ", - t.Target.String(), t.TargetType.Bytes(), t.Name); err != nil { - return nil - } - - if err = t.Tagger.Encode(&w); err != nil { - return nil - } - - if _, err = fmt.Fprintf(&w, "\n\n"); err != nil { - return nil - } - - if _, err = fmt.Fprintf(&w, t.Message); err != nil { - return nil - } - - return &CommitGPGSignature{ - Signature: t.PGPSignature, - Payload: strings.TrimSpace(w.String()) + "\n", - } -} - func (repo *Repository) getCommit(id SHA1) (*Commit, error) { var tagObject *object.Tag @@ -123,12 +91,6 @@ func (repo *Repository) getCommit(id SHA1) (*Commit, error) { commit := convertCommit(gogitCommit) commit.repo = repo - if tagObject != nil { - commit.CommitMessage = strings.TrimSpace(tagObject.Message) - commit.Author = &tagObject.Tagger - commit.Signature = convertPGPSignatureForTag(tagObject) - } - tree, err := gogitCommit.Tree() if err != nil { return nil, err diff --git a/modules/git/repo_commit_nogogit.go b/modules/git/repo_commit_nogogit.go index 13a7be778f583..3a7fcd3072639 100644 --- a/modules/git/repo_commit_nogogit.go +++ b/modules/git/repo_commit_nogogit.go @@ -108,10 +108,6 @@ func (repo *Repository) getCommitFromBatchReader(rd *bufio.Reader, id SHA1) (*Co return nil, err } - commit.CommitMessage = strings.TrimSpace(tag.Message) - commit.Author = tag.Tagger - commit.Signature = tag.Signature - return commit, nil case "commit": commit, err := CommitFromReader(repo, id, io.LimitReader(rd, size)) From e66e2c27bcb0542d0fdfb67220ef079ddf2b8913 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 15:32:52 +0100 Subject: [PATCH 02/21] fix import --- modules/git/repo_commit_gogit.go | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/git/repo_commit_gogit.go b/modules/git/repo_commit_gogit.go index 0b2460d746182..9fb843d818f9c 100644 --- a/modules/git/repo_commit_gogit.go +++ b/modules/git/repo_commit_gogit.go @@ -8,7 +8,6 @@ package git import ( - "fmt" "strings" "github.com/go-git/go-git/v5/plumbing" From c793f0f156526b93eb259f4f61dd56f7333f4c17 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 16:47:00 +0100 Subject: [PATCH 03/21] attempt to fix tests --- modules/git/repo_commit_test.go | 3 ++- modules/git/tests/repos/repo1_bare/MERGE_RR | 0 modules/git/tests/repos/repo1_bare/index | Bin 0 -> 65 bytes modules/git/tests/repos/repo1_bare/logs/HEAD | 1 + .../tests/repos/repo1_bare/logs/refs/heads/master | 1 + .../1c/91d130dc5fb75fd2d9f586a058650889cfe7fb | Bin 0 -> 813 bytes .../28/b55526e7100924d864dd89e35c1ea62e7a5a32 | Bin 0 -> 818 bytes .../36/f97d9a96457e2bab511db30fe2db03893ebc64 | Bin 0 -> 770 bytes .../4b/825dc642cb6eb9a060e54bf8d69288fbee4904 | Bin 0 -> 15 bytes .../93/3305878a3c9ad485c29b87fb662a73a9675c4b | Bin 0 -> 770 bytes .../ce/064814f4a0d337b333e646ece456cd39fab612 | Bin 0 -> 815 bytes .../cf/8b0b492a950b358a7ce7f9d01b18aef48a6b2d | Bin 0 -> 827 bytes .../git/tests/repos/repo1_bare/refs/heads/master | 2 +- .../tests/repos/repo1_bare/refs/tags/signed-tag | 1 + 14 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 modules/git/tests/repos/repo1_bare/MERGE_RR create mode 100644 modules/git/tests/repos/repo1_bare/index create mode 100644 modules/git/tests/repos/repo1_bare/objects/1c/91d130dc5fb75fd2d9f586a058650889cfe7fb create mode 100644 modules/git/tests/repos/repo1_bare/objects/28/b55526e7100924d864dd89e35c1ea62e7a5a32 create mode 100644 modules/git/tests/repos/repo1_bare/objects/36/f97d9a96457e2bab511db30fe2db03893ebc64 create mode 100644 modules/git/tests/repos/repo1_bare/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 create mode 100644 modules/git/tests/repos/repo1_bare/objects/93/3305878a3c9ad485c29b87fb662a73a9675c4b create mode 100644 modules/git/tests/repos/repo1_bare/objects/ce/064814f4a0d337b333e646ece456cd39fab612 create mode 100644 modules/git/tests/repos/repo1_bare/objects/cf/8b0b492a950b358a7ce7f9d01b18aef48a6b2d create mode 100644 modules/git/tests/repos/repo1_bare/refs/tags/signed-tag diff --git a/modules/git/repo_commit_test.go b/modules/git/repo_commit_test.go index 7b3a5101f2b36..c523f17b1a577 100644 --- a/modules/git/repo_commit_test.go +++ b/modules/git/repo_commit_test.go @@ -44,7 +44,8 @@ func TestGetTagCommitWithSignature(t *testing.T) { assert.NoError(t, err) defer bareRepo1.Close() - commit, err := bareRepo1.GetCommit("3ad28a9149a2864384548f3d17ed7f38014c9e8a") + // both the tag and the commit are signed here, this validates only the commit signature + commit, err := bareRepo1.GetCommit("28b55526e7100924d864dd89e35c1ea62e7a5a32") assert.NoError(t, err) assert.NotNil(t, commit) assert.NotNil(t, commit.Signature) diff --git a/modules/git/tests/repos/repo1_bare/MERGE_RR b/modules/git/tests/repos/repo1_bare/MERGE_RR new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/modules/git/tests/repos/repo1_bare/index b/modules/git/tests/repos/repo1_bare/index new file mode 100644 index 0000000000000000000000000000000000000000..65d675154f23ffb2d0196e017d44a5e7017550f5 GIT binary patch literal 65 zcmZ?q402{*U|<4bhL9jvS0E+HV4z^Y<=qr}%;|LA&IJiiy? 1563741799 +0200 push +feaf4ba6bc635fec442f46ddd4512416ec43c2c2 ce064814f4a0d337b333e646ece456cd39fab612 silverwind 1668354026 +0100 push diff --git a/modules/git/tests/repos/repo1_bare/logs/refs/heads/master b/modules/git/tests/repos/repo1_bare/logs/refs/heads/master index cef4ca2dcb904..46da5fe0b15a5 100644 --- a/modules/git/tests/repos/repo1_bare/logs/refs/heads/master +++ b/modules/git/tests/repos/repo1_bare/logs/refs/heads/master @@ -1 +1,2 @@ 37991dec2c8e592043f47155ce4808d4580f9123 feaf4ba6bc635fec442f46ddd4512416ec43c2c2 silverwind 1563741799 +0200 push +feaf4ba6bc635fec442f46ddd4512416ec43c2c2 ce064814f4a0d337b333e646ece456cd39fab612 silverwind 1668354026 +0100 push diff --git a/modules/git/tests/repos/repo1_bare/objects/1c/91d130dc5fb75fd2d9f586a058650889cfe7fb b/modules/git/tests/repos/repo1_bare/objects/1c/91d130dc5fb75fd2d9f586a058650889cfe7fb new file mode 100644 index 0000000000000000000000000000000000000000..fb50b65f9ff04e722d4df5c734d8d64eb761f61a GIT binary patch literal 813 zcmV+|1Je9>0hN=$TCJP2Xxf!d&!#WIA07Sc z-}rko{0TTwlo3WUgn)${giP`CznT8;VLjH5rUu{sK1DZeAB1KIV%zk|TN3F%IRhBb z9PLkq5Je@VG#Xt$hdF;uMI+|B`^$-rht7qT6PT^;8KmNjgm2tCMa{5fZwl-At?ceGLjp0z2VhpHLt`~~|T~IpX0N;HyZB}>LdTjFq zF7l@L56{<9jqruT;wT6UKle|G7x5{QKjX-fT;KL)2Am#GHi~cTebB~Cf59;O2y2us z(Q_epA>N*DazSBOChX)i#BS@jqmH89jSn6w)NisbKr|Sq zKEn4(PPFFq+6X7=xN~Zc?G8aT6uQR%({_S$js!VG_XbOmqKqND4Fk5fN@vAH~};niGA@JCnu z_3!z6)Bg!1LY7GRS_~FYf>0=a_Ip(SJ6PZ9v8lngzehK1Hvpj>g2c50y4%O*Pc8rf zG?6>&lG|c65Myy2c?(cORdEEv&>#cn;eT#O%WN=JZb^8w&z{L#EE2i{f zDp{`5TdSUEVm^~jFW!M?r|4cH-Ch%`pz7&#OcxOCjAa*vnfw%;_#lA&E?^rm-YuBz zz}NV6*2?Z-9QGZa+xp1k6^WdIMp-WPfn^oTe1GX#JK=j{#R!Rk0KAnMCh%iMGe=Yn0HhHTH69K_~U#mDD#e)F9tuV$mC%km(m@{ITImFHXqaPvM==o#v(HMUn( zlDyj;vP8@8#iz>A9Cq3|tE|O|FHe3E9%f#j#nC)54D~8L&_)2_2crD#DhJV>=IXK6 z)!QoLuVEx%Q9j$6^RN2;!0yv_)I;6m{vC;FZPQ{;f=(R-K=Npw7p>&(l6@8&$7z*5 zR;SrLxVfhH2`L=(B5!Nh!33A^!&=@JAJ1%q47Tw2e$55I3@>}<<=%>|$k`@q=*`dg z5Eawb*CsrD#%s1sHClT+^KxBY6s0CE%3fqU`_+JBR{+jpQw19}dWl+_>)h=Mx1+wf z#s?$l$7^Q2=WdHwM@5CSMwVqJr268sa<%Z*ZeS>YE?!jU<&)_Sdy~)WR5$0bGg2&{ zPo-avmv=s%HQgC*}wMDx!J97h3X@&33Vm3fD-(!hEBf-4BoO w+B0=nHhnM})sQ$Zu`>Mc0{H$)Tub=nj2RgJWsLA8)wL?W{qj=y0e4SSEbv>W@Bjb+ literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo1_bare/objects/36/f97d9a96457e2bab511db30fe2db03893ebc64 b/modules/git/tests/repos/repo1_bare/objects/36/f97d9a96457e2bab511db30fe2db03893ebc64 new file mode 100644 index 0000000000000000000000000000000000000000..c96b843902407e9468f8851fa80fc054dbb045c4 GIT binary patch literal 770 zcmV+d1O5DX0d14HvZGcMMIG}M%Bg1%pbJ#FU1lD{jD&y;E{GXP7Z9MY_iMY#o%lq1 ztzg$l_MBA*o}+$ypT9$szl$Wf0t-&#^UhDQ2zA`e{UXt9*zKT^ob!U@_>^^lEkoI z4PQe!O<7f9Uq4S&G{ZS~ns*2d%@HowK>5dGSmPTXQ4mB)5DK+Xl$)1RZ4A_q8eY2@ z_||YHb<@>)#a4yE*<{=oq^kSRW4+?ewoecRe60M{4gf3atUrm_ZKuJdBTO#p#7zpv zw=+DEDI2tQrM1)IBA$!L&xi%_R9=lc^ldi_EE^tb^$%_+6%=J3u1y;D%-UcYXo}G4rI7Wyu9?uR0&U~S;kG`2#y8}*6I48-3+3Do-kT?PxcE%O8bp__jX$sDQ#?B> zulhl6G1c84gT9Pj(ywxGhZdUNRKFe1Q_7zwv^N3u1`i286*iq(DN}sl>qf0kmy%_3 zI^viZ+2$w#wG4J4YM)gwqq++wU*E22AL3T147JBQtaBdjQiDbgiEY_PxGH&SEx$}` z3nSeUm+>-8{!IY5Jp)=-!z7MU8^(T0&%@iOI(y7c`~C!<{Bq5pl=#|7;-*S^W4N5) z^UxF~$_%+;Z%6oG;xSouf^x_DmVYKe;g(m@k&_*+QBKd9u zA0m_9>7kwHsNy}bRB=vF#@Z^&eN~aN14N^1fBk{|K$8~!I}*i_|8F9H1G4HoaeVlG AYybcN literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo1_bare/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/modules/git/tests/repos/repo1_bare/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 new file mode 100644 index 0000000000000000000000000000000000000000..adf64119a33d7621aeeaa505d30adb58afaa5559 GIT binary patch literal 15 WcmbxJ#nW*WL@ocIdmEWK9r>)TVA>E9|chi@fKQQ|1m;JrD|G8lWLE?Ch7x~Q>^Z7+l zzY@MNdOq_CQQtqMLetuB0yEe|mbq8r*sw#@ADN1QH5N5#z+>U|~0sL6( zL+E0M+1b9?LC;X|p6E@XXjS_kr#cw0prS=Jdn5OJ5~|wvVH?V&tT|{3W~{!4F>Xgi z;rBs~{Yg-)Ad~&QTbxVJPbkn1wHPaog-^tb5~GzY!kFXm;Kf?4YDI-oIe3s`^YkcL z`XfD@YJH+F*knvkJ}nfzkoM>eTL=SsnV>$Xgp8|9va2-RV(-l~$B|?wP;gLt7-scm zS5B5{EK1#c%)K4ec`Vq2yWp;ttu>){clYkB;Pza?*L-JiP3XhzDjGyF;GEr345RdM zJ5SwvTk7D7DQBHcHqB18W7Lt;K0-+wa;T{miC{y_DIF@6cW&Y&SG{ygdFGanmtG#V zl+ChiE~!VjS`2+&qU5U;hq!B!+J>cisE&;Ww%)RR*A7`iG%A)~!1Z8Cce-nBO|S?w zr30dN>XXBHKV0nX%LWJYDrEd1Kg)qQP73>>m1-j9ByHVE^;{sSs+O~r!WO7k)ULd0kV*bOeT~H&k&Dn zMBPl5C@Y0L19<^>u|$O+aHRksgo4O&0t-HbFSvpuvSqINk(}!GiN;smLGllb{`$B5 zz3%@cSpZ~S6c|<@DTZYjqWJmWjQ;oH?Qxsx8~N?;+Ue&0M0%!2hI{j*MscA3(>0k3Gy?^E;pJ^ z(;jH6;gw(KV>;=9N;%49M`e@N^gD+)xSP7^$;_(aXur<-%dx92T_c7dD`Oen3?5=& zB?X=H4Xc7I;hXn*A05#Lj_i&~Nb7vWB*|j|sl1Cj_X@Lv6LV-?2=b&!QY6&pkh9yx zP1NQXCXXzVPY*Am@$?XjHd9t)4Et$8w6}z(i!h(yWMWFDj(tXuP!ftOUaEH3f~Or# zqjvQ!0UA;3AMZ;YH(+~p5Q^63T5{fO5FhxKf~nVpJT`L+pC@;kfg9sMko#>E#~r}m&H zC9~{mtIj10?v&|haRypt;cc89-lkc}>^jsV?Rm5x1PSWr&`ehDi6Yy@O8Al=yiXNt zet(HzvWE2zBCFno>&4qBrqUS9riqL4J45ML zt1~RHNXU$$DAP<4iB@0jWrGp4b23kFh(8yMdol%6gbz>bRqsjLcsYexWom2fz7u@N z;xHcI(jBU6V4jxB&BLoed9R_>9(olKq;9IufUzjktsXKSCBHsr+qj?2BkP=FAM|^H tX@=8L;`x@o11ve0?*#chs$T~2%NhNo{g*MsN2(6NZ@;`GegOD(SMvVNmv;aF literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo1_bare/objects/cf/8b0b492a950b358a7ce7f9d01b18aef48a6b2d b/modules/git/tests/repos/repo1_bare/objects/cf/8b0b492a950b358a7ce7f9d01b18aef48a6b2d new file mode 100644 index 0000000000000000000000000000000000000000..1152b25bb8318c8fcb2b11de4e18b0185eeef25f GIT binary patch literal 827 zcmV-B1H}Az0hN={!^kHPlWms3wlCQ+oE z+1}FGT9cLcZCfumNmAr5%Y+aPGLB-390DrOAjJzzk3Y7OV*+b`<h9v z2Wyta=yLImAN_ z##D*&bKCI+=#th#k4y$ay2Gw=-kC+PcK|`jjN8nf!*%IpqL{nz)+J<)0Kt;-?sL-(FZT_ z_%1)Ja-7%pVDO_(pohavsk_^@gi26+d ze6;S@2WbyS_wCYAJn{`gHf|{Gl+X&cVNE{_>?{D{&>rk%J+H-C*Qr>8L7lv+#3wU9 zCJm0wIdl^Ex4mm`76`^`{>e-?7~HLfhL87JzrHOl@`cpL2B!f?4O<<1H> z!c*yCAY>(?x~CS*PS%Ui^+K^Sv$K<6c#;jaz?R!yMDYw&R`1g=NF?EMQ_H?6NpSVy zyM4QAGd+4Y)b{o;9&AXC&+RZ^mFBsXA1A`|=XQ{IA%T<+tqh+ke}Q{Q%RZ FW`6CxpoRbd literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo1_bare/refs/heads/master b/modules/git/tests/repos/repo1_bare/refs/heads/master index c5e92eb229764..9b0de228190a6 100644 --- a/modules/git/tests/repos/repo1_bare/refs/heads/master +++ b/modules/git/tests/repos/repo1_bare/refs/heads/master @@ -1 +1 @@ -feaf4ba6bc635fec442f46ddd4512416ec43c2c2 +ce064814f4a0d337b333e646ece456cd39fab612 diff --git a/modules/git/tests/repos/repo1_bare/refs/tags/signed-tag b/modules/git/tests/repos/repo1_bare/refs/tags/signed-tag new file mode 100644 index 0000000000000..3998a68507d4e --- /dev/null +++ b/modules/git/tests/repos/repo1_bare/refs/tags/signed-tag @@ -0,0 +1 @@ +36f97d9a96457e2bab511db30fe2db03893ebc64 From 6b14736a0591fe475c2953f6c1fb625742ab4464 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 17:39:54 +0100 Subject: [PATCH 04/21] fix TestRepository_GetTags --- modules/git/repo_tag_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/git/repo_tag_test.go b/modules/git/repo_tag_test.go index 6a00473bb794a..7be1f85ea0336 100644 --- a/modules/git/repo_tag_test.go +++ b/modules/git/repo_tag_test.go @@ -26,11 +26,14 @@ func TestRepository_GetTags(t *testing.T) { assert.NoError(t, err) return } - assert.Len(t, tags, 1) + assert.Len(t, tags, 2) assert.Equal(t, len(tags), total) - assert.EqualValues(t, "test", tags[0].Name) - assert.EqualValues(t, "3ad28a9149a2864384548f3d17ed7f38014c9e8a", tags[0].ID.String()) + assert.EqualValues(t, "signed-tag", tags[0].Name) + assert.EqualValues(t, "36f97d9a96457e2bab511db30fe2db03893ebc64", tags[0].ID.String()) assert.EqualValues(t, "tag", tags[0].Type) + assert.EqualValues(t, "test", tags[1].Name) + assert.EqualValues(t, "3ad28a9149a2864384548f3d17ed7f38014c9e8a", tags[1].ID.String()) + assert.EqualValues(t, "tag", tags[1].Type) } func TestRepository_GetTag(t *testing.T) { From c5952510f7266c1dc4291d8db2e1132b579a0a14 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 17:59:44 +0100 Subject: [PATCH 05/21] fix TestRepository_GetCodeActivityStats --- modules/git/repo_stats_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/git/repo_stats_test.go b/modules/git/repo_stats_test.go index 494a1613052af..b7def9c7af8d1 100644 --- a/modules/git/repo_stats_test.go +++ b/modules/git/repo_stats_test.go @@ -25,9 +25,9 @@ func TestRepository_GetCodeActivityStats(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, code) - assert.EqualValues(t, 9, code.CommitCount) + assert.EqualValues(t, 10, code.CommitCount) assert.EqualValues(t, 3, code.AuthorCount) - assert.EqualValues(t, 9, code.CommitCountInAllBranches) + assert.EqualValues(t, 10, code.CommitCountInAllBranches) assert.EqualValues(t, 10, code.Additions) assert.EqualValues(t, 1, code.Deletions) assert.Len(t, code.Authors, 3) From 82c00c1f1b7b68a376bef14d39e7d644f65261b3 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 18:29:22 +0100 Subject: [PATCH 06/21] fix TestRepository_GetRefs --- modules/git/repo_ref_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/git/repo_ref_test.go b/modules/git/repo_ref_test.go index afd38ca251919..f692ec52417b7 100644 --- a/modules/git/repo_ref_test.go +++ b/modules/git/repo_ref_test.go @@ -20,13 +20,14 @@ func TestRepository_GetRefs(t *testing.T) { refs, err := bareRepo1.GetRefs() assert.NoError(t, err) - assert.Len(t, refs, 5) + assert.Len(t, refs, 6) expectedRefs := []string{ BranchPrefix + "branch1", BranchPrefix + "branch2", BranchPrefix + "master", TagPrefix + "test", + TagPrefix + "signed-tag", NotesRef, } @@ -44,9 +45,12 @@ func TestRepository_GetRefsFiltered(t *testing.T) { refs, err := bareRepo1.GetRefsFiltered(TagPrefix) assert.NoError(t, err) - if assert.Len(t, refs, 1) { - assert.Equal(t, TagPrefix+"test", refs[0].Name) + if assert.Len(t, refs, 2) { + assert.Equal(t, TagPrefix+"signed-tag", refs[0].Name) assert.Equal(t, "tag", refs[0].Type) - assert.Equal(t, "3ad28a9149a2864384548f3d17ed7f38014c9e8a", refs[0].Object.String()) + assert.Equal(t, "36f97d9a96457e2bab511db30fe2db03893ebc64", refs[0].Object.String()) + assert.Equal(t, TagPrefix+"test", refs[1].Name) + assert.Equal(t, "tag", refs[1].Type) + assert.Equal(t, "3ad28a9149a2864384548f3d17ed7f38014c9e8a", refs[1].Object.String()) } } From 0ee518d54edd2ce4423f84c72817e11f6767c209 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 18:45:20 +0100 Subject: [PATCH 07/21] fix TestGetLatestCommitTime --- modules/git/repo_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/git/repo_test.go b/modules/git/repo_test.go index 8ca170cd1f876..fa9c3b06868d5 100644 --- a/modules/git/repo_test.go +++ b/modules/git/repo_test.go @@ -18,7 +18,7 @@ func TestGetLatestCommitTime(t *testing.T) { // Time is Sun Jul 21 22:43:13 2019 +0200 // which is the time of commit // feaf4ba6bc635fec442f46ddd4512416ec43c2c2 (refs/heads/master) - assert.EqualValues(t, 1563741793, lct.Unix()) + assert.EqualValues(t, 1668354014, lct.Unix()) } func TestRepoIsEmpty(t *testing.T) { From e92fff6f2244cbe4d6e8cc27f7445b616f31a86c Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 18:46:45 +0100 Subject: [PATCH 08/21] update comment --- modules/git/repo_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/git/repo_test.go b/modules/git/repo_test.go index fa9c3b06868d5..7660deacd85b1 100644 --- a/modules/git/repo_test.go +++ b/modules/git/repo_test.go @@ -15,9 +15,9 @@ func TestGetLatestCommitTime(t *testing.T) { bareRepo1Path := filepath.Join(testReposDir, "repo1_bare") lct, err := GetLatestCommitTime(DefaultContext, bareRepo1Path) assert.NoError(t, err) - // Time is Sun Jul 21 22:43:13 2019 +0200 + // Time is Sun Nov 13 16:40:14 2022 +0100 // which is the time of commit - // feaf4ba6bc635fec442f46ddd4512416ec43c2c2 (refs/heads/master) + // ce064814f4a0d337b333e646ece456cd39fab612 (refs/heads/master) assert.EqualValues(t, 1668354014, lct.Unix()) } From 854170e60e4d43d1a5b0d70f08249610a088f3b2 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 19:08:09 +0100 Subject: [PATCH 09/21] fix TestGetTagCommitWithSignature --- modules/git/repo_commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/git/repo_commit_test.go b/modules/git/repo_commit_test.go index c523f17b1a577..9c143e1be2899 100644 --- a/modules/git/repo_commit_test.go +++ b/modules/git/repo_commit_test.go @@ -50,7 +50,7 @@ func TestGetTagCommitWithSignature(t *testing.T) { assert.NotNil(t, commit) assert.NotNil(t, commit.Signature) // test that signature is not in message - assert.Equal(t, "tag", commit.CommitMessage) + assert.Equal(t, "signed-commit\n", commit.CommitMessage) } func TestGetCommitWithBadCommitID(t *testing.T) { From 83e3629ddac2697e91fca29fa5d9f056a3decc63 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 19:49:33 +0100 Subject: [PATCH 10/21] trim off newline from commit.CommitMessage --- modules/git/commit_reader.go | 2 +- modules/git/repo_commit_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/git/commit_reader.go b/modules/git/commit_reader.go index 3c1f6f5ffd656..e7950b40c0d7c 100644 --- a/modules/git/commit_reader.go +++ b/modules/git/commit_reader.go @@ -95,7 +95,7 @@ readLoop: _, _ = payloadSB.Write(line) } } - commit.CommitMessage = messageSB.String() + commit.CommitMessage = strings.TrimRight(messageSB.String(), "\n") commit.Signature = &CommitGPGSignature{ Signature: signatureSB.String(), Payload: payloadSB.String(), diff --git a/modules/git/repo_commit_test.go b/modules/git/repo_commit_test.go index 9c143e1be2899..08d1fae1333b9 100644 --- a/modules/git/repo_commit_test.go +++ b/modules/git/repo_commit_test.go @@ -50,7 +50,7 @@ func TestGetTagCommitWithSignature(t *testing.T) { assert.NotNil(t, commit) assert.NotNil(t, commit.Signature) // test that signature is not in message - assert.Equal(t, "signed-commit\n", commit.CommitMessage) + assert.Equal(t, "signed-commit", commit.CommitMessage) } func TestGetCommitWithBadCommitID(t *testing.T) { From 92813a6ea59b9c72c95807bd509423743d1f127e Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 19:52:46 +0100 Subject: [PATCH 11/21] remove useless MERGE_RR file --- modules/git/tests/repos/repo1_bare/MERGE_RR | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 modules/git/tests/repos/repo1_bare/MERGE_RR diff --git a/modules/git/tests/repos/repo1_bare/MERGE_RR b/modules/git/tests/repos/repo1_bare/MERGE_RR deleted file mode 100644 index e69de29bb2d1d..0000000000000 From 9a831b9545b06db8e82e2220d1e96d66bf88f9b0 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 20:10:59 +0100 Subject: [PATCH 12/21] fix TestCommitFromReader and rename file to commit_reader_test.go --- modules/git/{commit_test.go => commit_reader_test.go} | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename modules/git/{commit_test.go => commit_reader_test.go} (98%) diff --git a/modules/git/commit_test.go b/modules/git/commit_reader_test.go similarity index 98% rename from modules/git/commit_test.go rename to modules/git/commit_reader_test.go index fb8c22dfd3573..fd8276d2f9eaa 100644 --- a/modules/git/commit_test.go +++ b/modules/git/commit_reader_test.go @@ -100,10 +100,8 @@ committer silverwind 1563741793 +0200 empty commit`, commitFromReader.Signature.Payload) assert.EqualValues(t, "silverwind ", commitFromReader.Author.String()) - commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n")) + commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString)) assert.NoError(t, err) - commitFromReader.CommitMessage += "\n\n" - commitFromReader.Signature.Payload += "\n\n" assert.EqualValues(t, commitFromReader, commitFromReader2) } From 78a1bdcc5be8e5c9121774b65d714fe1e1559e3b Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 20:13:52 +0100 Subject: [PATCH 13/21] only trim a single newline --- modules/git/commit_reader.go | 2 +- modules/git/commit_reader_test.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/git/commit_reader.go b/modules/git/commit_reader.go index e7950b40c0d7c..215736d1dae6d 100644 --- a/modules/git/commit_reader.go +++ b/modules/git/commit_reader.go @@ -95,7 +95,7 @@ readLoop: _, _ = payloadSB.Write(line) } } - commit.CommitMessage = strings.TrimRight(messageSB.String(), "\n") + commit.CommitMessage = strings.TrimSuffix(messageSB.String(), "\n") commit.Signature = &CommitGPGSignature{ Signature: signatureSB.String(), Payload: payloadSB.String(), diff --git a/modules/git/commit_reader_test.go b/modules/git/commit_reader_test.go index fd8276d2f9eaa..4a9c4e11e09fb 100644 --- a/modules/git/commit_reader_test.go +++ b/modules/git/commit_reader_test.go @@ -100,8 +100,10 @@ committer silverwind 1563741793 +0200 empty commit`, commitFromReader.Signature.Payload) assert.EqualValues(t, "silverwind ", commitFromReader.Author.String()) - commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString)) + commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n")) assert.NoError(t, err) + commitFromReader.CommitMessage += "\n" + commitFromReader.Signature.Payload += "\n" assert.EqualValues(t, commitFromReader, commitFromReader2) } From 5e61ff560abb3e20a3ed258d35ee85214771e1b5 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 20:29:21 +0100 Subject: [PATCH 14/21] really fix TestCommitFromReader --- modules/git/commit_reader_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/git/commit_reader_test.go b/modules/git/commit_reader_test.go index 4a9c4e11e09fb..fd8276d2f9eaa 100644 --- a/modules/git/commit_reader_test.go +++ b/modules/git/commit_reader_test.go @@ -100,10 +100,8 @@ committer silverwind 1563741793 +0200 empty commit`, commitFromReader.Signature.Payload) assert.EqualValues(t, "silverwind ", commitFromReader.Author.String()) - commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n")) + commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString)) assert.NoError(t, err) - commitFromReader.CommitMessage += "\n" - commitFromReader.Signature.Payload += "\n" assert.EqualValues(t, commitFromReader, commitFromReader2) } From b4ef4ca01b4fbf2726a49c7a426e9966b53fe3db Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 20:55:32 +0100 Subject: [PATCH 15/21] fix TestGetFileResponseFromCommit --- services/repository/files/file_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/repository/files/file_test.go b/services/repository/files/file_test.go index e158c63de24a7..e9074fcf6cad8 100644 --- a/services/repository/files/file_test.go +++ b/services/repository/files/file_test.go @@ -82,7 +82,7 @@ func getExpectedFileResponse() *api.FileResponse { Date: "2017-03-19T20:47:59Z", }, Parents: []*api.CommitMeta{}, - Message: "Initial commit\n", + Message: "Initial commit", Tree: &api.CommitMeta{ URL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/trees/2a2f1d4670728a2e10049e345bd7a276468beab6", SHA: "2a2f1d4670728a2e10049e345bd7a276468beab6", From 3eb73783e70d4eabcf14330953d843f4f0427dfc Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 21:30:38 +0100 Subject: [PATCH 16/21] fix TestDeleteRepoFile --- tests/integration/repofiles_delete_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/repofiles_delete_test.go b/tests/integration/repofiles_delete_test.go index f594efdeeb58f..0efd0d849cd73 100644 --- a/tests/integration/repofiles_delete_test.go +++ b/tests/integration/repofiles_delete_test.go @@ -51,7 +51,7 @@ func getExpectedDeleteFileResponse(u *url.URL) *api.FileResponse { Email: "bob@smith.com", }, }, - Message: "Deletes README.md\n", + Message: "Deletes README.md", }, Verification: &api.PayloadCommitVerification{ Verified: false, From ac8339c40345b1feacfde1f84066b7c7c5be872e Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 22:01:38 +0100 Subject: [PATCH 17/21] fix TestAPICreateFile --- tests/integration/api_repo_file_create_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/api_repo_file_create_test.go b/tests/integration/api_repo_file_create_test.go index f03efaa0eadf9..bf22b20463d64 100644 --- a/tests/integration/api_repo_file_create_test.go +++ b/tests/integration/api_repo_file_create_test.go @@ -98,7 +98,7 @@ func getExpectedFileResponseForCreate(repoFullName, commitID, treePath, latestCo }, Date: "2000-12-31T23:59:50Z", }, - Message: "Updates README.md\n", + Message: "Updates README.md", }, Verification: &api.PayloadCommitVerification{ Verified: false, @@ -204,7 +204,7 @@ func TestAPICreateFile(t *testing.T) { assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA) assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL) assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL) - assert.EqualValues(t, createFileOptions.Message+"\n", fileResponse.Commit.Message) + assert.EqualValues(t, createFileOptions.Message, fileResponse.Commit.Message) // Test creating a file without a message createFileOptions = getCreateFileOptions() @@ -215,7 +215,7 @@ func TestAPICreateFile(t *testing.T) { req = NewRequestWithJSON(t, "POST", url, &createFileOptions) resp = session.MakeRequest(t, req, http.StatusCreated) DecodeJSON(t, resp, &fileResponse) - expectedMessage := "Add '" + treePath + "'\n" + expectedMessage := "Add '" + treePath + "'" assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message) // Test trying to create a file that already exists, should fail From 4e3f0d90c44bd3095c29d789bcc7503a0a0d77a6 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 22:30:22 +0100 Subject: [PATCH 18/21] fix TestAPIDeleteFile --- tests/integration/api_repo_file_delete_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/api_repo_file_delete_test.go b/tests/integration/api_repo_file_delete_test.go index 2c8b1e381f7c5..821b8850bb114 100644 --- a/tests/integration/api_repo_file_delete_test.go +++ b/tests/integration/api_repo_file_delete_test.go @@ -88,7 +88,7 @@ func TestAPIDeleteFile(t *testing.T) { DecodeJSON(t, resp, &fileResponse) assert.NotNil(t, fileResponse) assert.Nil(t, fileResponse.Content) - assert.EqualValues(t, deleteFileOptions.Message+"\n", fileResponse.Commit.Message) + assert.EqualValues(t, deleteFileOptions.Message, fileResponse.Commit.Message) // Test deleting file without a message fileID++ @@ -100,7 +100,7 @@ func TestAPIDeleteFile(t *testing.T) { req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fileResponse) - expectedMessage := "Delete '" + treePath + "'\n" + expectedMessage := "Delete '" + treePath + "'" assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message) // Test deleting a file with the wrong SHA From 0425a5363b290af6bc0e67e6e624f58ad17575f2 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 13 Nov 2022 23:06:27 +0100 Subject: [PATCH 19/21] fix TestAPIUpdateFile --- tests/integration/api_repo_file_update_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/api_repo_file_update_test.go b/tests/integration/api_repo_file_update_test.go index a3be67ad844f4..09a9fac6aa765 100644 --- a/tests/integration/api_repo_file_update_test.go +++ b/tests/integration/api_repo_file_update_test.go @@ -94,7 +94,7 @@ func getExpectedFileResponseForUpdate(commitID, treePath, lastCommitSHA string) Email: "annedoe@example.com", }, }, - Message: "My update of README.md\n", + Message: "My update of README.md", }, Verification: &api.PayloadCommitVerification{ Verified: false, @@ -168,7 +168,7 @@ func TestAPIUpdateFile(t *testing.T) { assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA) assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL) assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL) - assert.EqualValues(t, updateFileOptions.Message+"\n", fileResponse.Commit.Message) + assert.EqualValues(t, updateFileOptions.Message, fileResponse.Commit.Message) // Test updating a file and renaming it updateFileOptions = getUpdateFileOptions() @@ -200,7 +200,7 @@ func TestAPIUpdateFile(t *testing.T) { req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions) resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fileResponse) - expectedMessage := "Update '" + treePath + "'\n" + expectedMessage := "Update '" + treePath + "'" assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message) // Test updating a file with the wrong SHA From 91e9ee4472802fe7ff02354d238fa81cad3d6765 Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 14 Nov 2022 06:47:17 +0100 Subject: [PATCH 20/21] fix wiki tests --- tests/integration/api_wiki_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/integration/api_wiki_test.go b/tests/integration/api_wiki_test.go index c6f4841d082ef..aea99dc6ffa3b 100644 --- a/tests/integration/api_wiki_test.go +++ b/tests/integration/api_wiki_test.go @@ -50,7 +50,7 @@ func TestAPIGetWikiPage(t *testing.T) { }, Date: "2017-11-27T04:31:18Z", }, - Message: "Add Home.md\n", + Message: "Add Home.md", }, }, ContentBase64: base64.RawStdEncoding.EncodeToString( @@ -97,7 +97,7 @@ func TestAPIListWikiPages(t *testing.T) { }, Date: "2017-11-27T04:31:18Z", }, - Message: "Add Home.md\n", + Message: "Add Home.md", }, }, { @@ -120,7 +120,7 @@ func TestAPIListWikiPages(t *testing.T) { }, Date: "2019-01-25T01:41:55Z", }, - Message: "Add jpeg.jpg and page with image\n", + Message: "Add jpeg.jpg and page with image", }, }, { @@ -143,7 +143,7 @@ func TestAPIListWikiPages(t *testing.T) { }, Date: "2019-01-25T01:39:51Z", }, - Message: "Add page with spaced name\n", + Message: "Add page with spaced name", }, }, { @@ -166,7 +166,7 @@ func TestAPIListWikiPages(t *testing.T) { }, Date: "2021-07-19T16:42:46Z", }, - Message: "add unescaped file\n", + Message: "add unescaped file", }, }, } @@ -242,7 +242,7 @@ func TestAPIListPageRevisions(t *testing.T) { }, Date: "2017-11-27T04:31:18Z", }, - Message: "Add Home.md\n", + Message: "Add Home.md", }, }, Count: 1, From 20343dbb549cff5aa36ec6ea480a2796d1f5db8a Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 15 Nov 2022 20:14:27 +0100 Subject: [PATCH 21/21] back out of newline changes --- modules/git/commit_reader.go | 2 +- .../git/{commit_reader_test.go => commit_test.go} | 4 +++- modules/git/repo_commit_test.go | 2 +- services/repository/files/file_test.go | 2 +- tests/integration/api_repo_file_create_test.go | 6 +++--- tests/integration/api_repo_file_delete_test.go | 4 ++-- tests/integration/api_repo_file_update_test.go | 6 +++--- tests/integration/api_wiki_test.go | 12 ++++++------ tests/integration/repofiles_delete_test.go | 2 +- 9 files changed, 21 insertions(+), 19 deletions(-) rename modules/git/{commit_reader_test.go => commit_test.go} (98%) diff --git a/modules/git/commit_reader.go b/modules/git/commit_reader.go index 215736d1dae6d..3c1f6f5ffd656 100644 --- a/modules/git/commit_reader.go +++ b/modules/git/commit_reader.go @@ -95,7 +95,7 @@ readLoop: _, _ = payloadSB.Write(line) } } - commit.CommitMessage = strings.TrimSuffix(messageSB.String(), "\n") + commit.CommitMessage = messageSB.String() commit.Signature = &CommitGPGSignature{ Signature: signatureSB.String(), Payload: payloadSB.String(), diff --git a/modules/git/commit_reader_test.go b/modules/git/commit_test.go similarity index 98% rename from modules/git/commit_reader_test.go rename to modules/git/commit_test.go index fd8276d2f9eaa..fb8c22dfd3573 100644 --- a/modules/git/commit_reader_test.go +++ b/modules/git/commit_test.go @@ -100,8 +100,10 @@ committer silverwind 1563741793 +0200 empty commit`, commitFromReader.Signature.Payload) assert.EqualValues(t, "silverwind ", commitFromReader.Author.String()) - commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString)) + commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n")) assert.NoError(t, err) + commitFromReader.CommitMessage += "\n\n" + commitFromReader.Signature.Payload += "\n\n" assert.EqualValues(t, commitFromReader, commitFromReader2) } diff --git a/modules/git/repo_commit_test.go b/modules/git/repo_commit_test.go index 08d1fae1333b9..9c143e1be2899 100644 --- a/modules/git/repo_commit_test.go +++ b/modules/git/repo_commit_test.go @@ -50,7 +50,7 @@ func TestGetTagCommitWithSignature(t *testing.T) { assert.NotNil(t, commit) assert.NotNil(t, commit.Signature) // test that signature is not in message - assert.Equal(t, "signed-commit", commit.CommitMessage) + assert.Equal(t, "signed-commit\n", commit.CommitMessage) } func TestGetCommitWithBadCommitID(t *testing.T) { diff --git a/services/repository/files/file_test.go b/services/repository/files/file_test.go index e9074fcf6cad8..e158c63de24a7 100644 --- a/services/repository/files/file_test.go +++ b/services/repository/files/file_test.go @@ -82,7 +82,7 @@ func getExpectedFileResponse() *api.FileResponse { Date: "2017-03-19T20:47:59Z", }, Parents: []*api.CommitMeta{}, - Message: "Initial commit", + Message: "Initial commit\n", Tree: &api.CommitMeta{ URL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/trees/2a2f1d4670728a2e10049e345bd7a276468beab6", SHA: "2a2f1d4670728a2e10049e345bd7a276468beab6", diff --git a/tests/integration/api_repo_file_create_test.go b/tests/integration/api_repo_file_create_test.go index bf22b20463d64..f03efaa0eadf9 100644 --- a/tests/integration/api_repo_file_create_test.go +++ b/tests/integration/api_repo_file_create_test.go @@ -98,7 +98,7 @@ func getExpectedFileResponseForCreate(repoFullName, commitID, treePath, latestCo }, Date: "2000-12-31T23:59:50Z", }, - Message: "Updates README.md", + Message: "Updates README.md\n", }, Verification: &api.PayloadCommitVerification{ Verified: false, @@ -204,7 +204,7 @@ func TestAPICreateFile(t *testing.T) { assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA) assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL) assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL) - assert.EqualValues(t, createFileOptions.Message, fileResponse.Commit.Message) + assert.EqualValues(t, createFileOptions.Message+"\n", fileResponse.Commit.Message) // Test creating a file without a message createFileOptions = getCreateFileOptions() @@ -215,7 +215,7 @@ func TestAPICreateFile(t *testing.T) { req = NewRequestWithJSON(t, "POST", url, &createFileOptions) resp = session.MakeRequest(t, req, http.StatusCreated) DecodeJSON(t, resp, &fileResponse) - expectedMessage := "Add '" + treePath + "'" + expectedMessage := "Add '" + treePath + "'\n" assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message) // Test trying to create a file that already exists, should fail diff --git a/tests/integration/api_repo_file_delete_test.go b/tests/integration/api_repo_file_delete_test.go index 821b8850bb114..2c8b1e381f7c5 100644 --- a/tests/integration/api_repo_file_delete_test.go +++ b/tests/integration/api_repo_file_delete_test.go @@ -88,7 +88,7 @@ func TestAPIDeleteFile(t *testing.T) { DecodeJSON(t, resp, &fileResponse) assert.NotNil(t, fileResponse) assert.Nil(t, fileResponse.Content) - assert.EqualValues(t, deleteFileOptions.Message, fileResponse.Commit.Message) + assert.EqualValues(t, deleteFileOptions.Message+"\n", fileResponse.Commit.Message) // Test deleting file without a message fileID++ @@ -100,7 +100,7 @@ func TestAPIDeleteFile(t *testing.T) { req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fileResponse) - expectedMessage := "Delete '" + treePath + "'" + expectedMessage := "Delete '" + treePath + "'\n" assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message) // Test deleting a file with the wrong SHA diff --git a/tests/integration/api_repo_file_update_test.go b/tests/integration/api_repo_file_update_test.go index 09a9fac6aa765..a3be67ad844f4 100644 --- a/tests/integration/api_repo_file_update_test.go +++ b/tests/integration/api_repo_file_update_test.go @@ -94,7 +94,7 @@ func getExpectedFileResponseForUpdate(commitID, treePath, lastCommitSHA string) Email: "annedoe@example.com", }, }, - Message: "My update of README.md", + Message: "My update of README.md\n", }, Verification: &api.PayloadCommitVerification{ Verified: false, @@ -168,7 +168,7 @@ func TestAPIUpdateFile(t *testing.T) { assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA) assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL) assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL) - assert.EqualValues(t, updateFileOptions.Message, fileResponse.Commit.Message) + assert.EqualValues(t, updateFileOptions.Message+"\n", fileResponse.Commit.Message) // Test updating a file and renaming it updateFileOptions = getUpdateFileOptions() @@ -200,7 +200,7 @@ func TestAPIUpdateFile(t *testing.T) { req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions) resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fileResponse) - expectedMessage := "Update '" + treePath + "'" + expectedMessage := "Update '" + treePath + "'\n" assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message) // Test updating a file with the wrong SHA diff --git a/tests/integration/api_wiki_test.go b/tests/integration/api_wiki_test.go index aea99dc6ffa3b..c6f4841d082ef 100644 --- a/tests/integration/api_wiki_test.go +++ b/tests/integration/api_wiki_test.go @@ -50,7 +50,7 @@ func TestAPIGetWikiPage(t *testing.T) { }, Date: "2017-11-27T04:31:18Z", }, - Message: "Add Home.md", + Message: "Add Home.md\n", }, }, ContentBase64: base64.RawStdEncoding.EncodeToString( @@ -97,7 +97,7 @@ func TestAPIListWikiPages(t *testing.T) { }, Date: "2017-11-27T04:31:18Z", }, - Message: "Add Home.md", + Message: "Add Home.md\n", }, }, { @@ -120,7 +120,7 @@ func TestAPIListWikiPages(t *testing.T) { }, Date: "2019-01-25T01:41:55Z", }, - Message: "Add jpeg.jpg and page with image", + Message: "Add jpeg.jpg and page with image\n", }, }, { @@ -143,7 +143,7 @@ func TestAPIListWikiPages(t *testing.T) { }, Date: "2019-01-25T01:39:51Z", }, - Message: "Add page with spaced name", + Message: "Add page with spaced name\n", }, }, { @@ -166,7 +166,7 @@ func TestAPIListWikiPages(t *testing.T) { }, Date: "2021-07-19T16:42:46Z", }, - Message: "add unescaped file", + Message: "add unescaped file\n", }, }, } @@ -242,7 +242,7 @@ func TestAPIListPageRevisions(t *testing.T) { }, Date: "2017-11-27T04:31:18Z", }, - Message: "Add Home.md", + Message: "Add Home.md\n", }, }, Count: 1, diff --git a/tests/integration/repofiles_delete_test.go b/tests/integration/repofiles_delete_test.go index 0efd0d849cd73..f594efdeeb58f 100644 --- a/tests/integration/repofiles_delete_test.go +++ b/tests/integration/repofiles_delete_test.go @@ -51,7 +51,7 @@ func getExpectedDeleteFileResponse(u *url.URL) *api.FileResponse { Email: "bob@smith.com", }, }, - Message: "Deletes README.md", + Message: "Deletes README.md\n", }, Verification: &api.PayloadCommitVerification{ Verified: false,