Skip to content

Commit e965cfd

Browse files
authored
[RFC] move gitignore file to .devbox directory and ignore gen/profile/shell_history (#215)
## Summary With the recent use of nix-profile, the `profile` symlinks are showing up in git history. This is regrettable. This PR adds a `.gitignore` file to `.devbox` directory and ignoring the `gen/`, `profile*` , `nix-profile` and `shell-history` symlinks. Going forward, we should avoid editing this file. Each edit will need to be checked in by our users. So, this PR is a breaking change, in a sense. New features we add that generate files in `.devbox` should be added inside `gen/` if they want to be gitignored. New features that we do want users to check in (like a lock file) can be placed in `.devbox/` (and not `.devbox/gen`). ## How was it tested? in a new devbox project, with `git init` and initial files already committed: - did `devbox shell` to generate the gitignore and other files - did `git status` to inspect changes and found no new file changes were reported. - did `ls -al .devbox` and saw the other files (like gen/ and profile* were generated) as well as `.devbox/.gitignore`.
1 parent 8f7f0c0 commit e965cfd

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

generate.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
//go:embed tmpl/* tmpl/.*
2121
var tmplFS embed.FS
2222

23-
var shellFiles = []string{".gitignore", "development.nix", "shell.nix"}
24-
var buildFiles = []string{".gitignore", "development.nix", "runtime.nix", "Dockerfile", "Dockerfile.dockerignore"}
23+
var shellFiles = []string{"development.nix", "shell.nix"}
24+
var buildFiles = []string{"development.nix", "runtime.nix", "Dockerfile", "Dockerfile.dockerignore"}
2525

2626
func generate(rootPath string, plan *plansdk.Plan, files []string) error {
2727
outPath := filepath.Join(rootPath, ".devbox/gen")
@@ -33,6 +33,14 @@ func generate(rootPath string, plan *plansdk.Plan, files []string) error {
3333
}
3434
}
3535

36+
// Gitignore file is added to the .devbox directory
37+
// TODO savil. Remove this hardcode from here, so this function can be generically defined again
38+
// by accepting the files list parameter.
39+
err := writeFromTemplate(filepath.Join(rootPath, ".devbox"), plan, ".gitignore")
40+
if err != nil {
41+
return errors.WithStack(err)
42+
}
43+
3644
for name, content := range plan.GeneratedFiles {
3745
filePath := filepath.Join(outPath, name)
3846
if err := os.WriteFile(filePath, []byte(content), 0644); err != nil {

tmpl/.gitignore.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
*
2-
.*
2+
.*

0 commit comments

Comments
 (0)