removes old .gitignore, adds new .gitattributes
Signed-off-by: Richard Jones <richard@dagger.io>
This commit is contained in:
15
pkg/pkg.go
15
pkg/pkg.go
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@@ -61,10 +62,18 @@ func Vendor(ctx context.Context, p string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// generate `.gitignore`
|
||||
// remove 0.1-style .gitignore files
|
||||
gitignorePath := path.Join(cuePkgDir, ".gitignore")
|
||||
if contents, err := ioutil.ReadFile(gitignorePath); err == nil {
|
||||
if strings.HasPrefix(string(contents), "# generated by dagger") {
|
||||
os.Remove(gitignorePath)
|
||||
}
|
||||
}
|
||||
|
||||
// generate `.gitattributes` file
|
||||
if err := os.WriteFile(
|
||||
path.Join(cuePkgDir, ".gitignore"),
|
||||
[]byte(fmt.Sprintf("# generated by dagger\ndagger.lock\n%s", strings.Join(modules, "\n"))),
|
||||
path.Join(cuePkgDir, ".gitattributes"),
|
||||
[]byte("# generated by dagger\n** linguist-generated\n"),
|
||||
0600,
|
||||
); err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user