From b4f1c36d0eb125fb11edbaa7aa246dfd9cfe92b0 Mon Sep 17 00:00:00 2001 From: CaiCandong <1290147055@qq.com> Date: Tue, 22 Aug 2023 21:23:35 +0800 Subject: [PATCH 01/18] fix verifyCommits error when push a new branch --- routers/private/hook_verification.go | 37 ++++++++++++++++------------ 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/routers/private/hook_verification.go b/routers/private/hook_verification.go index caf3874ec3030..cce611fc29b8c 100644 --- a/routers/private/hook_verification.go +++ b/routers/private/hook_verification.go @@ -28,23 +28,28 @@ func verifyCommits(oldCommitID, newCommitID string, repo *git.Repository, env [] _ = stdoutWriter.Close() }() + var command *git.Command + if oldCommitID == git.EmptySHA { + command = git.NewCommand(repo.Ctx, "rev-list").AddDynamicArguments(newCommitID).AddArguments("--not", "--all") + } else { + command = git.NewCommand(repo.Ctx, "rev-list").AddDynamicArguments(oldCommitID + "..." + newCommitID) + } // This is safe as force pushes are already forbidden - err = git.NewCommand(repo.Ctx, "rev-list").AddDynamicArguments(oldCommitID + "..." + newCommitID). - Run(&git.RunOpts{ - Env: env, - Dir: repo.Path, - Stdout: stdoutWriter, - PipelineFunc: func(ctx context.Context, cancel context.CancelFunc) error { - _ = stdoutWriter.Close() - err := readAndVerifyCommitsFromShaReader(stdoutReader, repo, env) - if err != nil { - log.Error("%v", err) - cancel() - } - _ = stdoutReader.Close() - return err - }, - }) + err = command.Run(&git.RunOpts{ + Env: env, + Dir: repo.Path, + Stdout: stdoutWriter, + PipelineFunc: func(ctx context.Context, cancel context.CancelFunc) error { + _ = stdoutWriter.Close() + err := readAndVerifyCommitsFromShaReader(stdoutReader, repo, env) + if err != nil { + log.Error("%v", err) + cancel() + } + _ = stdoutReader.Close() + return err + }, + }) if err != nil && !isErrUnverifiedCommit(err) { log.Error("Unable to check commits from %s to %s in %s: %v", oldCommitID, newCommitID, repo.Path, err) } From ff50ea9ed456431d78916fb5fc3d9adec767eedc Mon Sep 17 00:00:00 2001 From: CaiCandong <50507092+CaiCandong@users.noreply.github.com> Date: Tue, 22 Aug 2023 22:06:50 +0800 Subject: [PATCH 02/18] add some comments Co-authored-by: wxiaoguang --- routers/private/hook_verification.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/routers/private/hook_verification.go b/routers/private/hook_verification.go index cce611fc29b8c..8604789529a6e 100644 --- a/routers/private/hook_verification.go +++ b/routers/private/hook_verification.go @@ -30,6 +30,9 @@ func verifyCommits(oldCommitID, newCommitID string, repo *git.Repository, env [] var command *git.Command if oldCommitID == git.EmptySHA { + // When creating a new branch, the oldCommitID is empty, by using "newCommitID --not --all": + // List commits that are reachable by following the newCommitID, exclude "all" existing heads/tags commits + // So, it only lists the new commits received, doesn't list the commits already present in the receiving repository command = git.NewCommand(repo.Ctx, "rev-list").AddDynamicArguments(newCommitID).AddArguments("--not", "--all") } else { command = git.NewCommand(repo.Ctx, "rev-list").AddDynamicArguments(oldCommitID + "..." + newCommitID) From de982aa0a8329176dd838fcc14751579c18c0e57 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 23 Aug 2023 23:14:22 +0800 Subject: [PATCH 03/18] Add test --- routers/private/hook_verification_test.go | 25 +++++++++++++++++++++++ routers/private/main_test.go | 17 +++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 routers/private/hook_verification_test.go create mode 100644 routers/private/main_test.go diff --git a/routers/private/hook_verification_test.go b/routers/private/hook_verification_test.go new file mode 100644 index 0000000000000..ebd67499e8d1e --- /dev/null +++ b/routers/private/hook_verification_test.go @@ -0,0 +1,25 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package private + +import ( + "context" + "testing" + + "code.gitea.io/gitea/models/unittest" + "code.gitea.io/gitea/modules/git" + + "github.com/stretchr/testify/assert" +) + +func TestVerifyCommits(t *testing.T) { + unittest.PrepareTestEnv(t) + + gitRepo, err := git.OpenRepository(context.Background(), ".") + assert.NoError(t, err) + defer gitRepo.Close() + + err = verifyCommits(git.EmptySHA, "9c5c60143975a120bf70ac4aed34bf903ef19db6", gitRepo, nil) + assert.NoError(t, err) +} diff --git a/routers/private/main_test.go b/routers/private/main_test.go new file mode 100644 index 0000000000000..700af6ec8d413 --- /dev/null +++ b/routers/private/main_test.go @@ -0,0 +1,17 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package private + +import ( + "path/filepath" + "testing" + + "code.gitea.io/gitea/models/unittest" +) + +func TestMain(m *testing.M) { + unittest.MainTest(m, &unittest.TestOptions{ + GiteaRootPath: filepath.Join("..", ".."), + }) +} From 98eab3af0324bf629b534c8b8dd041f78b7f0363 Mon Sep 17 00:00:00 2001 From: CaiCandong <1290147055@qq.com> Date: Fri, 25 Aug 2023 11:00:38 +0800 Subject: [PATCH 04/18] mock database --- models/fixtures/email_address.yml | 10 +++++++++- models/fixtures/gpg_key.yml | 24 +++++++++++++++++++++++- models/fixtures/user.yml | 4 ++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/models/fixtures/email_address.yml b/models/fixtures/email_address.yml index e7df5fdc5f01c..898735ed95f37 100644 --- a/models/fixtures/email_address.yml +++ b/models/fixtures/email_address.yml @@ -276,4 +276,12 @@ email: user2-2@example.com lower_email: user2-2@example.com is_activated: false - is_primary: false \ No newline at end of file + is_primary: false + +- + id: 36 + uid: 36 + email: 1290147055@qq.com + lower_email: 1290147055@qq.com + is_activated: true + is_primary: false diff --git a/models/fixtures/gpg_key.yml b/models/fixtures/gpg_key.yml index ca780a73aa0c1..1253e779b3800 100644 --- a/models/fixtures/gpg_key.yml +++ b/models/fixtures/gpg_key.yml @@ -1 +1,23 @@ -[] # empty +- + id: 1 + owner_id: 36 + key_id: 2ECAAA351B755A40 + primary_key_id: + content: xsDNBGTjB1cBDACv7YEaiA5VaoTBR0fcPRy+RHgTd88ALhklVVd54lbMKWwsHa3Ms9sCYbq8chly4g50l45o8qL0mu+zkZDvrU3EsZAwFwv/6iKltQXRIQ7j0uNKIyJi/+yyMiRJtU24ptAkc+bHhb2wi7cnJtldGyDZIoymzotTdpJupmjVFXqQtbeqMHpSKg6JdyGLK+wX+ITD7gZ6UddPPbw5Yo6N5b56w55cSIG6cDtafo+/Fc4WF0jdDDmCEyPlr3afDKEcpmnDSJsMhm7/eZ5MRn2dh9+brnEFyxkKSJYfI7ptA6trAs+DCil9FgZbXM9P/c0joVUzi1lSGSu1ryav9eAb4J5lgzl2Tad338+cVWuCHR6yTbq4qZcfgNVnFK1WMUrg9MF2A8wNLO1O9LSQpXwDSBmnM9W7TcTE6bpxbADVH7WEScCNmExKeqUnvvypaeiwmwz7Jqh/V5NhjE3ySgo3j/oBFFUp2SSkZhk7p0uP8mDLSdfPLxtBUv3EQAPs8CCD7WkAEQEAAQ== + verified: true + can_sign: true + can_encrypt_comms: true + can_encrypt_storage: true + can_certify: true + +- + id: 2 + owner_id: 36 + key_id: 2FCCED20E8714BAA + primary_key_id: 2ECAAA351B755A40 + content: zsDNBGTjB1cBDADm2EFZ6SzUoF5We4kQBaLYtkFNRA2yQafbu+W/AYOITgxye2xDKVcMaopV6B+vPXKyIshakWkdpK8Xw5dZGI0loOm5PXFJDI6lzWWUy76J3SevenCXzxWOCXZOtI25Zpev/b96Cu7xsRdcL6eYpGRNwVJ3bW3AhD5z2AU0z05VYKrNIzs5e7PfO9g7uGQ5DuejLr6Wp9+zHfp6ppHkHFET7x0ZrNE+hH1hPAK0yFQ75iU4zvNXxa2PKgfSBkEADre+EV0+BxlRB9c9jkLWKa/Xa4ecaiFgH/ler12gr8/NOCJww+bLQapJBTKSGycupANwIZb1lgna1r09P6PCp25MBrvVWfD9qzvVmFxpM+e8/y9D3RcJkHwJjQ9SaX/gNq/nFdvVsLpIMGGQY0KDMeJW/XkwhGNZ/tuztLgqSIcbNuVZMooOwgAT9r1Z1XpKuuh+mNTwwzEzvV5Qo6Kd/9/zPqJmoniziNxyzfEQ82HhOMZg3CJVGenPPhIHXCJAO3kAEQEAAQ== + verified: true + can_sign: true + can_encrypt_comms: true + can_encrypt_storage: true + can_certify: true diff --git a/models/fixtures/user.yml b/models/fixtures/user.yml index c7c5c024be89a..20a56e76f4e2e 100644 --- a/models/fixtures/user.yml +++ b/models/fixtures/user.yml @@ -1301,7 +1301,7 @@ lower_name: limited_org36 name: limited_org36 full_name: Limited Org 36 - email: limited_org36@example.com + email: 1290147055@qq.com keep_email_private: false email_notifications_preference: enabled passwd: ZogKvWdyEx:password @@ -1320,7 +1320,7 @@ allow_create_organization: true prohibit_login: false avatar: avatar22 - avatar_email: limited_org36@example.com + avatar_email: 1290147055@qq.com use_custom_avatar: false num_followers: 0 num_following: 0 From 4191603042c2ca6d028fc916c48fce7dba9a64c7 Mon Sep 17 00:00:00 2001 From: CaiCandong <1290147055@qq.com> Date: Fri, 25 Aug 2023 11:02:05 +0800 Subject: [PATCH 05/18] mock repo --- .../tests/repos/repo1_hook_verification/HEAD | 1 + .../tests/repos/repo1_hook_verification/config | 6 ++++++ .../repos/repo1_hook_verification/description | 1 + .../repo1_hook_verification/git-daemon-export-ok | 0 .../repos/repo1_hook_verification/info/exclude | 6 ++++++ .../tests/repos/repo1_hook_verification/info/refs | 1 + .../tests/repos/repo1_hook_verification/logs/HEAD | 2 ++ .../repo1_hook_verification/logs/refs/heads/main | 2 ++ .../11/28cd8e82948ea10b4932b2481210610604ce7e | Bin 0 -> 155 bytes .../2b/df04adb23d2b40b6085efb230856e5e2a775b7 | Bin 0 -> 55 bytes .../45/1c1608ab9c5277fdc73ea68aea711c046ac7ac | Bin 0 -> 708 bytes .../64/e643f86a640d97f95820b43aeb28631042c629 | Bin 0 -> 711 bytes .../65/a457425a679cbe9adf0d2741785d3ceabb44a7 | Bin 0 -> 50 bytes .../7d/92f8f0cf7b989acf2c56a9a4387f5b39a92c41 | 1 + .../99/ff046fbdf6eed4ae4349f9181ff42b340a4582 | Bin 0 -> 82 bytes .../c6/6377c623ba4a70ee872b64fbac7a3f27a32ef6 | Bin 0 -> 81 bytes .../c8/871c5132e62a637e2afada08acd41146662bed | Bin 0 -> 24 bytes .../d1/b459fc1811eb7b30b2e14acaccb853f5d1b3e2 | Bin 0 -> 27 bytes .../e0/5ec071e40a53cd4785345a99fd12f5dbb6a777 | Bin 0 -> 143 bytes .../e3/7e5d19823e42fad252f6341b1f77a7bc6ee451 | Bin 0 -> 59 bytes .../e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 | Bin 0 -> 15 bytes .../repo1_hook_verification/objects/info/packs | 1 + .../repos/repo1_hook_verification/refs/heads/main | 1 + 23 files changed, 22 insertions(+) create mode 100644 routers/private/tests/repos/repo1_hook_verification/HEAD create mode 100644 routers/private/tests/repos/repo1_hook_verification/config create mode 100644 routers/private/tests/repos/repo1_hook_verification/description create mode 100644 routers/private/tests/repos/repo1_hook_verification/git-daemon-export-ok create mode 100644 routers/private/tests/repos/repo1_hook_verification/info/exclude create mode 100644 routers/private/tests/repos/repo1_hook_verification/info/refs create mode 100644 routers/private/tests/repos/repo1_hook_verification/logs/HEAD create mode 100644 routers/private/tests/repos/repo1_hook_verification/logs/refs/heads/main create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/11/28cd8e82948ea10b4932b2481210610604ce7e create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/2b/df04adb23d2b40b6085efb230856e5e2a775b7 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/45/1c1608ab9c5277fdc73ea68aea711c046ac7ac create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/64/e643f86a640d97f95820b43aeb28631042c629 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/7d/92f8f0cf7b989acf2c56a9a4387f5b39a92c41 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/99/ff046fbdf6eed4ae4349f9181ff42b340a4582 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/c6/6377c623ba4a70ee872b64fbac7a3f27a32ef6 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/c8/871c5132e62a637e2afada08acd41146662bed create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/d1/b459fc1811eb7b30b2e14acaccb853f5d1b3e2 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/e0/5ec071e40a53cd4785345a99fd12f5dbb6a777 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/e3/7e5d19823e42fad252f6341b1f77a7bc6ee451 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/info/packs create mode 100644 routers/private/tests/repos/repo1_hook_verification/refs/heads/main diff --git a/routers/private/tests/repos/repo1_hook_verification/HEAD b/routers/private/tests/repos/repo1_hook_verification/HEAD new file mode 100644 index 0000000000000..b870d82622c1a --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/HEAD @@ -0,0 +1 @@ +ref: refs/heads/main diff --git a/routers/private/tests/repos/repo1_hook_verification/config b/routers/private/tests/repos/repo1_hook_verification/config new file mode 100644 index 0000000000000..64280b806c976 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/config @@ -0,0 +1,6 @@ +[core] + repositoryformatversion = 0 + filemode = false + bare = true + symlinks = false + ignorecase = true diff --git a/routers/private/tests/repos/repo1_hook_verification/description b/routers/private/tests/repos/repo1_hook_verification/description new file mode 100644 index 0000000000000..498b267a8c781 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/routers/private/tests/repos/repo1_hook_verification/git-daemon-export-ok b/routers/private/tests/repos/repo1_hook_verification/git-daemon-export-ok new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/routers/private/tests/repos/repo1_hook_verification/info/exclude b/routers/private/tests/repos/repo1_hook_verification/info/exclude new file mode 100644 index 0000000000000..a5196d1be8fb5 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/info/exclude @@ -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] +# *~ diff --git a/routers/private/tests/repos/repo1_hook_verification/info/refs b/routers/private/tests/repos/repo1_hook_verification/info/refs new file mode 100644 index 0000000000000..e04c2535a091f --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/info/refs @@ -0,0 +1 @@ +64e643f86a640d97f95820b43aeb28631042c629 refs/heads/main diff --git a/routers/private/tests/repos/repo1_hook_verification/logs/HEAD b/routers/private/tests/repos/repo1_hook_verification/logs/HEAD new file mode 100644 index 0000000000000..a032573e1296d --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 7d92f8f0cf7b989acf2c56a9a4387f5b39a92c41 Gitea 1692868984 +0800 push +7d92f8f0cf7b989acf2c56a9a4387f5b39a92c41 64e643f86a640d97f95820b43aeb28631042c629 Gitea 1692869253 +0800 push diff --git a/routers/private/tests/repos/repo1_hook_verification/logs/refs/heads/main b/routers/private/tests/repos/repo1_hook_verification/logs/refs/heads/main new file mode 100644 index 0000000000000..a032573e1296d --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/logs/refs/heads/main @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 7d92f8f0cf7b989acf2c56a9a4387f5b39a92c41 Gitea 1692868984 +0800 push +7d92f8f0cf7b989acf2c56a9a4387f5b39a92c41 64e643f86a640d97f95820b43aeb28631042c629 Gitea 1692869253 +0800 push diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/11/28cd8e82948ea10b4932b2481210610604ce7e b/routers/private/tests/repos/repo1_hook_verification/objects/11/28cd8e82948ea10b4932b2481210610604ce7e new file mode 100644 index 0000000000000000000000000000000000000000..52e0c35d87c6ba3bd4a69fb58ceece5c82e55991 GIT binary patch literal 155 zcmV;M0A&Ao0hNwH3d0}}0DJZo-V0^bb>l)Qg}g-LZkt1rMoiz|e4*DF24>opW$xBH zzVs$ynNxj>aLyGna3Ba86{Oj_6X^!zS{Zd(;L77(nW)Iw6Drffop2$qmRr2>Z_C>zlUMUh0Dn zmTcLQlcuWj5lE2xW$Xz72|}zOBnYx`#6<#4h$z4qacLYSLd2%#1nZ<9(t46B=ga zKg3sorj

YRkIUGK?-s;@W2a(ySeW94vP&uM<;|>Dt#z$lg}-nJWx?pg;jlTfUBE z!Bu2QNSjow=`y0c9E!@<$+yUiYaT(bAC6b!p)xNg3lSLQj4R zlHFJCP^j*3*BWlRFs;4Ob>F4eFwyl#Y+q@;^Opebe{TJv;LnQWWLS(zW~9uTB0LTk z3qJRgQII5pez~7huN=h5kdNOkI#&*#|5SeTdUItKlDS_g5TDEQK6`JkXr6X@x1Q>; z8u)LX+ho4HZQWkTokQqZ#{oO%o4P#9OR-%`r}i`2;E+#&dB982L@%<-x&00GnPNZQ qL*2GP&e0GK!SeM*fv-Yu0_xv?D%SD8-bu}*&(oYdslNaLlpr=CWM`WI literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/64/e643f86a640d97f95820b43aeb28631042c629 b/routers/private/tests/repos/repo1_hook_verification/objects/64/e643f86a640d97f95820b43aeb28631042c629 new file mode 100644 index 0000000000000000000000000000000000000000..20a49d6d46aead6f32569dacb7c1dabff2d10815 GIT binary patch literal 711 zcmV;&0yzD60hN-;&Z9;EgmdO8`fg$XcmKi!0fi4ew^ewmno?( zC6!eARJd>3dIkuxf6QZ1fP&@=Hm8sP>4Je}nnMqj7^wUl;w-&No*3L=tXc#>uR z8HOLYZ~q1qhoJB=GhEzBIPW@=+P#F^GK7Q5BwI?a#*3P^;55;r1Q&NQa0=GQhU&-q9IUUKh_p`nWpoO3DAER3TfJk*yUo@aYEhb teB6=S%|4Qbzh6$`*B1f4r07Ty|Nm2Q!������[�,fd2$��n`�zԃ��ۺ.�b����Zd���0N��$�:plPR,1Gs+�n�*���z(4��c��Sɹ��J��My�߶�sY�e��]��� �G ��ߏs[Oօ�)��~B0�}]�7M�|�ݘ�r�T�����0O��N� \ No newline at end of file diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/99/ff046fbdf6eed4ae4349f9181ff42b340a4582 b/routers/private/tests/repos/repo1_hook_verification/objects/99/ff046fbdf6eed4ae4349f9181ff42b340a4582 new file mode 100644 index 0000000000000000000000000000000000000000..a61154c7b5976d37587a964bb102f7ffb793548e GIT binary patch literal 82 zcmV-Y0ImOc0V^p=O;xb8WH2-^Ff%bxNYpE-C}Fs`CGwAi;OlCGO%J_Jo!Jrm_2TA7 oPz6a~1<&R_n!V}bHD~W`&2{BbHx51N37!a5kc?9S0Ce;)g40MPHUIzs literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/c6/6377c623ba4a70ee872b64fbac7a3f27a32ef6 b/routers/private/tests/repos/repo1_hook_verification/objects/c6/6377c623ba4a70ee872b64fbac7a3f27a32ef6 new file mode 100644 index 0000000000000000000000000000000000000000..7dcb793528bad47cd563677c4e3cf140f4523c70 GIT binary patch literal 81 zcmV-X0IvUd0V^p=O;xb8WH2-^Ff%bxNYpE-C}B9!E)!_(?!gHCF`P(zM?~ n6(oTbJe&Jy_NI&1oV~j>*Of=zIP|0^cp_9mGEM~mhF~p9Jj)^x literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/c8/871c5132e62a637e2afada08acd41146662bed b/routers/private/tests/repos/repo1_hook_verification/objects/c8/871c5132e62a637e2afada08acd41146662bed new file mode 100644 index 0000000000000000000000000000000000000000..c51305a9e48394e10fe4240a106b9632eab7fa8e GIT binary patch literal 24 fcmb}frnHcPY*0Amp^*tr7krWywk+gBaCr2?ultu|-F;r5LJ}%1SJMRDh literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/e3/7e5d19823e42fad252f6341b1f77a7bc6ee451 b/routers/private/tests/repos/repo1_hook_verification/objects/e3/7e5d19823e42fad252f6341b1f77a7bc6ee451 new file mode 100644 index 0000000000000000000000000000000000000000..b3f925e8178ae2e9412790904043936967b15dcd GIT binary patch literal 59 zcmV-B0L1@z0V^p=O;xb8WH2-^Ff%bxNYpE-C}DUu_tET47q2;ccWbUIkGgT_Nl)-Z RsDdOy3X*Xu003m3Fc_uO7S{j( literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 b/routers/private/tests/repos/repo1_hook_verification/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 new file mode 100644 index 0000000000000000000000000000000000000000..711223894375fe1186ac5bfffdc48fb1fa1e65cc GIT binary patch literal 15 Wcmb Date: Fri, 25 Aug 2023 11:02:24 +0800 Subject: [PATCH 06/18] add test --- routers/private/hook_verification_test.go | 29 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/routers/private/hook_verification_test.go b/routers/private/hook_verification_test.go index ebd67499e8d1e..2f1c2df1a6082 100644 --- a/routers/private/hook_verification_test.go +++ b/routers/private/hook_verification_test.go @@ -4,22 +4,41 @@ package private import ( + "code.gitea.io/gitea/models/unittest" "context" "testing" - "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/git" "github.com/stretchr/testify/assert" ) +var ( + testReposDir = "tests/repos/" +) + func TestVerifyCommits(t *testing.T) { unittest.PrepareTestEnv(t) - gitRepo, err := git.OpenRepository(context.Background(), ".") + gitRepo, err := git.OpenRepository(context.Background(), testReposDir+"repo1_hook_verification") assert.NoError(t, err) - defer gitRepo.Close() - err = verifyCommits(git.EmptySHA, "9c5c60143975a120bf70ac4aed34bf903ef19db6", gitRepo, nil) - assert.NoError(t, err) + testCases := []struct { + base, head string + verified bool + }{ + {"7d92f8f0cf7b989acf2c56a9a4387f5b39a92c41", "64e643f86a640d97f95820b43aeb28631042c629", true}, + {git.EmptySHA, "451c1608ab9c5277fdc73ea68aea711c046ac7ac", true}, // New branch with verified commit + {"e05ec071e40a53cd4785345a99fd12f5dbb6a777", "7d92f8f0cf7b989acf2c56a9a4387f5b39a92c41", false}, + {git.EmptySHA, "1128cd8e82948ea10b4932b2481210610604ce7e", false}, // New branch with unverified commit + } + + for _, tc := range testCases { + err = verifyCommits(tc.base, tc.head, gitRepo, nil) + if tc.verified { + assert.NoError(t, err) + } else { + assert.Error(t, err) + } + } } From 2a5c7798c08a828d0624dad45883eaf96a34ccb8 Mon Sep 17 00:00:00 2001 From: CaiCandong <1290147055@qq.com> Date: Fri, 25 Aug 2023 11:15:32 +0800 Subject: [PATCH 07/18] fix lint --- routers/private/hook_verification_test.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/routers/private/hook_verification_test.go b/routers/private/hook_verification_test.go index 2f1c2df1a6082..79f505bea5dab 100644 --- a/routers/private/hook_verification_test.go +++ b/routers/private/hook_verification_test.go @@ -4,18 +4,16 @@ package private import ( - "code.gitea.io/gitea/models/unittest" "context" "testing" + "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/git" "github.com/stretchr/testify/assert" ) -var ( - testReposDir = "tests/repos/" -) +var testReposDir = "tests/repos/" func TestVerifyCommits(t *testing.T) { unittest.PrepareTestEnv(t) From a83d437ba7fd9b531f7a65ae61a44bb2d52f803c Mon Sep 17 00:00:00 2001 From: CaiCandong <1290147055@qq.com> Date: Fri, 25 Aug 2023 13:07:55 +0800 Subject: [PATCH 08/18] fix gpp_key test --- models/fixtures/gpg_key.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/fixtures/gpg_key.yml b/models/fixtures/gpg_key.yml index 1253e779b3800..9acd4c6770ee9 100644 --- a/models/fixtures/gpg_key.yml +++ b/models/fixtures/gpg_key.yml @@ -1,5 +1,5 @@ - - id: 1 + id: 5 owner_id: 36 key_id: 2ECAAA351B755A40 primary_key_id: @@ -11,7 +11,7 @@ can_certify: true - - id: 2 + id: 6 owner_id: 36 key_id: 2FCCED20E8714BAA primary_key_id: 2ECAAA351B755A40 From a37097b461e45692f075f9194c8e920a3daa9d80 Mon Sep 17 00:00:00 2001 From: CaiCandong <1290147055@qq.com> Date: Fri, 25 Aug 2023 13:33:53 +0800 Subject: [PATCH 09/18] fix gitRepo.Close --- routers/private/hook_verification_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/private/hook_verification_test.go b/routers/private/hook_verification_test.go index 79f505bea5dab..173b32996cb87 100644 --- a/routers/private/hook_verification_test.go +++ b/routers/private/hook_verification_test.go @@ -19,6 +19,7 @@ func TestVerifyCommits(t *testing.T) { unittest.PrepareTestEnv(t) gitRepo, err := git.OpenRepository(context.Background(), testReposDir+"repo1_hook_verification") + defer gitRepo.Close() assert.NoError(t, err) testCases := []struct { From 93b38955cb42e8aecc3c59c3740842972e16320d Mon Sep 17 00:00:00 2001 From: chenyaoran <1290147055@qq.com> Date: Sun, 27 Aug 2023 23:27:42 +0800 Subject: [PATCH 10/18] mock repo --- .../hooks/applypatch-msg.sample | 15 ++ .../hooks/commit-msg.sample | 24 +++ .../hooks/fsmonitor-watchman.sample | 174 ++++++++++++++++++ .../hooks/post-receive | 16 ++ .../hooks/post-receive.d/gitea | 3 + .../hooks/post-update.sample | 8 + .../hooks/pre-applypatch.sample | 14 ++ .../hooks/pre-commit.sample | 49 +++++ .../hooks/pre-merge-commit.sample | 13 ++ .../hooks/pre-push.sample | 53 ++++++ .../hooks/pre-rebase.sample | 169 +++++++++++++++++ .../repo1_hook_verification/hooks/pre-receive | 16 ++ .../hooks/pre-receive.d/gitea | 3 + .../hooks/pre-receive.sample | 24 +++ .../hooks/prepare-commit-msg.sample | 42 +++++ .../hooks/proc-receive | 3 + .../hooks/proc-receive.d/gitea | 0 .../hooks/push-to-checkout.sample | 78 ++++++++ .../hooks/sendemail-validate.sample | 77 ++++++++ .../repo1_hook_verification/hooks/update | 15 ++ .../hooks/update.d/gitea | 3 + .../hooks/update.sample | 128 +++++++++++++ .../repos/repo1_hook_verification/info/refs | 2 +- .../repos/repo1_hook_verification/logs/HEAD | 3 +- .../logs/refs/heads/main | 3 +- .../08/cbc8f0e903b0916025ae7577564b7ed39ecb2c | Bin 0 -> 86 bytes .../0b/5987362fe3fabdd4406babdc819642ee2f5a2a | Bin 0 -> 22 bytes .../11/28cd8e82948ea10b4932b2481210610604ce7e | Bin 155 -> 0 bytes .../13/b0f23f673b161f4b5cb66f051cb93c99729e1e | Bin 0 -> 86 bytes .../23/33a51fdb238b7023a62ae3dcc58994061a7c86 | Bin 0 -> 86 bytes .../45/1c1608ab9c5277fdc73ea68aea711c046ac7ac | Bin 708 -> 0 bytes .../64/e643f86a640d97f95820b43aeb28631042c629 | Bin 711 -> 0 bytes .../72/920278f2f999e3005801e5d5b8ab8139d3641c | 2 + .../7d/92f8f0cf7b989acf2c56a9a4387f5b39a92c41 | 1 - .../8b/903ede7c494725624bf842ec890f6342dababd | Bin 0 -> 86 bytes .../93/eac826f6188f34646cea81bf426aa5ba7d3bfe | Bin 0 -> 684 bytes .../97/79d17a04f1e2640583d35703c62460b2d86e0a | 2 + .../99/ff046fbdf6eed4ae4349f9181ff42b340a4582 | Bin 82 -> 0 bytes .../9c/e3f779ae33f31fce17fac3c512047b75d7498b | Bin 0 -> 153 bytes .../a9/f76e70a663e40091749a97eeac5f57a6fec141 | Bin 0 -> 24 bytes .../ba/0caedd359ebe310ef431335576e20f2b84e9b9 | Bin 0 -> 63 bytes .../bb/87653e0819460e79b5f075f2563f583cbbf18c | Bin 0 -> 682 bytes .../c6/6377c623ba4a70ee872b64fbac7a3f27a32ef6 | Bin 81 -> 0 bytes .../c8/871c5132e62a637e2afada08acd41146662bed | Bin 24 -> 0 bytes .../cb/a4c30c196a0e03e7bdf6eeb8393d14b9d073aa | 3 + .../d1/b459fc1811eb7b30b2e14acaccb853f5d1b3e2 | Bin 27 -> 0 bytes .../d7/66f2917716d45be24bfa968b8409544941be32 | 3 + .../e0/5ec071e40a53cd4785345a99fd12f5dbb6a777 | Bin 143 -> 0 bytes .../e8/4e452c3a20c02dee17ec2f63c0cb9ef6c759eb | Bin 0 -> 677 bytes .../08/cbc8f0e903b0916025ae7577564b7ed39ecb2c | Bin 0 -> 86 bytes .../0b/5987362fe3fabdd4406babdc819642ee2f5a2a | Bin 0 -> 22 bytes .../13/b0f23f673b161f4b5cb66f051cb93c99729e1e | Bin 0 -> 86 bytes .../23/33a51fdb238b7023a62ae3dcc58994061a7c86 | Bin 0 -> 86 bytes .../8b/903ede7c494725624bf842ec890f6342dababd | Bin 0 -> 86 bytes .../93/eac826f6188f34646cea81bf426aa5ba7d3bfe | Bin 0 -> 684 bytes .../9c/e3f779ae33f31fce17fac3c512047b75d7498b | Bin 0 -> 153 bytes .../a9/f76e70a663e40091749a97eeac5f57a6fec141 | Bin 0 -> 24 bytes .../bb/87653e0819460e79b5f075f2563f583cbbf18c | Bin 0 -> 682 bytes .../cb/a4c30c196a0e03e7bdf6eeb8393d14b9d073aa | 3 + .../repo1_hook_verification/refs/heads/main | 2 +- 60 files changed, 944 insertions(+), 7 deletions(-) create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/applypatch-msg.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/commit-msg.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/fsmonitor-watchman.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/post-receive create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/post-receive.d/gitea create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/post-update.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-applypatch.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-commit.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-merge-commit.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-push.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-rebase.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.d/gitea create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/prepare-commit-msg.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive.d/gitea create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/push-to-checkout.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/sendemail-validate.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/update create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/update.d/gitea create mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/update.sample create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/08/cbc8f0e903b0916025ae7577564b7ed39ecb2c create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/0b/5987362fe3fabdd4406babdc819642ee2f5a2a delete mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/11/28cd8e82948ea10b4932b2481210610604ce7e create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/13/b0f23f673b161f4b5cb66f051cb93c99729e1e create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/23/33a51fdb238b7023a62ae3dcc58994061a7c86 delete mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/45/1c1608ab9c5277fdc73ea68aea711c046ac7ac delete mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/64/e643f86a640d97f95820b43aeb28631042c629 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/72/920278f2f999e3005801e5d5b8ab8139d3641c delete mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/7d/92f8f0cf7b989acf2c56a9a4387f5b39a92c41 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/8b/903ede7c494725624bf842ec890f6342dababd create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/93/eac826f6188f34646cea81bf426aa5ba7d3bfe create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/97/79d17a04f1e2640583d35703c62460b2d86e0a delete mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/99/ff046fbdf6eed4ae4349f9181ff42b340a4582 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/9c/e3f779ae33f31fce17fac3c512047b75d7498b create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/a9/f76e70a663e40091749a97eeac5f57a6fec141 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/ba/0caedd359ebe310ef431335576e20f2b84e9b9 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/bb/87653e0819460e79b5f075f2563f583cbbf18c delete mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/c6/6377c623ba4a70ee872b64fbac7a3f27a32ef6 delete mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/c8/871c5132e62a637e2afada08acd41146662bed create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/cb/a4c30c196a0e03e7bdf6eeb8393d14b9d073aa delete mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/d1/b459fc1811eb7b30b2e14acaccb853f5d1b3e2 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/d7/66f2917716d45be24bfa968b8409544941be32 delete mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/e0/5ec071e40a53cd4785345a99fd12f5dbb6a777 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/e8/4e452c3a20c02dee17ec2f63c0cb9ef6c759eb create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/08/cbc8f0e903b0916025ae7577564b7ed39ecb2c create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/0b/5987362fe3fabdd4406babdc819642ee2f5a2a create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/13/b0f23f673b161f4b5cb66f051cb93c99729e1e create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/23/33a51fdb238b7023a62ae3dcc58994061a7c86 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/8b/903ede7c494725624bf842ec890f6342dababd create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/93/eac826f6188f34646cea81bf426aa5ba7d3bfe create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/9c/e3f779ae33f31fce17fac3c512047b75d7498b create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/a9/f76e70a663e40091749a97eeac5f57a6fec141 create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/bb/87653e0819460e79b5f075f2563f583cbbf18c create mode 100644 routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/cb/a4c30c196a0e03e7bdf6eeb8393d14b9d073aa diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/applypatch-msg.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/applypatch-msg.sample new file mode 100644 index 0000000000000..a5d7b84a67345 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/commit-msg.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/commit-msg.sample new file mode 100644 index 0000000000000..b58d1184a9d43 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/fsmonitor-watchman.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/fsmonitor-watchman.sample new file mode 100644 index 0000000000000..23e856f5deeb7 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/fsmonitor-watchman.sample @@ -0,0 +1,174 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 2) and last update token +# formatted as a string and outputs to stdout a new update token and +# all files that have been modified since the update token. Paths must +# be relative to the root of the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $last_update_token) = @ARGV; + +# Uncomment for debugging +# print STDERR "$0 $version $last_update_token\n"; + +# Check the hook interface version +if ($version ne 2) { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree = get_working_dir(); + +my $retry = 1; + +my $json_pkg; +eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; +} or do { + require JSON::PP; + $json_pkg = "JSON::PP"; +}; + +launch_watchman(); + +sub launch_watchman { + my $o = watchman_query(); + if (is_work_tree_watched($o)) { + output_result($o->{clock}, @{$o->{files}}); + } +} + +sub output_result { + my ($clockid, @files) = @_; + + # Uncomment for debugging watchman output + # open (my $fh, ">", ".git/watchman-output.out"); + # binmode $fh, ":utf8"; + # print $fh "$clockid\n@files\n"; + # close $fh; + + binmode STDOUT, ":utf8"; + print $clockid; + print "\0"; + local $, = "\0"; + print @files; +} + +sub watchman_clock { + my $response = qx/watchman clock "$git_work_tree"/; + die "Failed to get clock id on '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + return $json_pkg->new->utf8->decode($response); +} + +sub watchman_query { + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $last_update_token but not from the .git folder. + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + my $last_update_line = ""; + if (substr($last_update_token, 0, 1) eq "c") { + $last_update_token = "\"$last_update_token\""; + $last_update_line = qq[\n"since": $last_update_token,]; + } + my $query = <<" END"; + ["query", "$git_work_tree", {$last_update_line + "fields": ["name"], + "expression": ["not", ["dirname", ".git"]] + }] + END + + # Uncomment for debugging the watchman query + # open (my $fh, ">", ".git/watchman-query.json"); + # print $fh $query; + # close $fh; + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + # Uncomment for debugging the watch response + # open ($fh, ">", ".git/watchman-response.json"); + # print $fh $response; + # close $fh; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + return $json_pkg->new->utf8->decode($response); +} + +sub is_work_tree_watched { + my ($output) = @_; + my $error = $output->{error}; + if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) { + $retry--; + my $response = qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + $output = $json_pkg->new->utf8->decode($response); + $error = $output->{error}; + die "Watchman: $error.\n" . + "Falling back to scanning...\n" if $error; + + # Uncomment for debugging watchman output + # open (my $fh, ">", ".git/watchman-output.out"); + # close $fh; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + my $o = watchman_clock(); + $error = $output->{error}; + + die "Watchman: $error.\n" . + "Falling back to scanning...\n" if $error; + + output_result($o->{clock}, ("/")); + $last_update_token = $o->{clock}; + + eval { launch_watchman() }; + return 0; + } + + die "Watchman: $error.\n" . + "Falling back to scanning...\n" if $error; + + return 1; +} + +sub get_working_dir { + my $working_dir; + if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $working_dir = Win32::GetCwd(); + $working_dir =~ tr/\\/\//; + } else { + require Cwd; + $working_dir = Cwd::cwd(); + } + + return $working_dir; +} diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/post-receive b/routers/private/tests/repos/repo1_hook_verification/hooks/post-receive new file mode 100644 index 0000000000000..80ae57095ca0e --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/post-receive @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# AUTO GENERATED BY GITEA, DO NOT MODIFY +data=$(cat) +exitcodes="" +hookname=$(basename $0) +GIT_DIR=${GIT_DIR:-$(dirname $0)/..} + +for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do + test -x "${hook}" && test -f "${hook}" || continue + echo "${data}" | "${hook}" + exitcodes="${exitcodes} $?" +done + +for i in ${exitcodes}; do + [ ${i} -eq 0 ] || exit ${i} +done diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/post-receive.d/gitea b/routers/private/tests/repos/repo1_hook_verification/hooks/post-receive.d/gitea new file mode 100644 index 0000000000000..f6ad38a1bbe56 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/post-receive.d/gitea @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# AUTO GENERATED BY GITEA, DO NOT MODIFY +D:/code/golang_code/gitea/go_build_main_go.exe hook --config="D:\\code\\golang_code\\gitea\\custom\\conf\\app.ini" post-receive diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/post-update.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/post-update.sample new file mode 100644 index 0000000000000..ec17ec1939b7c --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-applypatch.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-applypatch.sample new file mode 100644 index 0000000000000..4142082bcb939 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-commit.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-commit.sample new file mode 100644 index 0000000000000..e144712c85c05 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --type=bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-merge-commit.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-merge-commit.sample new file mode 100644 index 0000000000000..399eab1924e39 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-merge-commit.sample @@ -0,0 +1,13 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git merge" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message to +# stderr if it wants to stop the merge commit. +# +# To enable this hook, rename this file to "pre-merge-commit". + +. git-sh-setup +test -x "$GIT_DIR/hooks/pre-commit" && + exec "$GIT_DIR/hooks/pre-commit" +: diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-push.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-push.sample new file mode 100644 index 0000000000000..4ce688d32b753 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +zero=$(git hash-object --stdin &2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-rebase.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-rebase.sample new file mode 100644 index 0000000000000..6cbef5c370d8c --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive new file mode 100644 index 0000000000000..80ae57095ca0e --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# AUTO GENERATED BY GITEA, DO NOT MODIFY +data=$(cat) +exitcodes="" +hookname=$(basename $0) +GIT_DIR=${GIT_DIR:-$(dirname $0)/..} + +for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do + test -x "${hook}" && test -f "${hook}" || continue + echo "${data}" | "${hook}" + exitcodes="${exitcodes} $?" +done + +for i in ${exitcodes}; do + [ ${i} -eq 0 ] || exit ${i} +done diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.d/gitea b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.d/gitea new file mode 100644 index 0000000000000..ff2bda838ccab --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.d/gitea @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# AUTO GENERATED BY GITEA, DO NOT MODIFY +D:/code/golang_code/gitea/go_build_main_go.exe hook --config="D:\\code\\golang_code\\gitea\\custom\\conf\\app.ini" pre-receive diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.sample new file mode 100644 index 0000000000000..a1fd29ec14823 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/prepare-commit-msg.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/prepare-commit-msg.sample new file mode 100644 index 0000000000000..10fa14c5ab013 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive b/routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive new file mode 100644 index 0000000000000..d6693b4fd31b3 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# AUTO GENERATED BY GITEA, DO NOT MODIFY +D:/code/golang_code/gitea/go_build_main_go.exe hook --config="D:\\code\\golang_code\\gitea\\custom\\conf\\app.ini" proc-receive diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive.d/gitea b/routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive.d/gitea new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/push-to-checkout.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/push-to-checkout.sample new file mode 100644 index 0000000000000..af5a0c0018b5e --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/push-to-checkout.sample @@ -0,0 +1,78 @@ +#!/bin/sh + +# An example hook script to update a checked-out tree on a git push. +# +# This hook is invoked by git-receive-pack(1) when it reacts to git +# push and updates reference(s) in its repository, and when the push +# tries to update the branch that is currently checked out and the +# receive.denyCurrentBranch configuration variable is set to +# updateInstead. +# +# By default, such a push is refused if the working tree and the index +# of the remote repository has any difference from the currently +# checked out commit; when both the working tree and the index match +# the current commit, they are updated to match the newly pushed tip +# of the branch. This hook is to be used to override the default +# behaviour; however the code below reimplements the default behaviour +# as a starting point for convenient modification. +# +# The hook receives the commit with which the tip of the current +# branch is going to be updated: +commit=$1 + +# It can exit with a non-zero status to refuse the push (when it does +# so, it must not modify the index or the working tree). +die () { + echo >&2 "$*" + exit 1 +} + +# Or it can make any necessary changes to the working tree and to the +# index to bring them to the desired state when the tip of the current +# branch is updated to the new commit, and exit with a zero status. +# +# For example, the hook can simply run git read-tree -u -m HEAD "$1" +# in order to emulate git fetch that is run in the reverse direction +# with git push, as the two-tree form of git read-tree -u -m is +# essentially the same as git switch or git checkout that switches +# branches while keeping the local changes in the working tree that do +# not interfere with the difference between the branches. + +# The below is a more-or-less exact translation to shell of the C code +# for the default behaviour for git's push-to-checkout hook defined in +# the push_to_deploy() function in builtin/receive-pack.c. +# +# Note that the hook will be executed from the repository directory, +# not from the working tree, so if you want to perform operations on +# the working tree, you will have to adapt your code accordingly, e.g. +# by adding "cd .." or using relative paths. + +if ! git update-index -q --ignore-submodules --refresh +then + die "Up-to-date check failed" +fi + +if ! git diff-files --quiet --ignore-submodules -- +then + die "Working directory has unstaged changes" +fi + +# This is a rough translation of: +# +# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX +if git cat-file -e HEAD 2>/dev/null +then + head=HEAD +else + head=$(git hash-object -t tree --stdin &2 + exit 1 +} + +unset GIT_DIR GIT_WORK_TREE +cd "$worktree" && + +if grep -q "^diff --git " "$1" +then + validate_patch "$1" +else + validate_cover_letter "$1" +fi && + +if test "$GIT_SENDEMAIL_FILE_COUNTER" = "$GIT_SENDEMAIL_FILE_TOTAL" +then + git config --unset-all sendemail.validateWorktree && + trap 'git worktree remove -ff "$worktree"' EXIT && + validate_series +fi diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/update b/routers/private/tests/repos/repo1_hook_verification/hooks/update new file mode 100644 index 0000000000000..b3570b0004cfa --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/update @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# AUTO GENERATED BY GITEA, DO NOT MODIFY +exitcodes="" +hookname=$(basename $0) +GIT_DIR=${GIT_DIR:-$(dirname $0/..)} + +for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do + test -x "${hook}" && test -f "${hook}" || continue + "${hook}" $1 $2 $3 + exitcodes="${exitcodes} $?" +done + +for i in ${exitcodes}; do + [ ${i} -eq 0 ] || exit ${i} +done diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/update.d/gitea b/routers/private/tests/repos/repo1_hook_verification/hooks/update.d/gitea new file mode 100644 index 0000000000000..1e72edee7335a --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/update.d/gitea @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# AUTO GENERATED BY GITEA, DO NOT MODIFY +D:/code/golang_code/gitea/go_build_main_go.exe hook --config="D:\\code\\golang_code\\gitea\\custom\\conf\\app.ini" update $1 $2 $3 diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/update.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/update.sample new file mode 100644 index 0000000000000..c4d426bc6ee94 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --type=bool hooks.allowunannotated) +allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch) +denycreatebranch=$(git config --type=bool hooks.denycreatebranch) +allowdeletetag=$(git config --type=bool hooks.allowdeletetag) +allowmodifytag=$(git config --type=bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero=$(git hash-object --stdin &2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/routers/private/tests/repos/repo1_hook_verification/info/refs b/routers/private/tests/repos/repo1_hook_verification/info/refs index e04c2535a091f..ee593c4db2647 100644 --- a/routers/private/tests/repos/repo1_hook_verification/info/refs +++ b/routers/private/tests/repos/repo1_hook_verification/info/refs @@ -1 +1 @@ -64e643f86a640d97f95820b43aeb28631042c629 refs/heads/main +d766f2917716d45be24bfa968b8409544941be32 refs/heads/main diff --git a/routers/private/tests/repos/repo1_hook_verification/logs/HEAD b/routers/private/tests/repos/repo1_hook_verification/logs/HEAD index a032573e1296d..5c549b9b4ea66 100644 --- a/routers/private/tests/repos/repo1_hook_verification/logs/HEAD +++ b/routers/private/tests/repos/repo1_hook_verification/logs/HEAD @@ -1,2 +1 @@ -0000000000000000000000000000000000000000 7d92f8f0cf7b989acf2c56a9a4387f5b39a92c41 Gitea 1692868984 +0800 push -7d92f8f0cf7b989acf2c56a9a4387f5b39a92c41 64e643f86a640d97f95820b43aeb28631042c629 Gitea 1692869253 +0800 push +0000000000000000000000000000000000000000 d766f2917716d45be24bfa968b8409544941be32 Gitea 1693148474 +0800 push diff --git a/routers/private/tests/repos/repo1_hook_verification/logs/refs/heads/main b/routers/private/tests/repos/repo1_hook_verification/logs/refs/heads/main index a032573e1296d..5c549b9b4ea66 100644 --- a/routers/private/tests/repos/repo1_hook_verification/logs/refs/heads/main +++ b/routers/private/tests/repos/repo1_hook_verification/logs/refs/heads/main @@ -1,2 +1 @@ -0000000000000000000000000000000000000000 7d92f8f0cf7b989acf2c56a9a4387f5b39a92c41 Gitea 1692868984 +0800 push -7d92f8f0cf7b989acf2c56a9a4387f5b39a92c41 64e643f86a640d97f95820b43aeb28631042c629 Gitea 1692869253 +0800 push +0000000000000000000000000000000000000000 d766f2917716d45be24bfa968b8409544941be32 Gitea 1693148474 +0800 push diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/08/cbc8f0e903b0916025ae7577564b7ed39ecb2c b/routers/private/tests/repos/repo1_hook_verification/objects/08/cbc8f0e903b0916025ae7577564b7ed39ecb2c new file mode 100644 index 0000000000000000000000000000000000000000..d55278f9d45b3d2613b96d44eb9e79e507bc0f27 GIT binary patch literal 86 zcmV-c0IC0Y0V^p=O;s>7HexU|FfcPQQApG)sVHH1Huur&O&6~@dv|NDE04Ny=t)oT sM5ux!LJE?>3RZs4D_EBNgkfUItm*I8#D_2YchC`PLJCd=0AmO~qq@l?H2?qr literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/0b/5987362fe3fabdd4406babdc819642ee2f5a2a b/routers/private/tests/repos/repo1_hook_verification/objects/0b/5987362fe3fabdd4406babdc819642ee2f5a2a new file mode 100644 index 0000000000000000000000000000000000000000..d8b6020bc02054c403ad6288079eb97b8c0907a7 GIT binary patch literal 22 dcmb1&*~>k49dzZ(*R$F2e$wK literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/11/28cd8e82948ea10b4932b2481210610604ce7e b/routers/private/tests/repos/repo1_hook_verification/objects/11/28cd8e82948ea10b4932b2481210610604ce7e deleted file mode 100644 index 52e0c35d87c6ba3bd4a69fb58ceece5c82e55991..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 155 zcmV;M0A&Ao0hNwH3d0}}0DJZo-V0^bb>l)Qg}g-LZkt1rMoiz|e4*DF24>opW$xBH zzVs$ynNxj>aLyGna3Ba86{Oj_6X^!7HexU|FfcPQQApG)sVHIKj%+v6fBb9j6^HEAcN(WTz0;4< sf+|P?D|j~d(d7HexU|FfcPQQApG)sVHIKj%+v6fBb9j6^HEAcN(WTz0;4< sf+|QNq#zlr;Mv?qvo~G5=Iq_Axvo6w#-S%Y!4sh-q~KHl0Pg!cNh*0LG5`Po literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/45/1c1608ab9c5277fdc73ea68aea711c046ac7ac b/routers/private/tests/repos/repo1_hook_verification/objects/45/1c1608ab9c5277fdc73ea68aea711c046ac7ac deleted file mode 100644 index 0df8b68f6401656a5230114dd587457bf88381a1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 708 zcmV;#0z3V90hLn8u7gGZ>zS{Zd(;L77(nW)Iw6Drffop2$qmRr2>Z_C>zlUMUh0Dn zmTcLQlcuWj5lE2xW$Xz72|}zOBnYx`#6<#4h$z4qacLYSLd2%#1nZ<9(t46B=ga zKg3sorj

YRkIUGK?-s;@W2a(ySeW94vP&uM<;|>Dt#z$lg}-nJWx?pg;jlTfUBE z!Bu2QNSjow=`y0c9E!@<$+yUiYaT(bAC6b!p)xNg3lSLQj4R zlHFJCP^j*3*BWlRFs;4Ob>F4eFwyl#Y+q@;^Opebe{TJv;LnQWWLS(zW~9uTB0LTk z3qJRgQII5pez~7huN=h5kdNOkI#&*#|5SeTdUItKlDS_g5TDEQK6`JkXr6X@x1Q>; z8u)LX+ho4HZQWkTokQqZ#{oO%o4P#9OR-%`r}i`2;E+#&dB982L@%<-x&00GnPNZQ qL*2GP&e0GK!SeM*fv-Yu0_xv?D%SD8-bu}*&(oYdslNaLlpr=CWM`WI diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/64/e643f86a640d97f95820b43aeb28631042c629 b/routers/private/tests/repos/repo1_hook_verification/objects/64/e643f86a640d97f95820b43aeb28631042c629 deleted file mode 100644 index 20a49d6d46aead6f32569dacb7c1dabff2d10815..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 711 zcmV;&0yzD60hN-;&Z9;EgmdO8`fg$XcmKi!0fi4ew^ewmno?( zC6!eARJd>3dIkuxf6QZ1fP&@=Hm8sP>4Je}nnMqj7^wUl;w-&No*3L=tXc#>uR z8HOLYZ~q1qhoJB=GhEzBIPW@=+P#F^GK7Q5BwI?a#*3P^;55;r1Q&NQa0=GQhU&-q9IUUKh_p`nWpoO3DAER3TfJk*yUo@aYEhb teB6=S%|4Qbzh6$`*B1f4r07Ty|Nm2Q!������[�,fd2$��n`�zԃ��ۺ.�b����Zd���0N��$�:plPR,1Gs+�n�*���z(4��c��Sɹ��J��My�߶�sY�e��]��� �G ��ߏs[Oօ�)��~B0�}]�7M�|�ݘ�r�T�����0O��N� \ No newline at end of file diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/8b/903ede7c494725624bf842ec890f6342dababd b/routers/private/tests/repos/repo1_hook_verification/objects/8b/903ede7c494725624bf842ec890f6342dababd new file mode 100644 index 0000000000000000000000000000000000000000..fd3c3a488b22a43d8391d6db5a5787a33c77024e GIT binary patch literal 86 zcmV-c0IC0Y0V^p=O;s>7HexU|FfcPQQApG)sVHH1Huur&O&6~@dv|NDE04Ny=t)oT sM5ux!LJE?>3RZs4D_EBNgkfUItm*I8#D_2YchC`PLJCe30B#*W6uSE()c^nh literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/93/eac826f6188f34646cea81bf426aa5ba7d3bfe b/routers/private/tests/repos/repo1_hook_verification/objects/93/eac826f6188f34646cea81bf426aa5ba7d3bfe new file mode 100644 index 0000000000000000000000000000000000000000..80abd3ade146e5e807d77fa798872ad11813c6e8 GIT binary patch literal 684 zcmV;d0#p5X0hN-;j-yBvMSIOx#2#fAQ!q%?t!6S{8z(ry7 zzWW=nqQbMny9NVjMrIi5P2a`F?0>uz_u^R<;Ny2R({fJ0vpn$SSSK|I&*nF$00k=F z+B8+wbX6t0$~04NPVD1GD>h`*LCKyMe@XQCKI!pJ?Sdg0RaGw<|6fjlNl)|J{F1cx z)SG+v$NaR(2}}67T|di1ZR*FRc)EBf!%!FOMR3bPS33%n`zdT*r_sG_ zXJpyEKRSdH=?%Gu{Zkn8Xg11>#$p656J{C4T}23tuHBhc?3&Ig5RT7Bq^U-{Z;p6s z`}M+9L|6TFuAQFem_s$iYbh>Kn~o_tOTyk;H3nT4t8jK(BT;}Q9d6wz!$}QGzVYe- zPrI%#wVV#8aJh7i)Y#EO)t=$kOV%xiT!gdIJc6?K?AnYdux?ws+)h?7H2F9Fr3TUbLOVrs59EDU literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/97/79d17a04f1e2640583d35703c62460b2d86e0a b/routers/private/tests/repos/repo1_hook_verification/objects/97/79d17a04f1e2640583d35703c62460b2d86e0a new file mode 100644 index 0000000000000..7f3293a8bc2e3 --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification/objects/97/79d17a04f1e2640583d35703c62460b2d86e0a @@ -0,0 +1,2 @@ +x��1 +!ES{��AwGGa 9E�Qg W���#�A�����Z�/������p��(�(���Bh�ۼ&�����:pLY`���U��-�z����\��ZM:��������xJ/�G}:�3 \ No newline at end of file diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/99/ff046fbdf6eed4ae4349f9181ff42b340a4582 b/routers/private/tests/repos/repo1_hook_verification/objects/99/ff046fbdf6eed4ae4349f9181ff42b340a4582 deleted file mode 100644 index a61154c7b5976d37587a964bb102f7ffb793548e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 82 zcmV-Y0ImOc0V^p=O;xb8WH2-^Ff%bxNYpE-C}Fs`CGwAi;OlCGO%J_Jo!Jrm_2TA7 oPz6a~1<&R_n!V}bHD~W`&2{BbHx51N37!a5kc?9S0Ce;)g40MPHUIzs diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/9c/e3f779ae33f31fce17fac3c512047b75d7498b b/routers/private/tests/repos/repo1_hook_verification/objects/9c/e3f779ae33f31fce17fac3c512047b75d7498b new file mode 100644 index 0000000000000000000000000000000000000000..61a9ee8391cacd644d02db180d3e4acef6a6426a GIT binary patch literal 153 zcmV;K0A~Mq0hNwH3c@fD06pgwxeKz%wn-L5{L1cTt39-pkP80Z;txCx3=E8J%QAN# zLpb$j=Ao!)nZO88fI@;evgI-7F%6QfBAH55_u^)2_bNOnf(A+q254F8l+2_cVGV;& zg^bLO_x{|PXVGf@`osM(cjJq0%gu*G7=}U#{TT{?JM1ym?T^Im>)YBqeY`YY^%>n4 H#@RwpUeQZ( literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/a9/f76e70a663e40091749a97eeac5f57a6fec141 b/routers/private/tests/repos/repo1_hook_verification/objects/a9/f76e70a663e40091749a97eeac5f57a6fec141 new file mode 100644 index 0000000000000000000000000000000000000000..fb79dc96b958666cf9f58227b26cf5a55ddfca72 GIT binary patch literal 24 gcmb7HexU|FfcPQQApG)sVHH1Huur&O&6~@dv|NDE04Ny=t)oT VM5ux!LJE=zDM-Po004)>KZVCe7#IKm literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/bb/87653e0819460e79b5f075f2563f583cbbf18c b/routers/private/tests/repos/repo1_hook_verification/objects/bb/87653e0819460e79b5f075f2563f583cbbf18c new file mode 100644 index 0000000000000000000000000000000000000000..a765d667581bf143461d197e64e95fdf5219fd51 GIT binary patch literal 682 zcmV;b0#*HZ0hN-;&ZAZkg|p@~LpW8gCR>D%cjyKGXM zlD?yo&MBR|e>_?YL{az+k7WsH7Eu+$R#0FO4e5$Qe2yTjD4x!d#O9JDFj7gE#48)i zCkBP^5gCaV1R53`k4lC^RVG0Zi5w;I94B!!Dp`ieX5926$WUIC;QO!jSKZ<=`#tX; ze*zjxEX|1`&w~RcQWWu_A7i-uA1C#zp4u9G`+F4Kuv~C9&LFT1SH4_*{TC+y0b0*^ zE3&MpvRoWnUC+*IYTECEWb%|eO63%KTdF3nSxt`e<1(gWE~|Ct{mTjPQJiPJ%0ox- z)Y>Sa7e_mNi|p3?A_d<5GUQh)Ma3;@L+0LC>zP_zKZ5<>BPDD%0$h39+17$1A&s^) z7?eXV=i#h$V*3pE)jPA&w%T1lpXx7B<%2AmqA;f1AlCT);S~gEjIE|sWtF1K`4zU!<@#hZ}d0a>{q!txQMx0qSLV*(x zaB!Zlo9dm4Xq$Y?BG*2gtTcpa-!;~Q)NY?Bv%bs(aAy6Dro>0SI1Gs{mdRIRT*d8x zh4HvBZX!e-#h4{-mXfWl3zV7dl+0(cmPly(3IQg#-|lm6ug_wu?(WPWs?kVi=#Rsm zydM}_q>L4;(?!gHCF`P(zM?~ n6(oTbJe&Jy_NI&1oV~j>*Of=zIP|0^cp_9mGEM~mhF~p9Jj)^x diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/c8/871c5132e62a637e2afada08acd41146662bed b/routers/private/tests/repos/repo1_hook_verification/objects/c8/871c5132e62a637e2afada08acd41146662bed deleted file mode 100644 index c51305a9e48394e10fe4240a106b9632eab7fa8e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24 fcmbm ���p���1w͗�-7p���Ąp��Zs�DZ�L̾������L��e@� \ No newline at end of file diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/d1/b459fc1811eb7b30b2e14acaccb853f5d1b3e2 b/routers/private/tests/repos/repo1_hook_verification/objects/d1/b459fc1811eb7b30b2e14acaccb853f5d1b3e2 deleted file mode 100644 index dc97118569add159d0d98167be3b19f7e2a661ae..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 27 icmb}frnHcPY*��x��vQ�(��a��W�o"��s�r�z��e�ŭ}�QD��֨fK)�m�r>>�������̚$�F8�x� ��^J� k{mcz�I*�^�Mb�� m�6��M~h�p�� {���0��� ]€?nUwg�ɠ���J �б��<�7�2 \ No newline at end of file diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/e0/5ec071e40a53cd4785345a99fd12f5dbb6a777 b/routers/private/tests/repos/repo1_hook_verification/objects/e0/5ec071e40a53cd4785345a99fd12f5dbb6a777 deleted file mode 100644 index ee929629123a45dcd7ff818f191749f1ce0fb1e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 143 zcmV;A0C4|!0gcT$4#F@HKv8O+!aWKa8;_R=A*383Cm3(RMQkN91-B;!J+xnX`k}3B z>0Amp^*tr7krWywk+gBaCr2?ultu|-F;r5LJ}%1SJMRDh diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/e8/4e452c3a20c02dee17ec2f63c0cb9ef6c759eb b/routers/private/tests/repos/repo1_hook_verification/objects/e8/4e452c3a20c02dee17ec2f63c0cb9ef6c759eb new file mode 100644 index 0000000000000000000000000000000000000000..24580f88e3d3537e6a29a04e280d193f1fcf7d2c GIT binary patch literal 677 zcmV;W0$Tle0hN+V53)uWg}dfg%-*!Za1oNWDVIS(L_k1cH^6XFxyViA*MIhFy6dLz z<|I#YPTs|nwsl>NKosd;#-0#B*d5_BMiL=QIGE!M@-P=zj!Bq&x5K+66$s&YhU#!n zni1@v1ZlVvbC^q#L|B^UMVk3e@QH{Mkzu8b6*wlP@HCcf4{(xZ1pNLp{wk`G;NQ}= z{u3~Q#4?-+B_3>Ok*29H{XRC5|4}KrVyFu6>))rKyUQ5*b2wiPfl^)JT_WzmJVnR*Q%GFQ>qyVs&!ot+$MG z6Zq4XFVoAx?&oDq`gQM3kG3f0uJ4S=f7@sOD&W`k$lb(!!?HzFQDF40Ot^_~32R?) zH?1)pAGSlA)`?Z0cl~xwlu3^5P)u)acfSY z(Rk7;KJUeY@9)$n(ZuMbm1vJNZdIM`GhjNo3nwXgYm0D|AO)CLYn!|;IZe@JXpJ2> zHksU>=W4sQ=Rk3d?v=OZ)W~tMw#U2L1&g4kmz}n$GM;@>pzm!<*H%@2nxu8^^{qds zXcb@Bz+Zu4tSiB=6PX^ZZE>-Gxa~L0| zoeS%6LwF`gS$dADL4H8>V})lO)(Q?gr$zF$Us#_4{xebf2tHfpWt zuE@xH+=4D=1kZb!g_sM`$x~-9Z^}F_tp_*fEyd16X!S-_`?oA9rcfc$kzVLKx!s^ L^=7HexU|FfcPQQApG)sVHH1Huur&O&6~@dv|NDE04Ny=t)oT sM5ux!LJE?>3RZs4D_EBNgkfUItm*I8#D_2YchC`PLJCd=0AmO~qq@l?H2?qr literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/0b/5987362fe3fabdd4406babdc819642ee2f5a2a b/routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/0b/5987362fe3fabdd4406babdc819642ee2f5a2a new file mode 100644 index 0000000000000000000000000000000000000000..d8b6020bc02054c403ad6288079eb97b8c0907a7 GIT binary patch literal 22 dcmb1&*~>k49dzZ(*R$F2e$wK literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/13/b0f23f673b161f4b5cb66f051cb93c99729e1e b/routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/13/b0f23f673b161f4b5cb66f051cb93c99729e1e new file mode 100644 index 0000000000000000000000000000000000000000..77936d82415e3e526af9ef249a3b6531c14df4fa GIT binary patch literal 86 zcmV-c0IC0Y0V^p=O;s>7HexU|FfcPQQApG)sVHIKj%+v6fBb9j6^HEAcN(WTz0;4< sf+|P?D|j~d(d7HexU|FfcPQQApG)sVHIKj%+v6fBb9j6^HEAcN(WTz0;4< sf+|QNq#zlr;Mv?qvo~G5=Iq_Axvo6w#-S%Y!4sh-q~KHl0Pg!cNh*0LG5`Po literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/8b/903ede7c494725624bf842ec890f6342dababd b/routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/8b/903ede7c494725624bf842ec890f6342dababd new file mode 100644 index 0000000000000000000000000000000000000000..fd3c3a488b22a43d8391d6db5a5787a33c77024e GIT binary patch literal 86 zcmV-c0IC0Y0V^p=O;s>7HexU|FfcPQQApG)sVHH1Huur&O&6~@dv|NDE04Ny=t)oT sM5ux!LJE?>3RZs4D_EBNgkfUItm*I8#D_2YchC`PLJCe30B#*W6uSE()c^nh literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/93/eac826f6188f34646cea81bf426aa5ba7d3bfe b/routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/93/eac826f6188f34646cea81bf426aa5ba7d3bfe new file mode 100644 index 0000000000000000000000000000000000000000..80abd3ade146e5e807d77fa798872ad11813c6e8 GIT binary patch literal 684 zcmV;d0#p5X0hN-;j-yBvMSIOx#2#fAQ!q%?t!6S{8z(ry7 zzWW=nqQbMny9NVjMrIi5P2a`F?0>uz_u^R<;Ny2R({fJ0vpn$SSSK|I&*nF$00k=F z+B8+wbX6t0$~04NPVD1GD>h`*LCKyMe@XQCKI!pJ?Sdg0RaGw<|6fjlNl)|J{F1cx z)SG+v$NaR(2}}67T|di1ZR*FRc)EBf!%!FOMR3bPS33%n`zdT*r_sG_ zXJpyEKRSdH=?%Gu{Zkn8Xg11>#$p656J{C4T}23tuHBhc?3&Ig5RT7Bq^U-{Z;p6s z`}M+9L|6TFuAQFem_s$iYbh>Kn~o_tOTyk;H3nT4t8jK(BT;}Q9d6wz!$}QGzVYe- zPrI%#wVV#8aJh7i)Y#EO)t=$kOV%xiT!gdIJc6?K?AnYdux?ws+)h?7H2F9Fr3TUbLOVrs59EDU literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/9c/e3f779ae33f31fce17fac3c512047b75d7498b b/routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/9c/e3f779ae33f31fce17fac3c512047b75d7498b new file mode 100644 index 0000000000000000000000000000000000000000..61a9ee8391cacd644d02db180d3e4acef6a6426a GIT binary patch literal 153 zcmV;K0A~Mq0hNwH3c@fD06pgwxeKz%wn-L5{L1cTt39-pkP80Z;txCx3=E8J%QAN# zLpb$j=Ao!)nZO88fI@;evgI-7F%6QfBAH55_u^)2_bNOnf(A+q254F8l+2_cVGV;& zg^bLO_x{|PXVGf@`osM(cjJq0%gu*G7=}U#{TT{?JM1ym?T^Im>)YBqeY`YY^%>n4 H#@RwpUeQZ( literal 0 HcmV?d00001 diff --git a/routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/a9/f76e70a663e40091749a97eeac5f57a6fec141 b/routers/private/tests/repos/repo1_hook_verification/objects/tmp_objdir-incoming-a21648/a9/f76e70a663e40091749a97eeac5f57a6fec141 new file mode 100644 index 0000000000000000000000000000000000000000..fb79dc96b958666cf9f58227b26cf5a55ddfca72 GIT binary patch literal 24 gcmb~LpW8gCR>D%cjyKGXM zlD?yo&MBR|e>_?YL{az+k7WsH7Eu+$R#0FO4e5$Qe2yTjD4x!d#O9JDFj7gE#48)i zCkBP^5gCaV1R53`k4lC^RVG0Zi5w;I94B!!Dp`ieX5926$WUIC;QO!jSKZ<=`#tX; ze*zjxEX|1`&w~RcQWWu_A7i-uA1C#zp4u9G`+F4Kuv~C9&LFT1SH4_*{TC+y0b0*^ zE3&MpvRoWnUC+*IYTECEWb%|eO63%KTdF3nSxt`e<1(gWE~|Ct{mTjPQJiPJ%0ox- z)Y>Sa7e_mNi|p3?A_d<5GUQh)Ma3;@L+0LC>zP_zKZ5<>BPDD%0$h39+17$1A&s^) z7?eXV=i#h$V*3pE)jPA&w%T1lpXx7B<%2AmqA;f1AlCT);S~gEjIE|sWtF1K`4zU!<@#hZ}d0a>{q!txQMx0qSLV*(x zaB!Zlo9dm4Xq$Y?BG*2gtTcpa-!;~Q)NY?Bv%bs(aAy6Dro>0SI1Gs{mdRIRT*d8x zh4HvBZX!e-#h4{-mXfWl3zV7dl+0(cmPly(3IQg#-|lm6ug_wu?(WPWs?kVi=#Rsm zydM}_q>L4;m ���p���1w͗�-7p���Ąp��Zs�DZ�L̾������L��e@� \ No newline at end of file diff --git a/routers/private/tests/repos/repo1_hook_verification/refs/heads/main b/routers/private/tests/repos/repo1_hook_verification/refs/heads/main index ddc5a5404baba..2186e820a7990 100644 --- a/routers/private/tests/repos/repo1_hook_verification/refs/heads/main +++ b/routers/private/tests/repos/repo1_hook_verification/refs/heads/main @@ -1 +1 @@ -64e643f86a640d97f95820b43aeb28631042c629 +d766f2917716d45be24bfa968b8409544941be32 From dca58bfcdc34f2c9033950152741b35d69ca0c64 Mon Sep 17 00:00:00 2001 From: chenyaoran <1290147055@qq.com> Date: Sun, 27 Aug 2023 23:28:19 +0800 Subject: [PATCH 11/18] add dummy gpg key --- .../repo1_hook_verification_dummy_gpg_key.txt | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt diff --git a/routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt b/routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt new file mode 100644 index 0000000000000..377cdbe97d41b --- /dev/null +++ b/routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt @@ -0,0 +1,132 @@ + -----BEGIN PGP PUBLIC KEY BLOCK----- + + mQGNBGTrY3UBDAC2HLBqmMplAV15qSnC7g1c4dV406f5EHNhFr95Nup2My6b2eaf + Tlvedv77s8PT/I7F3fy4apOZs5A7w2SsPlLMcQ3ev4uGOsxRtkq5RLy1Yb6SNueX + 0Da2UVKR5KTC5Q6BWaqxwS0IjKOLZ/xz0Pbe/ClV3bZSKBEY2omkVo3Z0HZ771vB + 2clPRvGJ/IdeKOsZ3ZytSFXfyiJBdARmeSPmydXLil8+Ibq5iLAeow5PK8hK1TCO + nKHzLWNqcNq70tyjoHvcGi70iGjoVEEUgPCLLuU8WmzTJwlvA3BuDzjtaO7TLo/j + dE6iqkHtMSS8x+43sAH6hcFRCWAVh/0Uq7n36uGDfNxGnX3YrmX3LR9x5IsBES1r + GGWbpxio4o5GIf/Xd+JgDd9rzJCqRuZ3/sW/TxK38htWaVNZV0kMkHUCTc1ctzWp + Cm635hbFCHBhPYIp+/z206khkAKDbz/CNuU91Wazsh7KO07wrwDtxfDDbInJ8TfH + E2TGjzjQzgChfmcAEQEAAbQXYWJjZGUgPGFiY2RlQGdpdGVhLmNvbT6JAc4EEwEI + ADgWIQRo/BkcvP70fnQCv16xVDFkJim4JgUCZOtjdQIbAwULCQgHAgYVCgkICwIE + FgIDAQIeAQIXgAAKCRCxVDFkJim4Js6+C/9yIjHqcyM88hQAYQUoiPYfgJ0f2NsD + Ai/X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CgkBxZJWbScN4Jtaw +ory9LEQqo0/epYJwf+79GHIJrpODAPiPJEMKmlej23KyoFuusOi17C0vHCf3GZNj +4F2So3LOrcs51qTlOum2MdL5oTdqffatzs6p4u5bHBxyRugQlQggTRSK+TXLdxnF +Xr9ukXjIC2mFir7CCnZHw4e+2JwZfaAom0ZX+pLwrReSop4BPPU2YDzt3XCUk0S9 +kpiOsN7iFWUMCFreIE50DOxt9406kSGopYKVaifbDl4MdLXM4v+oucLe7/yOViT/ +dm4FcIytIR+jzC8MaLQTB23euzm2wOjI1YOwv7Il6PWZyDdU+tyzXcaJ7wSFBeQF +ZZtqph2TItCeV04HoaKHHc254akc +=PPG4 +-----END PGP PRIVATE KEY BLOCK----- + + + + + From dd5cdb118caeedbe967717888f7fae992e679bb1 Mon Sep 17 00:00:00 2001 From: chenyaoran <1290147055@qq.com> Date: Sun, 27 Aug 2023 23:28:33 +0800 Subject: [PATCH 12/18] mock database --- models/fixtures/gpg_key.yml | 10 +++++----- models/fixtures/user.yml | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/models/fixtures/gpg_key.yml b/models/fixtures/gpg_key.yml index 9acd4c6770ee9..2d54313fdf1c7 100644 --- a/models/fixtures/gpg_key.yml +++ b/models/fixtures/gpg_key.yml @@ -1,9 +1,9 @@ - id: 5 owner_id: 36 - key_id: 2ECAAA351B755A40 + key_id: B15431642629B826 primary_key_id: - content: xsDNBGTjB1cBDACv7YEaiA5VaoTBR0fcPRy+RHgTd88ALhklVVd54lbMKWwsHa3Ms9sCYbq8chly4g50l45o8qL0mu+zkZDvrU3EsZAwFwv/6iKltQXRIQ7j0uNKIyJi/+yyMiRJtU24ptAkc+bHhb2wi7cnJtldGyDZIoymzotTdpJupmjVFXqQtbeqMHpSKg6JdyGLK+wX+ITD7gZ6UddPPbw5Yo6N5b56w55cSIG6cDtafo+/Fc4WF0jdDDmCEyPlr3afDKEcpmnDSJsMhm7/eZ5MRn2dh9+brnEFyxkKSJYfI7ptA6trAs+DCil9FgZbXM9P/c0joVUzi1lSGSu1ryav9eAb4J5lgzl2Tad338+cVWuCHR6yTbq4qZcfgNVnFK1WMUrg9MF2A8wNLO1O9LSQpXwDSBmnM9W7TcTE6bpxbADVH7WEScCNmExKeqUnvvypaeiwmwz7Jqh/V5NhjE3ySgo3j/oBFFUp2SSkZhk7p0uP8mDLSdfPLxtBUv3EQAPs8CCD7WkAEQEAAQ== + content: xsDNBGTrY3UBDAC2HLBqmMplAV15qSnC7g1c4dV406f5EHNhFr95Nup2My6b2eafTlvedv77s8PT/I7F3fy4apOZs5A7w2SsPlLMcQ3ev4uGOsxRtkq5RLy1Yb6SNueX0Da2UVKR5KTC5Q6BWaqxwS0IjKOLZ/xz0Pbe/ClV3bZSKBEY2omkVo3Z0HZ771vB2clPRvGJ/IdeKOsZ3ZytSFXfyiJBdARmeSPmydXLil8+Ibq5iLAeow5PK8hK1TCOnKHzLWNqcNq70tyjoHvcGi70iGjoVEEUgPCLLuU8WmzTJwlvA3BuDzjtaO7TLo/jdE6iqkHtMSS8x+43sAH6hcFRCWAVh/0Uq7n36uGDfNxGnX3YrmX3LR9x5IsBES1rGGWbpxio4o5GIf/Xd+JgDd9rzJCqRuZ3/sW/TxK38htWaVNZV0kMkHUCTc1ctzWpCm635hbFCHBhPYIp+/z206khkAKDbz/CNuU91Wazsh7KO07wrwDtxfDDbInJ8TfHE2TGjzjQzgChfmcAEQEAAQ== verified: true can_sign: true can_encrypt_comms: true @@ -13,9 +13,9 @@ - id: 6 owner_id: 36 - key_id: 2FCCED20E8714BAA - primary_key_id: 2ECAAA351B755A40 - content: zsDNBGTjB1cBDADm2EFZ6SzUoF5We4kQBaLYtkFNRA2yQafbu+W/AYOITgxye2xDKVcMaopV6B+vPXKyIshakWkdpK8Xw5dZGI0loOm5PXFJDI6lzWWUy76J3SevenCXzxWOCXZOtI25Zpev/b96Cu7xsRdcL6eYpGRNwVJ3bW3AhD5z2AU0z05VYKrNIzs5e7PfO9g7uGQ5DuejLr6Wp9+zHfp6ppHkHFET7x0ZrNE+hH1hPAK0yFQ75iU4zvNXxa2PKgfSBkEADre+EV0+BxlRB9c9jkLWKa/Xa4ecaiFgH/ler12gr8/NOCJww+bLQapJBTKSGycupANwIZb1lgna1r09P6PCp25MBrvVWfD9qzvVmFxpM+e8/y9D3RcJkHwJjQ9SaX/gNq/nFdvVsLpIMGGQY0KDMeJW/XkwhGNZ/tuztLgqSIcbNuVZMooOwgAT9r1Z1XpKuuh+mNTwwzEzvV5Qo6Kd/9/zPqJmoniziNxyzfEQ82HhOMZg3CJVGenPPhIHXCJAO3kAEQEAAQ== + key_id: EE3AF48454AFD619 + primary_key_id: B15431642629B826 + content: zsDNBGTrY3UBDADsHrzuOicQaPdUQm0+0UNrs92cESm/j/4yBBUk+sfLZAo6J99c4eh4nAQzzZ7al080rYKB0G+7xoRz1eHcQH6zrVcqB8KYtf/sdY47WaMiMyxM+kTSvzp7tsv7QuSQZ0neUEXRyYMz5ttBfIjWUd+3NDItuHyB+MtNWlS3zXgaUbe5VifqKaNmzN0Ye4yXTKcpypE3AOqPVz+iIFv3c6TmsqLHJaR4VoicCleAqLyF/28WsJO7M9dDW+EM3MZVnsVpycTURyHAJGfSk10waQZAaRwmarCN/q0KEJ+aEAK/SRliUneBZoMO5hY5iBeG432tofwaQqAahPv9uXIb1n2JEMKwnMlMA9UGD1AcDbywfj1m/ZGBBw95i4Ekkfn43RvV3THr7uJU/dRqqP+iic4MwpUrOxqELW/kmeHXlBcNbZZhEEvwRoW7U2/9eeuog4nRleRJ0pi/xOP9wmxkKjaIPIK3phdBtEpVk4w/UTAWNdyIIrFggukeAnZFyGJwlm8AEQEAAQ== verified: true can_sign: true can_encrypt_comms: true diff --git a/models/fixtures/user.yml b/models/fixtures/user.yml index 20a56e76f4e2e..f24d098a7ed7b 100644 --- a/models/fixtures/user.yml +++ b/models/fixtures/user.yml @@ -1301,7 +1301,7 @@ lower_name: limited_org36 name: limited_org36 full_name: Limited Org 36 - email: 1290147055@qq.com + email: abcde@gitea.com keep_email_private: false email_notifications_preference: enabled passwd: ZogKvWdyEx:password @@ -1320,7 +1320,7 @@ allow_create_organization: true prohibit_login: false avatar: avatar22 - avatar_email: 1290147055@qq.com + avatar_email: abcde@gitea.com use_custom_avatar: false num_followers: 0 num_following: 0 From 2d14932ea96ad8889d16281cbe575cd28fe511d4 Mon Sep 17 00:00:00 2001 From: chenyaoran <1290147055@qq.com> Date: Sun, 27 Aug 2023 23:29:00 +0800 Subject: [PATCH 13/18] new commit sha in test --- routers/private/hook_verification_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routers/private/hook_verification_test.go b/routers/private/hook_verification_test.go index 173b32996cb87..cd0c05ff50a71 100644 --- a/routers/private/hook_verification_test.go +++ b/routers/private/hook_verification_test.go @@ -26,10 +26,10 @@ func TestVerifyCommits(t *testing.T) { base, head string verified bool }{ - {"7d92f8f0cf7b989acf2c56a9a4387f5b39a92c41", "64e643f86a640d97f95820b43aeb28631042c629", true}, - {git.EmptySHA, "451c1608ab9c5277fdc73ea68aea711c046ac7ac", true}, // New branch with verified commit - {"e05ec071e40a53cd4785345a99fd12f5dbb6a777", "7d92f8f0cf7b989acf2c56a9a4387f5b39a92c41", false}, - {git.EmptySHA, "1128cd8e82948ea10b4932b2481210610604ce7e", false}, // New branch with unverified commit + {"72920278f2f999e3005801e5d5b8ab8139d3641c", "d766f2917716d45be24bfa968b8409544941be32", true}, + {git.EmptySHA, "93eac826f6188f34646cea81bf426aa5ba7d3bfe", true}, // New branch with verified commit + {"9779d17a04f1e2640583d35703c62460b2d86e0a", "72920278f2f999e3005801e5d5b8ab8139d3641c", false}, + {git.EmptySHA, "9ce3f779ae33f31fce17fac3c512047b75d7498b", false}, // New branch with unverified commit } for _, tc := range testCases { From c2c4aaf9dd08f9d18988d2bc9da3d6d374fd76f6 Mon Sep 17 00:00:00 2001 From: chenyaoran <1290147055@qq.com> Date: Sun, 27 Aug 2023 23:33:19 +0800 Subject: [PATCH 14/18] delete unnecessary file --- .../git-daemon-export-ok | 0 .../hooks/applypatch-msg.sample | 15 -- .../hooks/commit-msg.sample | 24 --- .../hooks/fsmonitor-watchman.sample | 174 ------------------ .../hooks/post-receive | 16 -- .../hooks/post-receive.d/gitea | 3 - .../hooks/post-update.sample | 8 - .../hooks/pre-applypatch.sample | 14 -- .../hooks/pre-commit.sample | 49 ----- .../hooks/pre-merge-commit.sample | 13 -- .../hooks/pre-push.sample | 53 ------ .../hooks/pre-rebase.sample | 169 ----------------- .../repo1_hook_verification/hooks/pre-receive | 16 -- .../hooks/pre-receive.d/gitea | 3 - .../hooks/pre-receive.sample | 24 --- .../hooks/prepare-commit-msg.sample | 42 ----- .../hooks/proc-receive | 3 - .../hooks/proc-receive.d/gitea | 0 .../hooks/push-to-checkout.sample | 78 -------- .../hooks/sendemail-validate.sample | 77 -------- .../repo1_hook_verification/hooks/update | 15 -- .../hooks/update.d/gitea | 3 - .../hooks/update.sample | 128 ------------- 23 files changed, 927 deletions(-) delete mode 100644 routers/private/tests/repos/repo1_hook_verification/git-daemon-export-ok delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/applypatch-msg.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/commit-msg.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/fsmonitor-watchman.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/post-receive delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/post-receive.d/gitea delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/post-update.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-applypatch.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-commit.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-merge-commit.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-push.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-rebase.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.d/gitea delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/prepare-commit-msg.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive.d/gitea delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/push-to-checkout.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/sendemail-validate.sample delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/update delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/update.d/gitea delete mode 100644 routers/private/tests/repos/repo1_hook_verification/hooks/update.sample diff --git a/routers/private/tests/repos/repo1_hook_verification/git-daemon-export-ok b/routers/private/tests/repos/repo1_hook_verification/git-daemon-export-ok deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/applypatch-msg.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/applypatch-msg.sample deleted file mode 100644 index a5d7b84a67345..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/applypatch-msg.sample +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message taken by -# applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. The hook is -# allowed to edit the commit message file. -# -# To enable this hook, rename this file to "applypatch-msg". - -. git-sh-setup -commitmsg="$(git rev-parse --git-path hooks/commit-msg)" -test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} -: diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/commit-msg.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/commit-msg.sample deleted file mode 100644 index b58d1184a9d43..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/commit-msg.sample +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message. -# Called by "git commit" with one argument, the name of the file -# that has the commit message. The hook should exit with non-zero -# status after issuing an appropriate message if it wants to stop the -# commit. The hook is allowed to edit the commit message file. -# -# To enable this hook, rename this file to "commit-msg". - -# Uncomment the below to add a Signed-off-by line to the message. -# Doing this in a hook is a bad idea in general, but the prepare-commit-msg -# hook is more suited to it. -# -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" - -# This example catches duplicate Signed-off-by lines. - -test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { - echo >&2 Duplicate Signed-off-by lines. - exit 1 -} diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/fsmonitor-watchman.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/fsmonitor-watchman.sample deleted file mode 100644 index 23e856f5deeb7..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/fsmonitor-watchman.sample +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use IPC::Open2; - -# An example hook script to integrate Watchman -# (https://facebook.github.io/watchman/) with git to speed up detecting -# new and modified files. -# -# The hook is passed a version (currently 2) and last update token -# formatted as a string and outputs to stdout a new update token and -# all files that have been modified since the update token. Paths must -# be relative to the root of the working tree and separated by a single NUL. -# -# To enable this hook, rename this file to "query-watchman" and set -# 'git config core.fsmonitor .git/hooks/query-watchman' -# -my ($version, $last_update_token) = @ARGV; - -# Uncomment for debugging -# print STDERR "$0 $version $last_update_token\n"; - -# Check the hook interface version -if ($version ne 2) { - die "Unsupported query-fsmonitor hook version '$version'.\n" . - "Falling back to scanning...\n"; -} - -my $git_work_tree = get_working_dir(); - -my $retry = 1; - -my $json_pkg; -eval { - require JSON::XS; - $json_pkg = "JSON::XS"; - 1; -} or do { - require JSON::PP; - $json_pkg = "JSON::PP"; -}; - -launch_watchman(); - -sub launch_watchman { - my $o = watchman_query(); - if (is_work_tree_watched($o)) { - output_result($o->{clock}, @{$o->{files}}); - } -} - -sub output_result { - my ($clockid, @files) = @_; - - # Uncomment for debugging watchman output - # open (my $fh, ">", ".git/watchman-output.out"); - # binmode $fh, ":utf8"; - # print $fh "$clockid\n@files\n"; - # close $fh; - - binmode STDOUT, ":utf8"; - print $clockid; - print "\0"; - local $, = "\0"; - print @files; -} - -sub watchman_clock { - my $response = qx/watchman clock "$git_work_tree"/; - die "Failed to get clock id on '$git_work_tree'.\n" . - "Falling back to scanning...\n" if $? != 0; - - return $json_pkg->new->utf8->decode($response); -} - -sub watchman_query { - my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') - or die "open2() failed: $!\n" . - "Falling back to scanning...\n"; - - # In the query expression below we're asking for names of files that - # changed since $last_update_token but not from the .git folder. - # - # To accomplish this, we're using the "since" generator to use the - # recency index to select candidate nodes and "fields" to limit the - # output to file names only. Then we're using the "expression" term to - # further constrain the results. - my $last_update_line = ""; - if (substr($last_update_token, 0, 1) eq "c") { - $last_update_token = "\"$last_update_token\""; - $last_update_line = qq[\n"since": $last_update_token,]; - } - my $query = <<" END"; - ["query", "$git_work_tree", {$last_update_line - "fields": ["name"], - "expression": ["not", ["dirname", ".git"]] - }] - END - - # Uncomment for debugging the watchman query - # open (my $fh, ">", ".git/watchman-query.json"); - # print $fh $query; - # close $fh; - - print CHLD_IN $query; - close CHLD_IN; - my $response = do {local $/; }; - - # Uncomment for debugging the watch response - # open ($fh, ">", ".git/watchman-response.json"); - # print $fh $response; - # close $fh; - - die "Watchman: command returned no output.\n" . - "Falling back to scanning...\n" if $response eq ""; - die "Watchman: command returned invalid output: $response\n" . - "Falling back to scanning...\n" unless $response =~ /^\{/; - - return $json_pkg->new->utf8->decode($response); -} - -sub is_work_tree_watched { - my ($output) = @_; - my $error = $output->{error}; - if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) { - $retry--; - my $response = qx/watchman watch "$git_work_tree"/; - die "Failed to make watchman watch '$git_work_tree'.\n" . - "Falling back to scanning...\n" if $? != 0; - $output = $json_pkg->new->utf8->decode($response); - $error = $output->{error}; - die "Watchman: $error.\n" . - "Falling back to scanning...\n" if $error; - - # Uncomment for debugging watchman output - # open (my $fh, ">", ".git/watchman-output.out"); - # close $fh; - - # Watchman will always return all files on the first query so - # return the fast "everything is dirty" flag to git and do the - # Watchman query just to get it over with now so we won't pay - # the cost in git to look up each individual file. - my $o = watchman_clock(); - $error = $output->{error}; - - die "Watchman: $error.\n" . - "Falling back to scanning...\n" if $error; - - output_result($o->{clock}, ("/")); - $last_update_token = $o->{clock}; - - eval { launch_watchman() }; - return 0; - } - - die "Watchman: $error.\n" . - "Falling back to scanning...\n" if $error; - - return 1; -} - -sub get_working_dir { - my $working_dir; - if ($^O =~ 'msys' || $^O =~ 'cygwin') { - $working_dir = Win32::GetCwd(); - $working_dir =~ tr/\\/\//; - } else { - require Cwd; - $working_dir = Cwd::cwd(); - } - - return $working_dir; -} diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/post-receive b/routers/private/tests/repos/repo1_hook_verification/hooks/post-receive deleted file mode 100644 index 80ae57095ca0e..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/post-receive +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -# AUTO GENERATED BY GITEA, DO NOT MODIFY -data=$(cat) -exitcodes="" -hookname=$(basename $0) -GIT_DIR=${GIT_DIR:-$(dirname $0)/..} - -for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do - test -x "${hook}" && test -f "${hook}" || continue - echo "${data}" | "${hook}" - exitcodes="${exitcodes} $?" -done - -for i in ${exitcodes}; do - [ ${i} -eq 0 ] || exit ${i} -done diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/post-receive.d/gitea b/routers/private/tests/repos/repo1_hook_verification/hooks/post-receive.d/gitea deleted file mode 100644 index f6ad38a1bbe56..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/post-receive.d/gitea +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -# AUTO GENERATED BY GITEA, DO NOT MODIFY -D:/code/golang_code/gitea/go_build_main_go.exe hook --config="D:\\code\\golang_code\\gitea\\custom\\conf\\app.ini" post-receive diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/post-update.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/post-update.sample deleted file mode 100644 index ec17ec1939b7c..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/post-update.sample +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare a packed repository for use over -# dumb transports. -# -# To enable this hook, rename this file to "post-update". - -exec git update-server-info diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-applypatch.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-applypatch.sample deleted file mode 100644 index 4142082bcb939..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-applypatch.sample +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed -# by applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-applypatch". - -. git-sh-setup -precommit="$(git rev-parse --git-path hooks/pre-commit)" -test -x "$precommit" && exec "$precommit" ${1+"$@"} -: diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-commit.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-commit.sample deleted file mode 100644 index e144712c85c05..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-commit.sample +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed. -# Called by "git commit" with no arguments. The hook should -# exit with non-zero status after issuing an appropriate message if -# it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-commit". - -if git rev-parse --verify HEAD >/dev/null 2>&1 -then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=$(git hash-object -t tree /dev/null) -fi - -# If you want to allow non-ASCII filenames set this variable to true. -allownonascii=$(git config --type=bool hooks.allownonascii) - -# Redirect output to stderr. -exec 1>&2 - -# Cross platform projects tend to avoid non-ASCII filenames; prevent -# them from being added to the repository. We exploit the fact that the -# printable range starts at the space character and ends with tilde. -if [ "$allownonascii" != "true" ] && - # Note that the use of brackets around a tr range is ok here, (it's - # even required, for portability to Solaris 10's /usr/bin/tr), since - # the square bracket bytes happen to fall in the designated range. - test $(git diff --cached --name-only --diff-filter=A -z $against | - LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 -then - cat <<\EOF -Error: Attempt to add a non-ASCII file name. - -This can cause problems if you want to work with people on other platforms. - -To be portable it is advisable to rename the file. - -If you know what you are doing you can disable this check using: - - git config hooks.allownonascii true -EOF - exit 1 -fi - -# If there are whitespace errors, print the offending file names and fail. -exec git diff-index --check --cached $against -- diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-merge-commit.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-merge-commit.sample deleted file mode 100644 index 399eab1924e39..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-merge-commit.sample +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed. -# Called by "git merge" with no arguments. The hook should -# exit with non-zero status after issuing an appropriate message to -# stderr if it wants to stop the merge commit. -# -# To enable this hook, rename this file to "pre-merge-commit". - -. git-sh-setup -test -x "$GIT_DIR/hooks/pre-commit" && - exec "$GIT_DIR/hooks/pre-commit" -: diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-push.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-push.sample deleted file mode 100644 index 4ce688d32b753..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-push.sample +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -# An example hook script to verify what is about to be pushed. Called by "git -# push" after it has checked the remote status, but before anything has been -# pushed. If this script exits with a non-zero status nothing will be pushed. -# -# This hook is called with the following parameters: -# -# $1 -- Name of the remote to which the push is being done -# $2 -- URL to which the push is being done -# -# If pushing without using a named remote those arguments will be equal. -# -# Information about the commits which are being pushed is supplied as lines to -# the standard input in the form: -# -# -# -# This sample shows how to prevent push of commits where the log message starts -# with "WIP" (work in progress). - -remote="$1" -url="$2" - -zero=$(git hash-object --stdin &2 "Found WIP commit in $local_ref, not pushing" - exit 1 - fi - fi -done - -exit 0 diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-rebase.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-rebase.sample deleted file mode 100644 index 6cbef5c370d8c..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-rebase.sample +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2006, 2008 Junio C Hamano -# -# The "pre-rebase" hook is run just before "git rebase" starts doing -# its job, and can prevent the command from running by exiting with -# non-zero status. -# -# The hook is called with the following parameters: -# -# $1 -- the upstream the series was forked from. -# $2 -- the branch being rebased (or empty when rebasing the current branch). -# -# This sample shows how to prevent topic branches that are already -# merged to 'next' branch from getting rebased, because allowing it -# would result in rebasing already published history. - -publish=next -basebranch="$1" -if test "$#" = 2 -then - topic="refs/heads/$2" -else - topic=`git symbolic-ref HEAD` || - exit 0 ;# we do not interrupt rebasing detached HEAD -fi - -case "$topic" in -refs/heads/??/*) - ;; -*) - exit 0 ;# we do not interrupt others. - ;; -esac - -# Now we are dealing with a topic branch being rebased -# on top of master. Is it OK to rebase it? - -# Does the topic really exist? -git show-ref -q "$topic" || { - echo >&2 "No such branch $topic" - exit 1 -} - -# Is topic fully merged to master? -not_in_master=`git rev-list --pretty=oneline ^master "$topic"` -if test -z "$not_in_master" -then - echo >&2 "$topic is fully merged to master; better remove it." - exit 1 ;# we could allow it, but there is no point. -fi - -# Is topic ever merged to next? If so you should not be rebasing it. -only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` -only_next_2=`git rev-list ^master ${publish} | sort` -if test "$only_next_1" = "$only_next_2" -then - not_in_topic=`git rev-list "^$topic" master` - if test -z "$not_in_topic" - then - echo >&2 "$topic is already up to date with master" - exit 1 ;# we could allow it, but there is no point. - else - exit 0 - fi -else - not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` - /usr/bin/perl -e ' - my $topic = $ARGV[0]; - my $msg = "* $topic has commits already merged to public branch:\n"; - my (%not_in_next) = map { - /^([0-9a-f]+) /; - ($1 => 1); - } split(/\n/, $ARGV[1]); - for my $elem (map { - /^([0-9a-f]+) (.*)$/; - [$1 => $2]; - } split(/\n/, $ARGV[2])) { - if (!exists $not_in_next{$elem->[0]}) { - if ($msg) { - print STDERR $msg; - undef $msg; - } - print STDERR " $elem->[1]\n"; - } - } - ' "$topic" "$not_in_next" "$not_in_master" - exit 1 -fi - -<<\DOC_END - -This sample hook safeguards topic branches that have been -published from being rewound. - -The workflow assumed here is: - - * Once a topic branch forks from "master", "master" is never - merged into it again (either directly or indirectly). - - * Once a topic branch is fully cooked and merged into "master", - it is deleted. If you need to build on top of it to correct - earlier mistakes, a new topic branch is created by forking at - the tip of the "master". This is not strictly necessary, but - it makes it easier to keep your history simple. - - * Whenever you need to test or publish your changes to topic - branches, merge them into "next" branch. - -The script, being an example, hardcodes the publish branch name -to be "next", but it is trivial to make it configurable via -$GIT_DIR/config mechanism. - -With this workflow, you would want to know: - -(1) ... if a topic branch has ever been merged to "next". Young - topic branches can have stupid mistakes you would rather - clean up before publishing, and things that have not been - merged into other branches can be easily rebased without - affecting other people. But once it is published, you would - not want to rewind it. - -(2) ... if a topic branch has been fully merged to "master". - Then you can delete it. More importantly, you should not - build on top of it -- other people may already want to - change things related to the topic as patches against your - "master", so if you need further changes, it is better to - fork the topic (perhaps with the same name) afresh from the - tip of "master". - -Let's look at this example: - - o---o---o---o---o---o---o---o---o---o "next" - / / / / - / a---a---b A / / - / / / / - / / c---c---c---c B / - / / / \ / - / / / b---b C \ / - / / / / \ / - ---o---o---o---o---o---o---o---o---o---o---o "master" - - -A, B and C are topic branches. - - * A has one fix since it was merged up to "next". - - * B has finished. It has been fully merged up to "master" and "next", - and is ready to be deleted. - - * C has not merged to "next" at all. - -We would want to allow C to be rebased, refuse A, and encourage -B to be deleted. - -To compute (1): - - git rev-list ^master ^topic next - git rev-list ^master next - - if these match, topic has not merged in next at all. - -To compute (2): - - git rev-list master..topic - - if this is empty, it is fully merged to "master". - -DOC_END diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive deleted file mode 100644 index 80ae57095ca0e..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -# AUTO GENERATED BY GITEA, DO NOT MODIFY -data=$(cat) -exitcodes="" -hookname=$(basename $0) -GIT_DIR=${GIT_DIR:-$(dirname $0)/..} - -for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do - test -x "${hook}" && test -f "${hook}" || continue - echo "${data}" | "${hook}" - exitcodes="${exitcodes} $?" -done - -for i in ${exitcodes}; do - [ ${i} -eq 0 ] || exit ${i} -done diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.d/gitea b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.d/gitea deleted file mode 100644 index ff2bda838ccab..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.d/gitea +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -# AUTO GENERATED BY GITEA, DO NOT MODIFY -D:/code/golang_code/gitea/go_build_main_go.exe hook --config="D:\\code\\golang_code\\gitea\\custom\\conf\\app.ini" pre-receive diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.sample deleted file mode 100644 index a1fd29ec14823..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/pre-receive.sample +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# An example hook script to make use of push options. -# The example simply echoes all push options that start with 'echoback=' -# and rejects all pushes when the "reject" push option is used. -# -# To enable this hook, rename this file to "pre-receive". - -if test -n "$GIT_PUSH_OPTION_COUNT" -then - i=0 - while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" - do - eval "value=\$GIT_PUSH_OPTION_$i" - case "$value" in - echoback=*) - echo "echo from the pre-receive-hook: ${value#*=}" >&2 - ;; - reject) - exit 1 - esac - i=$((i + 1)) - done -fi diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/prepare-commit-msg.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/prepare-commit-msg.sample deleted file mode 100644 index 10fa14c5ab013..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/prepare-commit-msg.sample +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare the commit log message. -# Called by "git commit" with the name of the file that has the -# commit message, followed by the description of the commit -# message's source. The hook's purpose is to edit the commit -# message file. If the hook fails with a non-zero status, -# the commit is aborted. -# -# To enable this hook, rename this file to "prepare-commit-msg". - -# This hook includes three examples. The first one removes the -# "# Please enter the commit message..." help message. -# -# The second includes the output of "git diff --name-status -r" -# into the message, just before the "git status" output. It is -# commented because it doesn't cope with --amend or with squashed -# commits. -# -# The third example adds a Signed-off-by line to the message, that can -# still be edited. This is rarely a good idea. - -COMMIT_MSG_FILE=$1 -COMMIT_SOURCE=$2 -SHA1=$3 - -/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" - -# case "$COMMIT_SOURCE,$SHA1" in -# ,|template,) -# /usr/bin/perl -i.bak -pe ' -# print "\n" . `git diff --cached --name-status -r` -# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; -# *) ;; -# esac - -# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" -# if test -z "$COMMIT_SOURCE" -# then -# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" -# fi diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive b/routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive deleted file mode 100644 index d6693b4fd31b3..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -# AUTO GENERATED BY GITEA, DO NOT MODIFY -D:/code/golang_code/gitea/go_build_main_go.exe hook --config="D:\\code\\golang_code\\gitea\\custom\\conf\\app.ini" proc-receive diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive.d/gitea b/routers/private/tests/repos/repo1_hook_verification/hooks/proc-receive.d/gitea deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/push-to-checkout.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/push-to-checkout.sample deleted file mode 100644 index af5a0c0018b5e..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/push-to-checkout.sample +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh - -# An example hook script to update a checked-out tree on a git push. -# -# This hook is invoked by git-receive-pack(1) when it reacts to git -# push and updates reference(s) in its repository, and when the push -# tries to update the branch that is currently checked out and the -# receive.denyCurrentBranch configuration variable is set to -# updateInstead. -# -# By default, such a push is refused if the working tree and the index -# of the remote repository has any difference from the currently -# checked out commit; when both the working tree and the index match -# the current commit, they are updated to match the newly pushed tip -# of the branch. This hook is to be used to override the default -# behaviour; however the code below reimplements the default behaviour -# as a starting point for convenient modification. -# -# The hook receives the commit with which the tip of the current -# branch is going to be updated: -commit=$1 - -# It can exit with a non-zero status to refuse the push (when it does -# so, it must not modify the index or the working tree). -die () { - echo >&2 "$*" - exit 1 -} - -# Or it can make any necessary changes to the working tree and to the -# index to bring them to the desired state when the tip of the current -# branch is updated to the new commit, and exit with a zero status. -# -# For example, the hook can simply run git read-tree -u -m HEAD "$1" -# in order to emulate git fetch that is run in the reverse direction -# with git push, as the two-tree form of git read-tree -u -m is -# essentially the same as git switch or git checkout that switches -# branches while keeping the local changes in the working tree that do -# not interfere with the difference between the branches. - -# The below is a more-or-less exact translation to shell of the C code -# for the default behaviour for git's push-to-checkout hook defined in -# the push_to_deploy() function in builtin/receive-pack.c. -# -# Note that the hook will be executed from the repository directory, -# not from the working tree, so if you want to perform operations on -# the working tree, you will have to adapt your code accordingly, e.g. -# by adding "cd .." or using relative paths. - -if ! git update-index -q --ignore-submodules --refresh -then - die "Up-to-date check failed" -fi - -if ! git diff-files --quiet --ignore-submodules -- -then - die "Working directory has unstaged changes" -fi - -# This is a rough translation of: -# -# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX -if git cat-file -e HEAD 2>/dev/null -then - head=HEAD -else - head=$(git hash-object -t tree --stdin &2 - exit 1 -} - -unset GIT_DIR GIT_WORK_TREE -cd "$worktree" && - -if grep -q "^diff --git " "$1" -then - validate_patch "$1" -else - validate_cover_letter "$1" -fi && - -if test "$GIT_SENDEMAIL_FILE_COUNTER" = "$GIT_SENDEMAIL_FILE_TOTAL" -then - git config --unset-all sendemail.validateWorktree && - trap 'git worktree remove -ff "$worktree"' EXIT && - validate_series -fi diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/update b/routers/private/tests/repos/repo1_hook_verification/hooks/update deleted file mode 100644 index b3570b0004cfa..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/update +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -# AUTO GENERATED BY GITEA, DO NOT MODIFY -exitcodes="" -hookname=$(basename $0) -GIT_DIR=${GIT_DIR:-$(dirname $0/..)} - -for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do - test -x "${hook}" && test -f "${hook}" || continue - "${hook}" $1 $2 $3 - exitcodes="${exitcodes} $?" -done - -for i in ${exitcodes}; do - [ ${i} -eq 0 ] || exit ${i} -done diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/update.d/gitea b/routers/private/tests/repos/repo1_hook_verification/hooks/update.d/gitea deleted file mode 100644 index 1e72edee7335a..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/update.d/gitea +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -# AUTO GENERATED BY GITEA, DO NOT MODIFY -D:/code/golang_code/gitea/go_build_main_go.exe hook --config="D:\\code\\golang_code\\gitea\\custom\\conf\\app.ini" update $1 $2 $3 diff --git a/routers/private/tests/repos/repo1_hook_verification/hooks/update.sample b/routers/private/tests/repos/repo1_hook_verification/hooks/update.sample deleted file mode 100644 index c4d426bc6ee94..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/hooks/update.sample +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/sh -# -# An example hook script to block unannotated tags from entering. -# Called by "git receive-pack" with arguments: refname sha1-old sha1-new -# -# To enable this hook, rename this file to "update". -# -# Config -# ------ -# hooks.allowunannotated -# This boolean sets whether unannotated tags will be allowed into the -# repository. By default they won't be. -# hooks.allowdeletetag -# This boolean sets whether deleting tags will be allowed in the -# repository. By default they won't be. -# hooks.allowmodifytag -# This boolean sets whether a tag may be modified after creation. By default -# it won't be. -# hooks.allowdeletebranch -# This boolean sets whether deleting branches will be allowed in the -# repository. By default they won't be. -# hooks.denycreatebranch -# This boolean sets whether remotely creating branches will be denied -# in the repository. By default this is allowed. -# - -# --- Command line -refname="$1" -oldrev="$2" -newrev="$3" - -# --- Safety check -if [ -z "$GIT_DIR" ]; then - echo "Don't run this script from the command line." >&2 - echo " (if you want, you could supply GIT_DIR then run" >&2 - echo " $0 )" >&2 - exit 1 -fi - -if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then - echo "usage: $0 " >&2 - exit 1 -fi - -# --- Config -allowunannotated=$(git config --type=bool hooks.allowunannotated) -allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch) -denycreatebranch=$(git config --type=bool hooks.denycreatebranch) -allowdeletetag=$(git config --type=bool hooks.allowdeletetag) -allowmodifytag=$(git config --type=bool hooks.allowmodifytag) - -# check for no description -projectdesc=$(sed -e '1q' "$GIT_DIR/description") -case "$projectdesc" in -"Unnamed repository"* | "") - echo "*** Project description file hasn't been set" >&2 - exit 1 - ;; -esac - -# --- Check types -# if $newrev is 0000...0000, it's a commit to delete a ref. -zero=$(git hash-object --stdin &2 - echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 - exit 1 - fi - ;; - refs/tags/*,delete) - # delete tag - if [ "$allowdeletetag" != "true" ]; then - echo "*** Deleting a tag is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/tags/*,tag) - # annotated tag - if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 - then - echo "*** Tag '$refname' already exists." >&2 - echo "*** Modifying a tag is not allowed in this repository." >&2 - exit 1 - fi - ;; - refs/heads/*,commit) - # branch - if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then - echo "*** Creating a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/heads/*,delete) - # delete branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/remotes/*,commit) - # tracking branch - ;; - refs/remotes/*,delete) - # delete tracking branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a tracking branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - *) - # Anything else (is there anything else?) - echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 - exit 1 - ;; -esac - -# --- Finished -exit 0 From 07a054aef47f3af6bce55f530ef51ab749a27914 Mon Sep 17 00:00:00 2001 From: chenyaoran <1290147055@qq.com> Date: Sun, 27 Aug 2023 23:36:03 +0800 Subject: [PATCH 15/18] remove personal info --- models/fixtures/email_address.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/fixtures/email_address.yml b/models/fixtures/email_address.yml index 898735ed95f37..1c32379b60d94 100644 --- a/models/fixtures/email_address.yml +++ b/models/fixtures/email_address.yml @@ -281,7 +281,7 @@ - id: 36 uid: 36 - email: 1290147055@qq.com - lower_email: 1290147055@qq.com + email: abcde@gitea.com + lower_email: abcde@gitea.com is_activated: true is_primary: false From dc24b94bcb4eb5409b11927f7ce5950da0a322b0 Mon Sep 17 00:00:00 2001 From: chenyaoran <1290147055@qq.com> Date: Mon, 28 Aug 2023 09:46:05 +0800 Subject: [PATCH 16/18] rm unnecessary file --- .../private/tests/repos/repo1_hook_verification/description | 1 - .../tests/repos/repo1_hook_verification/info/exclude | 6 ------ 2 files changed, 7 deletions(-) delete mode 100644 routers/private/tests/repos/repo1_hook_verification/description delete mode 100644 routers/private/tests/repos/repo1_hook_verification/info/exclude diff --git a/routers/private/tests/repos/repo1_hook_verification/description b/routers/private/tests/repos/repo1_hook_verification/description deleted file mode 100644 index 498b267a8c781..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/description +++ /dev/null @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff --git a/routers/private/tests/repos/repo1_hook_verification/info/exclude b/routers/private/tests/repos/repo1_hook_verification/info/exclude deleted file mode 100644 index a5196d1be8fb5..0000000000000 --- a/routers/private/tests/repos/repo1_hook_verification/info/exclude +++ /dev/null @@ -1,6 +0,0 @@ -# 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] -# *~ From 88bc2a7e0233dc2ad755352967565df1ecb31ffa Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 29 Aug 2023 08:43:13 +0800 Subject: [PATCH 17/18] Update repo1_hook_verification_dummy_gpg_key.txt --- .../repo1_hook_verification_dummy_gpg_key.txt | 89 +++++++++---------- 1 file changed, 41 insertions(+), 48 deletions(-) diff --git a/routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt b/routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt index 377cdbe97d41b..2b9afc2bffb5f 100644 --- a/routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt +++ b/routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt @@ -1,49 +1,47 @@ - -----BEGIN PGP PUBLIC KEY BLOCK----- - - mQGNBGTrY3UBDAC2HLBqmMplAV15qSnC7g1c4dV406f5EHNhFr95Nup2My6b2eaf - Tlvedv77s8PT/I7F3fy4apOZs5A7w2SsPlLMcQ3ev4uGOsxRtkq5RLy1Yb6SNueX - 0Da2UVKR5KTC5Q6BWaqxwS0IjKOLZ/xz0Pbe/ClV3bZSKBEY2omkVo3Z0HZ771vB - 2clPRvGJ/IdeKOsZ3ZytSFXfyiJBdARmeSPmydXLil8+Ibq5iLAeow5PK8hK1TCO - nKHzLWNqcNq70tyjoHvcGi70iGjoVEEUgPCLLuU8WmzTJwlvA3BuDzjtaO7TLo/j - dE6iqkHtMSS8x+43sAH6hcFRCWAVh/0Uq7n36uGDfNxGnX3YrmX3LR9x5IsBES1r - GGWbpxio4o5GIf/Xd+JgDd9rzJCqRuZ3/sW/TxK38htWaVNZV0kMkHUCTc1ctzWp - Cm635hbFCHBhPYIp+/z206khkAKDbz/CNuU91Wazsh7KO07wrwDtxfDDbInJ8TfH - E2TGjzjQzgChfmcAEQEAAbQXYWJjZGUgPGFiY2RlQGdpdGVhLmNvbT6JAc4EEwEI - ADgWIQRo/BkcvP70fnQCv16xVDFkJim4JgUCZOtjdQIbAwULCQgHAgYVCgkICwIE - FgIDAQIeAQIXgAAKCRCxVDFkJim4Js6+C/9yIjHqc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B - CAAgFiEEaPwZHLz+9H50Ar9esVQxZCYpuCYFAmTrY3UCGwwACgkQsVQxZCYpuCb1 - AAv/dI5YtGxBXaHAMj+lOLmZi5w4t0M7Zafa8tNnWrBwj4KixiXEt52i5YKxuaVD - 3+/cMqidSDp0M5Cxx0wcmnmg+mdFFcowtXIXuk1TGTcHcOCPoXgF6gfoGimNNE1A - w1+EnC4/TbjMCKEM7b2QZ7/CgkBxZJWbScN4Jtawory9LEQqo0/epYJwf+79GHIJ - rpODAPiPJEMKmlej23KyoFuusOi17C0vHCf3GZNj4F2So3LOrcs51qTlOum2MdL5 - oTdqffatzs6p4u5bHBxyRugQlQggTRSK+TXLdxnFXr9ukXjIC2mFir7CCnZHw4e+ - 2JwZfaAom0ZX+pLwrReSop4BPPU2YDzt3XCUk0S9kpiOsN7iFWUMCFreIE50DOxt - 9406kSGopYKVaifbDl4MdLXM4v+oucLe7/yOViT/dm4FcIytIR+jzC8MaLQTB23e - uzm2wOjI1YOwv7Il6PWZyDdU+tyzXcaJ7wSFBeQFZZtqph2TItCeV04HoaKHHc25 - 4akc - =OYIo - -----END PGP PUBLIC KEY BLOCK----- - +# GPG key for abcde@gitea.com +-----BEGIN PGP PUBLIC KEY BLOCK----- +mQGNBGTrY3UBDAC2HLBqmMplAV15qSnC7g1c4dV406f5EHNhFr95Nup2My6b2eaf +Tlvedv77s8PT/I7F3fy4apOZs5A7w2SsPlLMcQ3ev4uGOsxRtkq5RLy1Yb6SNueX +0Da2UVKR5KTC5Q6BWaqxwS0IjKOLZ/xz0Pbe/ClV3bZSKBEY2omkVo3Z0HZ771vB +2clPRvGJ/IdeKOsZ3ZytSFXfyiJBdARmeSPmydXLil8+Ibq5iLAeow5PK8hK1TCO +nKHzLWNqcNq70tyjoHvcGi70iGjoVEEUgPCLLuU8WmzTJwlvA3BuDzjtaO7TLo/j +dE6iqkHtMSS8x+43sAH6hcFRCWAVh/0Uq7n36uGDfNxGnX3YrmX3LR9x5IsBES1r +GGWbpxio4o5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q6BWaqxwS0IjKOLZ/xz0Pbe/ClV3bZSKBEY2omkVo3Z0HZ771vB @@ -125,8 +123,3 @@ dm4FcIytIR+jzC8MaLQTB23euzm2wOjI1YOwv7Il6PWZyDdU+tyzXcaJ7wSFBeQF ZZtqph2TItCeV04HoaKHHc254akc =PPG4 -----END PGP PRIVATE KEY BLOCK----- - - - - - From 5812248d66a95820dffea039bdedbd441ca52d2a Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 29 Aug 2023 08:46:48 +0800 Subject: [PATCH 18/18] Update repo1_hook_verification_dummy_gpg_key.txt --- .../tests/repos/repo1_hook_verification_dummy_gpg_key.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt b/routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt index 2b9afc2bffb5f..3061c75dcbeeb 100644 --- a/routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt +++ b/routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt @@ -1,6 +1,7 @@ # GPG key for abcde@gitea.com -----BEGIN PGP PUBLIC KEY BLOCK----- + mQGNBGTrY3UBDAC2HLBqmMplAV15qSnC7g1c4dV406f5EHNhFr95Nup2My6b2eaf Tlvedv77s8PT/I7F3fy4apOZs5A7w2SsPlLMcQ3ev4uGOsxRtkq5RLy1Yb6SNueX 0Da2UVKR5KTC5Q6BWaqxwS0IjKOLZ/xz0Pbe/ClV3bZSKBEY2omkVo3Z0HZ771vB @@ -42,6 +43,7 @@ uzm2wOjI1YOwv7Il6PWZyDdU+tyzXcaJ7wSFBeQFZZtqph2TItCeV04HoaKHHc25 -----END PGP PUBLIC KEY BLOCK----- -----BEGIN PGP PRIVATE KEY BLOCK----- + lQWGBGTrY3UBDAC2HLBqmMplAV15qSnC7g1c4dV406f5EHNhFr95Nup2My6b2eaf Tlvedv77s8PT/I7F3fy4apOZs5A7w2SsPlLMcQ3ev4uGOsxRtkq5RLy1Yb6SNueX 0Da2UVKR5KTC5Q6BWaqxwS0IjKOLZ/xz0Pbe/ClV3bZSKBEY2omkVo3Z0HZ771vB