Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-28 04:36:11 +01:00
forgejo/routers
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
..
api Move reaction to models/issues/ (#19264) 2022-03-31 17:20:39 +08:00
common Update HTTP status codes to modern codes (#18063) 2022-03-23 12:54:07 +08:00
install Update HTTP status codes to modern codes (#18063) 2022-03-23 12:54:07 +08:00
private Make git.OpenRepository accept Context (#19260) 2022-03-30 03:13:41 +08:00
utils A better go code formatter, and now make fmt can run in Windows (#17684) 2021-11-17 20:34:35 +08:00
web Refactor git.Command.Run*, introduce RunWithContextString and RunWithContextBytes (#19266) 2022-03-31 13:56:22 +02:00
init.go Add Package Registry (#16510) 2022-03-30 16:42:47 +08:00