@@ -45,18 +45,22 @@ func (g *GoGetter) GetFiles(ctx context.Context, upstream, savePath string) (str
45
45
return "" , errors2.FetchFilesError {Message : err .Error ()}
46
46
}
47
47
48
- // if there is a `.git` directory, remove it - it's dynamic and will break the content hash used by `ship update`
49
- gitPresent , err := g .FS .Exists (path .Join (savePath , ".git" ))
50
- if err != nil {
51
- return "" , errors .Wrap (err , "check for .git directory" )
52
- }
53
- if gitPresent {
54
- err := g .FS .RemoveAll (path .Join (savePath , ".git" ))
48
+ // check if the upstream is a local file - if it is, we shouldn't remove the .git directory
49
+ fileDetector := getter.FileDetector {}
50
+ if _ , foundFile , err := fileDetector .Detect (upstream , savePath ); ! foundFile || err != nil {
51
+ // if there is a `.git` directory, remove it - it's dynamic and will break the content hash used by `ship update`
52
+ gitPresent , err := g .FS .Exists (path .Join (savePath , ".git" ))
55
53
if err != nil {
56
- return "" , errors .Wrap (err , "remove .git directory" )
54
+ return "" , errors .Wrap (err , "check for .git directory" )
55
+ }
56
+ if gitPresent {
57
+ err := g .FS .RemoveAll (path .Join (savePath , ".git" ))
58
+ if err != nil {
59
+ return "" , errors .Wrap (err , "remove .git directory" )
60
+ }
57
61
}
62
+ debug .Log ("event" , "gitPresent.check" , "gitPresent" , gitPresent )
58
63
}
59
- debug .Log ("event" , "gitPresent.check" , "gitPresent" , gitPresent )
60
64
61
65
return filepath .Join (savePath , g .Subdir ), nil
62
66
}
0 commit comments