@@ -22,7 +22,6 @@ import (
2222 "io"
2323 "net/http"
2424 "os"
25- pathpkg "path"
2625 "path/filepath"
2726 "strings"
2827
4443 }
4544
4645 ignoreFilePatterns = []string {
46+ ".gitignore" ,
4747 ".dockerignore" ,
4848 }
4949)
@@ -62,17 +62,8 @@ func UploadTarball(directory string, presignedUrl string, excludeFiles []string)
6262 }
6363 }
6464
65- // Normalize and filter ignore patterns
66- {
67- filtered := make ([]string , 0 , len (excludeFiles ))
68- for _ , exclude := range excludeFiles {
69- exclude = strings .TrimSpace (exclude )
70- if exclude == "" || strings .HasPrefix (exclude , "#" ) {
71- continue
72- }
73- filtered = append (filtered , filepath .ToSlash (exclude ))
74- }
75- excludeFiles = filtered
65+ for i , exclude := range excludeFiles {
66+ excludeFiles [i ] = strings .TrimSpace (exclude )
7667 }
7768
7869 var totalSize int64
@@ -85,19 +76,17 @@ func UploadTarball(directory string, presignedUrl string, excludeFiles []string)
8576 if err != nil {
8677 return nil
8778 }
88- // Use forward slashes inside tar archives regardless of OS
89- relPath = filepath .ToSlash (relPath )
9079
9180 for _ , exclude := range excludeFiles {
9281 if exclude == "" || strings .Contains (exclude , "Dockerfile" ) {
9382 continue
9483 }
9584 if info .IsDir () {
96- if strings .HasPrefix (relPath , exclude + "/" ) || relPath == exclude {
85+ if strings .HasPrefix (relPath , exclude + "/" ) || strings . HasPrefix ( relPath , exclude ) {
9786 return filepath .SkipDir
9887 }
9988 }
100- matched , err := pathpkg .Match (exclude , relPath )
89+ matched , err := filepath .Match (exclude , relPath )
10190 if err != nil {
10291 return nil
10392 }
@@ -144,22 +133,20 @@ func UploadTarball(directory string, presignedUrl string, excludeFiles []string)
144133 if err != nil {
145134 return fmt .Errorf ("failed to calculate relative path for %s: %w" , path , err )
146135 }
147- // Normalize to forward slashes for tar header names and matching
148- relPath = filepath .ToSlash (relPath )
149136
150137 for _ , exclude := range excludeFiles {
151138 if exclude == "" || strings .Contains (exclude , "Dockerfile" ) {
152139 continue
153140 }
154141
155142 if info .IsDir () {
156- if strings .HasPrefix (relPath , exclude + "/" ) || relPath == exclude {
143+ if strings .HasPrefix (relPath , exclude + "/" ) || strings . HasPrefix ( relPath , exclude ) {
157144 logger .Debugw ("excluding directory from tarball" , "path" , path )
158145 return filepath .SkipDir
159146 }
160147 }
161148
162- matched , err := pathpkg .Match (exclude , relPath )
149+ matched , err := filepath .Match (exclude , relPath )
163150 if err != nil {
164151 return nil
165152 }
0 commit comments