MCPcopy Index your code
hub / github.com/rilldata/rill / SetupGitIgnore

Function SetupGitIgnore

cli/pkg/cmdutil/githelper.go:148–177  ·  view source on GitHub ↗
(ctx context.Context, repo drivers.RepoStore)

Source from the content-addressed store, hash-verified

146}
147
148func SetupGitIgnore(ctx context.Context, repo drivers.RepoStore) error {
149 // Ensure .gitignore exists and contains necessary entries
150 contents, err := repo.Get(ctx, ".gitignore")
151 if err != nil {
152 if !strings.Contains(err.Error(), "no such file") {
153 return err
154 }
155 // Create .gitignore if it does not exist
156 err = repo.Put(ctx, ".gitignore", strings.NewReader(".DS_Store\n\n# Rill\n.env\ntmp\n"))
157 if err != nil {
158 return err
159 }
160 return nil
161 }
162
163 gitIgnoreContent := strings.ReplaceAll(contents, "\r\n", "\n")
164 gitIgnoreEntries := strings.Split(gitIgnoreContent, "\n")
165 var added bool
166 for _, path := range []string{".DS_Store", ".env", "tmp"} {
167 if slices.Contains(gitIgnoreEntries, path) {
168 continue // already exists
169 }
170 added = true
171 gitIgnoreContent += fmt.Sprintf("\n%s", path)
172 }
173 if !added {
174 return nil // nothing to add
175 }
176 return repo.Put(ctx, ".gitignore", strings.NewReader(gitIgnoreContent))
177}

Callers 2

DeployProjectMethod · 0.92
DeployWithUploadFlowFunction · 0.92

Calls 4

ContainsMethod · 0.80
GetMethod · 0.65
PutMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected