diff options
author | Antoine GIRARD <sapk@users.noreply.github.com> | 2018-11-03 23:06:09 +0100 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2018-11-03 18:06:09 -0400 |
commit | 57a8440db372d3b2a01d3ef12a4a560424a08657 (patch) | |
tree | 6afb467015b1e695ea54eef6d6820d92827eacd7 /scripts | |
parent | 54259e2f880365d65340ade6608007b3c5eb2ed5 (diff) | |
download | gitea-57a8440db372d3b2a01d3ef12a4a560424a08657.tar.gz gitea-57a8440db372d3b2a01d3ef12a4a560424a08657.zip |
Update gitignore list (#5258)
* update gitignore
* Handle symlink in tar
* Add some logs
Diffstat (limited to 'scripts')
-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") } |