removes old .gitignore, adds new .gitattributes
Signed-off-by: Richard Jones <richard@dagger.io>
This commit is contained in:
parent
c82bc00f87
commit
096c936aaf
15
pkg/pkg.go
15
pkg/pkg.go
@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -61,10 +62,18 @@ func Vendor(ctx context.Context, p string) error {
|
|||||||
return err
|
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(
|
if err := os.WriteFile(
|
||||||
path.Join(cuePkgDir, ".gitignore"),
|
path.Join(cuePkgDir, ".gitattributes"),
|
||||||
[]byte(fmt.Sprintf("# generated by dagger\ndagger.lock\n%s", strings.Join(modules, "\n"))),
|
[]byte("# generated by dagger\n** linguist-generated\n"),
|
||||||
0600,
|
0600,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -2,12 +2,12 @@ setup() {
|
|||||||
load 'helpers'
|
load 'helpers'
|
||||||
|
|
||||||
common_setup
|
common_setup
|
||||||
|
|
||||||
|
TEMPDIR=$(mktemp -d)
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "project init and update" {
|
@test "project init and update" {
|
||||||
TEMPDIR=$(mktemp -d)
|
cd "$TEMPDIR" || exit
|
||||||
echo "TEMPDIR=$TEMPDIR"
|
|
||||||
cd "$TEMPDIR"
|
|
||||||
|
|
||||||
"$DAGGER" project init ./ --name "github.com/foo/bar"
|
"$DAGGER" project init ./ --name "github.com/foo/bar"
|
||||||
test -d ./cue.mod/pkg
|
test -d ./cue.mod/pkg
|
||||||
@ -16,7 +16,15 @@ setup() {
|
|||||||
contents=$(cat ./cue.mod/module.cue)
|
contents=$(cat ./cue.mod/module.cue)
|
||||||
[ "$contents" == 'module: "github.com/foo/bar"' ]
|
[ "$contents" == 'module: "github.com/foo/bar"' ]
|
||||||
|
|
||||||
dagger project update
|
# ensure old 0.1 style .gitignore is removed
|
||||||
|
printf "# generated by dagger\ndagger.lock" > .gitignore
|
||||||
|
|
||||||
|
"$DAGGER" project update
|
||||||
test -d ./cue.mod/pkg/dagger.io
|
test -d ./cue.mod/pkg/dagger.io
|
||||||
test -d ./cue.mod/pkg/universe.dagger.io
|
test -d ./cue.mod/pkg/universe.dagger.io
|
||||||
|
test -f ./cue.mod/pkg/.gitattributes
|
||||||
|
run cat ./cue.mod/pkg/.gitattributes
|
||||||
|
assert_output --partial "generated by dagger"
|
||||||
|
|
||||||
|
test ! -f ./cue.mod/pkg/.gitignore
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user