diff options
Diffstat (limited to 'scripts/generate-gitignores.go')
-rw-r--r-- | scripts/generate-gitignores.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/generate-gitignores.go b/scripts/generate-gitignores.go index a169fc0242..0f56ff3a89 100644 --- a/scripts/generate-gitignores.go +++ b/scripts/generate-gitignores.go @@ -59,6 +59,8 @@ func main() { tr := tar.NewReader(gz) + filesToCopy := make(map[string]string, 0) + for { hdr, err := tr.Next() @@ -74,6 +76,12 @@ func main() { continue } + if hdr.Typeflag == tar.TypeSymlink { + fmt.Printf("Found symlink %s -> %s\n", hdr.Name, hdr.Linkname) + filesToCopy[strings.TrimSuffix(filepath.Base(hdr.Name), ".gitignore")] = strings.TrimSuffix(filepath.Base(hdr.Linkname), ".gitignore") + continue + } + out, err := os.Create(path.Join(destination, strings.TrimSuffix(filepath.Base(hdr.Name), ".gitignore"))) if err != nil { @@ -89,5 +97,21 @@ func main() { } } + for dst, src := range filesToCopy { + // Read all content of src to data + src = path.Join(destination, src) + data, err := ioutil.ReadFile(src) + if err != nil { + log.Fatalf("Failed to read src file. %s", err) + } + // Write data to dst + dst = path.Join(destination, dst) + err = ioutil.WriteFile(dst, data, 0644) + if err != nil { + log.Fatalf("Failed to write new file. %s", err) + } + fmt.Printf("Written (copy of %s) %s\n", src, dst) + } + fmt.Println("Done") } |