summaryrefslogtreecommitdiffstats
path: root/modules/git/repo_attribute.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git/repo_attribute.go')
-rw-r--r--modules/git/repo_attribute.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/modules/git/repo_attribute.go b/modules/git/repo_attribute.go
index d31203aabd..772ee6ad12 100644
--- a/modules/git/repo_attribute.go
+++ b/modules/git/repo_attribute.go
@@ -185,7 +185,8 @@ func (c *CheckAttributeReader) Init(ctx context.Context) error {
// Run run cmd
func (c *CheckAttributeReader) Run() error {
defer func() {
- _ = c.Close()
+ _ = c.stdinReader.Close()
+ _ = c.stdOut.Close()
}()
stdErr := new(bytes.Buffer)
err := c.cmd.RunWithContext(&RunContext{
@@ -196,14 +197,17 @@ func (c *CheckAttributeReader) Run() error {
Stdout: c.stdOut,
Stderr: stdErr,
PipelineFunc: func(_ context.Context, _ context.CancelFunc) error {
- close(c.running)
+ select {
+ case <-c.running:
+ default:
+ close(c.running)
+ }
return nil
},
})
if err != nil && c.ctx.Err() != nil && err.Error() != "signal: killed" {
return fmt.Errorf("failed to run attr-check. Error: %w\nStderr: %s", err, stdErr.String())
}
-
return nil
}
@@ -243,10 +247,8 @@ func (c *CheckAttributeReader) CheckPath(path string) (rs map[string]string, err
// Close close pip after use
func (c *CheckAttributeReader) Close() error {
- err := c.stdinWriter.Close()
- _ = c.stdinReader.Close()
- _ = c.stdOut.Close()
c.cancel()
+ err := c.stdinWriter.Close()
select {
case <-c.running:
default: