diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-05-25 07:20:09 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-05-30 09:09:53 +0300 |
commit | b62d7112a5e1591053abf68d1a4ff3f406327339 (patch) | |
tree | 32646be6fa3184e09c8599a6f115e6f3465a31cb | |
parent | 96bbfa25468d5c2655c4f5fc609a72192f6d0873 (diff) |
gitaly-lfs-smudge: Split out a new `run()` function
We're about to move loading the configuration out of `smudge()` so that
it doesn't need to depend on any global state anymore. Prepare for this
by pulling out a separate `run()` function so that we can continue to
log any errors and exit with an error code in a single location, only.
-rw-r--r-- | cmd/gitaly-lfs-smudge/main.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cmd/gitaly-lfs-smudge/main.go b/cmd/gitaly-lfs-smudge/main.go index 2d39f2619..c29d03d25 100644 --- a/cmd/gitaly-lfs-smudge/main.go +++ b/cmd/gitaly-lfs-smudge/main.go @@ -41,7 +41,7 @@ func main() { } defer closer.Close() - if err := smudge(os.Stdout, os.Stdin, &envConfig{}); err != nil { + if err := run(os.Stdout, os.Stdin, &envConfig{}); err != nil { log.WithError(err).Error(err) os.Exit(1) } @@ -61,3 +61,11 @@ func initLogging(p configProvider) (io.Closer, error) { log.WithOutputName(filepath), ) } + +func run(out io.Writer, in io.Reader, cfgProvider configProvider) error { + if err := smudge(out, in, cfgProvider); err != nil { + return fmt.Errorf("running smudge filter: %w", err) + } + + return nil +} |