Skip to content

Commit

Permalink
Add gitutil.WithExec(runWithStandardUmask) to Git invocations
Browse files Browse the repository at this point in the history
This fixes umask bugs while building from a remote Git URL where `ADD`/`COPY`'d files end up with `666`/`777` permissions instead of `644`/`755`.

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
  • Loading branch information
tianon committed Jun 26, 2024
1 parent aaaf86e commit 2448671
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions source/git/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ func (gs *gitSourceHandler) Snapshot(ctx context.Context, g session.Group) (out
if err := os.MkdirAll(checkoutDir, 0711); err != nil {
return nil, err
}
checkoutGit := git.New(gitutil.WithWorkTree(checkoutDir), gitutil.WithGitDir(checkoutDirGit))
checkoutGit := git.New(gitutil.WithExec(runWithStandardUmask), gitutil.WithWorkTree(checkoutDir), gitutil.WithGitDir(checkoutDirGit))
_, err = checkoutGit.Run(ctx, "-c", "init.defaultBranch=master", "init")
if err != nil {
return nil, err
Expand Down Expand Up @@ -586,7 +586,7 @@ func (gs *gitSourceHandler) Snapshot(ctx context.Context, g session.Group) (out
return nil, errors.Wrapf(err, "failed to create temporary checkout dir")
}
}
checkoutGit := git.New(gitutil.WithWorkTree(cd), gitutil.WithGitDir(gitDir))
checkoutGit := git.New(gitutil.WithExec(runWithStandardUmask), gitutil.WithWorkTree(cd), gitutil.WithGitDir(gitDir))
_, err = checkoutGit.Run(ctx, "checkout", ref, "--", ".")
if err != nil {
return nil, errors.Wrapf(err, "failed to checkout remote %s", urlutil.RedactCredentials(gs.src.Remote))
Expand Down Expand Up @@ -620,7 +620,7 @@ func (gs *gitSourceHandler) Snapshot(ctx context.Context, g session.Group) (out
}
}

git = git.New(gitutil.WithWorkTree(checkoutDir), gitutil.WithGitDir(gitDir))
git = git.New(gitutil.WithExec(runWithStandardUmask), gitutil.WithWorkTree(checkoutDir), gitutil.WithGitDir(gitDir))
_, err = git.Run(ctx, "submodule", "update", "--init", "--recursive", "--depth=1")
if err != nil {
return nil, errors.Wrapf(err, "failed to update submodules for %s", urlutil.RedactCredentials(gs.src.Remote))
Expand Down

0 comments on commit 2448671

Please sign in to comment.