You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
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`
2 years ago
..
archiver Make git.OpenRepository accept Context (#19260) 2 years ago
files Make git.OpenRepository accept Context (#19260) 2 years ago
adopt.go Make git.OpenRepository accept Context (#19260) 2 years ago
adopt_test.go format with gofumpt (#18184) 2 years ago
avatar.go Some repository refactors (#17950) 3 years ago
avatar_test.go Some repository refactors (#17950) 3 years ago
branch.go Use full output of git show-ref --tags to get tags for PushUpdateAddTag (#19235) 2 years ago
cache.go Move repository model into models/repo (#17933) 3 years ago
check.go Refactor `git.Command.Run*`, introduce `RunWithContextString` and `RunWithContextBytes` (#19266) 2 years ago
fork.go Refactor `git.Command.Run*`, introduce `RunWithContextString` and `RunWithContextBytes` (#19266) 2 years ago
fork_test.go Make git.OpenRepository accept Context (#19260) 2 years ago
hooks.go Make git.OpenRepository accept Context (#19260) 2 years ago
main_test.go Decouple unit test code from business code (#17623) 3 years ago
push.go Make git.OpenRepository accept Context (#19260) 2 years ago
repository.go Add Package Registry (#16510) 2 years ago
template.go Some repository refactors (#17950) 3 years ago
transfer.go Move organization related structs into sub package (#18518) 2 years ago
transfer_test.go Move organization related structs into sub package (#18518) 2 years ago