Skip to content

Commit 4962734

Browse files
Copy .git in deploysource provider (#5442) (#5475)
Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]> Signed-off-by: pipecd-bot <[email protected]> Co-authored-by: Shinnosuke Sawada-Dazai <[email protected]>
1 parent 3924dd2 commit 4962734

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

pkg/app/piped/deploysource/deploysource.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,8 @@ func (p *provider) prepare(ctx context.Context, lw io.Writer) (*DeploySource, er
203203
func (p *provider) copy(lw io.Writer) (*DeploySource, error) {
204204
p.copyNum++
205205

206-
src := p.source.RepoDir
207206
dest := fmt.Sprintf("%s-%d", p.source.RepoDir, p.copyNum)
208-
209-
// use tar to exclude the .git directory
210-
// the tar command does not create the destination directory if it does not exist.
211-
// so we need to create it before running the command.
212-
if err := os.MkdirAll(dest, 0700); err != nil {
213-
fmt.Fprintf(lw, "Unable to create the directory to store the copied deploy source (%v)\n", err)
214-
return nil, err
215-
}
216-
cmd := exec.Command("sh", "-c", fmt.Sprintf("tar c -f - -C '%s' --exclude='.git' . | tar x -f - -C '%s'", src, dest))
207+
cmd := exec.Command("cp", "-rf", p.source.RepoDir, dest)
217208
out, err := cmd.CombinedOutput()
218209
if err != nil {
219210
fmt.Fprintf(lw, "Unable to copy deploy source data (%v, %s)\n", err, string(out))

pkg/app/pipedv1/deploysource/deploysource.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,8 @@ func (p *provider) prepare(ctx context.Context, lw io.Writer) (*DeploySource, er
183183
func (p *provider) copy(lw io.Writer) (*DeploySource, error) {
184184
p.copyNum++
185185

186-
src := p.source.RepoDir
187186
dest := fmt.Sprintf("%s-%d", p.source.RepoDir, p.copyNum)
188-
189-
// use tar to exclude the .git directory
190-
// the tar command does not create the destination directory if it does not exist.
191-
// so we need to create it before running the command.
192-
if err := os.MkdirAll(dest, 0700); err != nil {
193-
fmt.Fprintf(lw, "Unable to create the directory to store the copied deploy source (%v)\n", err)
194-
return nil, err
195-
}
196-
cmd := exec.Command("sh", "-c", fmt.Sprintf("tar c -f - -C '%s' --exclude='.git' . | tar x -f - -C '%s'", src, dest))
187+
cmd := exec.Command("cp", "-rf", p.source.RepoDir, dest)
197188
out, err := cmd.CombinedOutput()
198189
if err != nil {
199190
fmt.Fprintf(lw, "Unable to copy deploy source data (%v, %s)\n", err, string(out))

0 commit comments

Comments
 (0)