bench-forgejo/services
wxiaoguang b877504b03
Refactor git.Command.Run*, introduce RunWithContextString and RunWithContextBytes (#19266)
This follows 
* https://github.com/go-gitea/gitea/issues/18553

Introduce `RunWithContextString` and `RunWithContextBytes` to help the refactoring. Add related unit tests. They keep the same behavior to save stderr into err.Error() as `RunInXxx` before.

Remove `RunInDirTimeoutPipeline` `RunInDirTimeoutFullPipeline` `RunInDirTimeout` `RunInDirTimeoutEnv`  `RunInDirPipeline`  `RunInDirFullPipeline`  `RunTimeout`, `RunInDirTimeoutEnvPipeline`, `RunInDirTimeoutEnvFullPipeline`, `RunInDirTimeoutEnvFullPipelineFunc`.

Then remaining `RunInDir` `RunInDirBytes` `RunInDirWithEnv` can be easily refactored in next PR with a simple search & replace:
* before: `stdout, err := RunInDir(path)`
* next: `stdout, _, err := RunWithContextString(&git.RunContext{Dir:path})`

Other changes:
1. When `timeout <= 0`, use default. Because `timeout==0` is meaningless and could cause bugs. And now many functions becomes more simple, eg: `GitGcRepos` 9 lines to 1 line. `Fsck` 6 lines to 1 line.
2. Only set defaultCommandExecutionTimeout when the option `setting.Git.Timeout.Default > 0`
2022-03-31 13:56:22 +02:00
..
agit Delete old git.NewCommand() and use it as git.NewCommandContext() (#18552) 2022-02-06 20:01:47 +01:00
asymkey Make git.OpenRepository accept Context (#19260) 2022-03-30 03:13:41 +08:00
attachment Simplify parameter types (#18006) 2021-12-20 04:41:31 +00:00
auth Add Package Registry (#16510) 2022-03-30 16:42:47 +08:00
comments Move some issue methods as functions (#19255) 2022-03-29 16:57:33 +02:00
context Add ContextUser to http request context (#18798) 2022-03-26 17:04:22 +08:00
cron Add Package Registry (#16510) 2022-03-30 16:42:47 +08:00
externalaccount Refactor auth package (#17962) 2022-01-02 21:12:35 +08:00
forms Add Package Registry (#16510) 2022-03-30 16:42:47 +08:00
gitdiff Make git.OpenRepository accept Context (#19260) 2022-03-30 03:13:41 +08:00
issue Move some issue methods as functions (#19255) 2022-03-29 16:57:33 +02:00
lfs Update HTTP status codes to modern codes (#18063) 2022-03-23 12:54:07 +08:00
mailer Move organization related structs into sub package (#18518) 2022-03-29 14:29:02 +08:00
migrations Move reaction to models/issues/ (#19264) 2022-03-31 17:20:39 +08:00
mirror Use a more general (and faster) method to sanitize URLs with credentials (#19239) 2022-03-31 10:25:40 +08:00
org Add Package Registry (#16510) 2022-03-30 16:42:47 +08:00
packages Add Package Registry (#16510) 2022-03-30 16:42:47 +08:00
pull Make git.OpenRepository accept Context (#19260) 2022-03-30 03:13:41 +08:00
release Make git.OpenRepository accept Context (#19260) 2022-03-30 03:13:41 +08:00
repository Refactor git.Command.Run*, introduce RunWithContextString and RunWithContextBytes (#19266) 2022-03-31 13:56:22 +02:00
task Use a more general (and faster) method to sanitize URLs with credentials (#19239) 2022-03-31 10:25:40 +08:00
user Add Package Registry (#16510) 2022-03-30 16:42:47 +08:00
webhook Only send webhook events to active system webhooks and only deliver to active hooks (#19234) 2022-03-28 11:17:21 +08:00
wiki Make git.OpenRepository accept Context (#19260) 2022-03-30 03:13:41 +08:00