Update gitignore list (#5258)
* update gitignore * Handle symlink in tar * Add some logs
This commit is contained in:
parent
54259e2f88
commit
57a8440db3
77 changed files with 767 additions and 159 deletions
24
scripts/generate-gitignores.go
vendored
24
scripts/generate-gitignores.go
vendored
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue