MCPcopy Create free account
hub / github.com/Facets-cloud/flow / UpsertWorkdir

Function UpsertWorkdir

internal/flowdb/db.go:868–883  ·  view source on GitHub ↗
(db *sql.DB, path, name, description, gitRemote string)

Source from the content-addressed store, hash-verified

866}
867
868func UpsertWorkdir(db *sql.DB, path, name, description, gitRemote string) error {
869 now := NowISO()
870 _, err := db.Exec(`
871 INSERT INTO workdirs (path, name, description, git_remote, last_used_at, created_at)
872 VALUES (?, ?, ?, ?, ?, ?)
873 ON CONFLICT(path) DO UPDATE SET
874 name = COALESCE(NULLIF(excluded.name, ''), workdirs.name),
875 description = COALESCE(NULLIF(excluded.description, ''), workdirs.description),
876 git_remote = COALESCE(NULLIF(excluded.git_remote, ''), workdirs.git_remote),
877 last_used_at = excluded.last_used_at
878 `, path, NullIfEmpty(name), NullIfEmpty(description), NullIfEmpty(gitRemote), now, now)
879 if err != nil {
880 return fmt.Errorf("upsert workdir %s: %w", path, err)
881 }
882 return nil
883}
884
885// ---------- playbook models ----------
886

Callers 8

addOwnerFunction · 0.92
addPlaybookFunction · 0.92
cmdWorkdirAddFunction · 0.92
cmdWorkdirScanFunction · 0.92
addProjectFunction · 0.92
addTaskFunction · 0.92
TestWorkdirUpsertFunction · 0.85

Calls 2

NowISOFunction · 0.85
NullIfEmptyFunction · 0.85

Tested by 2

TestWorkdirUpsertFunction · 0.68