mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
copyutil should not ignore files that just happen to start with .git
This commit is contained in:
@@ -25,7 +25,7 @@ func CopyDir(src string, dst string) error {
|
||||
// don't copy the .git dir
|
||||
if path != src {
|
||||
rel := strings.TrimPrefix(path, src)
|
||||
if strings.HasPrefix(rel, string(filepath.Separator)+".git") {
|
||||
if IsDotGitFolder(rel) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func Diff(sourceDir, destDir string) (sets.String, error) {
|
||||
}
|
||||
|
||||
// skip git repo if it exists
|
||||
if strings.Contains(path, ".git") {
|
||||
if IsDotGitFolder(path) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func Diff(sourceDir, destDir string) (sets.String, error) {
|
||||
}
|
||||
|
||||
// skip git repo if it exists
|
||||
if strings.Contains(path, ".git") {
|
||||
if IsDotGitFolder(path) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -129,6 +129,18 @@ func Diff(sourceDir, destDir string) (sets.String, error) {
|
||||
return diff, nil
|
||||
}
|
||||
|
||||
// IsDotGitFolder checks if the provided path is either the .git folder or
|
||||
// a file underneath the .git folder.
|
||||
func IsDotGitFolder(path string) bool {
|
||||
cleanPath := filepath.ToSlash(filepath.Clean(path))
|
||||
for _, c := range strings.Split(cleanPath, "/") {
|
||||
if c == ".git" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// PrettyFileDiff takes the content of two files and returns the pretty diff
|
||||
func PrettyFileDiff(s1, s2 string) string {
|
||||
dmp := diffmatchpatch.New()
|
||||
|
||||
Reference in New Issue
Block a user