forgejo/services/repository
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
..
archiver Make git.OpenRepository accept Context (#19260) 2022-03-30 03:13:41 +08:00
files Make git.OpenRepository accept Context (#19260) 2022-03-30 03:13:41 +08:00
adopt.go Make git.OpenRepository accept Context (#19260) 2022-03-30 03:13:41 +08:00
adopt_test.go format with gofumpt (#18184) 2022-01-20 18:46:10 +01:00
avatar.go Some repository refactors (#17950) 2021-12-12 23:48:20 +08:00
avatar_test.go Some repository refactors (#17950) 2021-12-12 23:48:20 +08:00
branch.go Use full output of git show-ref --tags to get tags for PushUpdateAddTag (#19235) 2022-03-29 19:12:33 +02:00
cache.go Move repository model into models/repo (#17933) 2021-12-10 09:27:50 +08:00
check.go Refactor git.Command.Run*, introduce RunWithContextString and RunWithContextBytes (#19266) 2022-03-31 13:56:22 +02:00
fork.go Refactor git.Command.Run*, introduce RunWithContextString and RunWithContextBytes (#19266) 2022-03-31 13:56:22 +02:00
fork_test.go Make git.OpenRepository accept Context (#19260) 2022-03-30 03:13:41 +08:00
hooks.go Make git.OpenRepository accept Context (#19260) 2022-03-30 03:13:41 +08:00
main_test.go Decouple unit test code from business code (#17623) 2021-11-12 22:36:47 +08:00
push.go Make git.OpenRepository accept Context (#19260) 2022-03-30 03:13:41 +08:00
repository.go Add Package Registry (#16510) 2022-03-30 16:42:47 +08:00
template.go Some repository refactors (#17950) 2021-12-12 23:48:20 +08:00
transfer.go Move organization related structs into sub package (#18518) 2022-03-29 14:29:02 +08:00
transfer_test.go Move organization related structs into sub package (#18518) 2022-03-29 14:29:02 +08:00