mirror of
https://github.com/docker/compose.git
synced 2025-04-08 17:05:13 +02:00
capture git fetch output when debug output is enabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
cb0b5f6e27
commit
ee33143026
@ -17,6 +17,8 @@
|
||||
package remote
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
@ -31,6 +33,7 @@ import (
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/compose/v2/pkg/api"
|
||||
"github.com/moby/buildkit/util/gitutil"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const GIT_REMOTE_ENABLED = "COMPOSE_EXPERIMENTAL_GIT_REMOTE"
|
||||
@ -169,7 +172,8 @@ func (g gitRemoteLoader) checkout(ctx context.Context, path string, ref *gitutil
|
||||
cmd = exec.CommandContext(ctx, "git", "fetch", "--depth=1", "origin", ref.Commit)
|
||||
cmd.Env = g.gitCommandEnv()
|
||||
cmd.Dir = path
|
||||
err = cmd.Run()
|
||||
|
||||
err = g.run(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -183,6 +187,19 @@ func (g gitRemoteLoader) checkout(ctx context.Context, path string, ref *gitutil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g gitRemoteLoader) run(cmd *exec.Cmd) error {
|
||||
if logrus.IsLevelEnabled(logrus.DebugLevel) {
|
||||
output, err := cmd.CombinedOutput()
|
||||
scanner := bufio.NewScanner(bytes.NewBuffer(output))
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
logrus.Debug(line)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func (g gitRemoteLoader) gitCommandEnv() []string {
|
||||
env := types.NewMapping(os.Environ())
|
||||
if env["GIT_TERMINAL_PROMPT"] == "" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user