Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy .git in deploysource provider #5442

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions pkg/app/piped/deploysource/deploysource.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,8 @@
func (p *provider) copy(lw io.Writer) (*DeploySource, error) {
p.copyNum++

src := p.source.RepoDir
dest := fmt.Sprintf("%s-%d", p.source.RepoDir, p.copyNum)

// use tar to exclude the .git directory
// the tar command does not create the destination directory if it does not exist.
// so we need to create it before running the command.
if err := os.MkdirAll(dest, 0700); err != nil {
fmt.Fprintf(lw, "Unable to create the directory to store the copied deploy source (%v)\n", err)
return nil, err
}
cmd := exec.Command("sh", "-c", fmt.Sprintf("tar c -f - -C '%s' --exclude='.git' . | tar x -f - -C '%s'", src, dest))
cmd := exec.Command("cp", "-rf", p.source.RepoDir, dest)

Check warning on line 207 in pkg/app/piped/deploysource/deploysource.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/piped/deploysource/deploysource.go#L207

Added line #L207 was not covered by tests
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Fprintf(lw, "Unable to copy deploy source data (%v, %s)\n", err, string(out))
Expand Down
11 changes: 1 addition & 10 deletions pkg/app/pipedv1/deploysource/deploysource.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,8 @@
func (p *provider) copy(lw io.Writer) (*DeploySource, error) {
p.copyNum++

src := p.source.RepoDir
dest := fmt.Sprintf("%s-%d", p.source.RepoDir, p.copyNum)

// use tar to exclude the .git directory
// the tar command does not create the destination directory if it does not exist.
// so we need to create it before running the command.
if err := os.MkdirAll(dest, 0700); err != nil {
fmt.Fprintf(lw, "Unable to create the directory to store the copied deploy source (%v)\n", err)
return nil, err
}
cmd := exec.Command("sh", "-c", fmt.Sprintf("tar c -f - -C '%s' --exclude='.git' . | tar x -f - -C '%s'", src, dest))
cmd := exec.Command("cp", "-rf", p.source.RepoDir, dest)

Check warning on line 200 in pkg/app/pipedv1/deploysource/deploysource.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/pipedv1/deploysource/deploysource.go#L200

Added line #L200 was not covered by tests
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Fprintf(lw, "Unable to copy deploy source data (%v, %s)\n", err, string(out))
Expand Down
Loading