MCPcopy Create free account
hub / github.com/nikivdev/go / ensureFlowToml

Function ensureFlowToml

cli/flow/main.go:3159–3179  ·  view source on GitHub ↗
(targetDir, owner, repo, login, privateRepoName string)

Source from the content-addressed store, hash-verified

3157}
3158
3159func ensureFlowToml(targetDir, owner, repo, login, privateRepoName string) (bool, error) {
3160 flowTomlOnDisk := filepath.Join(targetDir, "flow.toml")
3161
3162 info, err := os.Stat(flowTomlOnDisk)
3163 if err == nil {
3164 if info.IsDir() {
3165 return false, fmt.Errorf("%s exists and is a directory", flowTomlOnDisk)
3166 }
3167 return false, nil
3168 }
3169 if !errors.Is(err, os.ErrNotExist) {
3170 return false, fmt.Errorf("stat %s: %w", flowTomlOnDisk, err)
3171 }
3172
3173 content := fmt.Sprintf(flowTomlTemplate, owner, repo, login, privateRepoName)
3174 if err := os.WriteFile(flowTomlOnDisk, []byte(content), 0o644); err != nil {
3175 return false, fmt.Errorf("write %s: %w", flowTomlOnDisk, err)
3176 }
3177
3178 return true, nil
3179}
3180
3181func promptLine(ctx *snap.Context, prompt string) (string, error) {
3182 fmt.Fprint(ctx.Stdout(), prompt)

Callers 1

privateForkRepoFlowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected