Skip to content

Commit

Permalink
fix: do not copy .gitignore into container
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Wolf <[email protected]>
  • Loading branch information
ZauberNerd and KnisterPeter committed May 26, 2021
1 parent de92d68 commit 57b1b3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 5 additions & 0 deletions pkg/container/docker_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,11 @@ func (cr *containerReference) copyDir(dstPath string, srcPath string, useGitIgno
return err
}

if fi.Name() == ".gitignore" {
log.Debug("Ignoring .gitignore file")
return nil
}

sansPrefix := strings.TrimPrefix(file, srcPrefix)
split := strings.Split(sansPrefix, string(filepath.Separator))
if ignorer != nil && ignorer.Match(split, fi.IsDir()) {
Expand Down
13 changes: 5 additions & 8 deletions pkg/runner/step_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,10 @@ func (sc *StepContext) runAction(actionDir string, actionPath string) common.Exe
return nil
}
}
err := removeGitIgnore(actionDir)
if err != nil {
return err
}
// err := removeGitIgnore(actionDir)
// if err != nil {
// return err
// }
return rc.JobContainer.CopyDir(containerActionDir+"/", actionLocation+"/", rc.Config.UseGitIgnore)(ctx)
}

Expand Down Expand Up @@ -654,12 +654,9 @@ func removeGitIgnore(directory string) error {
if _, err := os.Stat(gitIgnorePath); err == nil {
// .gitignore exists
log.Debugf("Removing %s before docker cp", gitIgnorePath)
// ignore errors which might happen if multiple jobs try to delete the
// .gitignore file in parallel
err := os.Remove(gitIgnorePath)
if err != nil {
log.Warn("Error while removing .gitignore")
return nil
return err
}
}
return nil
Expand Down

0 comments on commit 57b1b3f

Please sign in to comment.