1
0
Fork 0
forked from forgejo/forgejo

Update gitignore list (#5258)

* update gitignore

* Handle symlink in tar

* Add some logs
This commit is contained in:
Antoine GIRARD 2018-11-03 23:06:09 +01:00 committed by techknowlogick
parent 54259e2f88
commit 57a8440db3
77 changed files with 767 additions and 159 deletions

View file

@ -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")
}