forgejo/services
Twenty Panda 5561e80b04 fix(hook): ignore unknown push options instead of failing
If a repository has

git config --add push.pushOption submit=".sourcehut/*.yml"

it failed when pushed because of the unknown submit push
option. It will be ignored instead.

Filtering out the push options is done in an earlier stage, when the
hook command runs, before it submits the options map to the private
endpoint.

* move all the push options logic to modules/git/pushoptions
* add 100% test coverage for modules/git/pushoptions

Test coverage for the code paths from which code was moved to the
modules/git/pushoptions package:

* cmd/hook.go:runHookPreReceive
* routers/private/hook_pre_receive.go:validatePushOptions
  tests/integration/git_push_test.go:TestOptionsGitPush runs through
  both. The test verifying the option is rejected was removed and, if
  added again, will fail because the option is now ignored instead of
  being rejected.

* cmd/hook.go:runHookProcReceive
* services/agit/agit.go:ProcReceive
  tests/integration/git_test.go: doCreateAgitFlowPull runs through
  both. It uses variations of AGit related push options.

* cmd/hook.go:runHookPostReceive
* routers/private/hook_post_receive.go:HookPostReceive
  tests/integration/git_test.go:doPushCreate called by TestGit/HTTP/sha1/PushCreate
  runs through both.
  Note that although it provides coverage for this code path it does not use push options.

Fixes: https://codeberg.org/forgejo/forgejo/issues/3651
2024-07-02 21:39:01 +02:00
..
actions Fixes git references wrongly transmitted to the action run 2024-06-30 06:17:40 +02:00
agit fix(hook): ignore unknown push options instead of failing 2024-07-02 21:39:01 +02:00
asymkey
attachment
auth
automerge
context
contexttest
convert Add tag protection via rest api #17862 (#31295) 2024-06-16 13:42:59 +02:00
cron
doctor
externalaccount [Fix] Account Linking UpdateMigrationsByType (#31428) 2024-06-23 12:40:53 +02:00
f3 Enable unparam linter (#31277) 2024-06-16 13:42:58 +02:00
federation
feed
forgejo
forms
gitdiff
indexer
issue
lfs Fix #31185 try fix lfs download from bitbucket failed (#31201) 2024-06-16 13:42:59 +02:00
mailer Enable unparam linter (#31277) 2024-06-16 13:42:58 +02:00
markup
migrations
mirror
notify
org
packages
pull Enable unparam linter (#31277) 2024-06-16 13:42:58 +02:00
release
remote Enable unparam linter (#31277) 2024-06-16 13:42:58 +02:00
repository fix(repository): git push to an adopted repository fails 2024-06-16 19:06:06 +02:00
secrets
task
uinotification
user
webhook
wiki