MCPcopy
hub / github.com/wavetermdev/waveterm / RevertDraft

Function RevertDraft

pkg/waveappstore/waveappstore.go:151–177  ·  view source on GitHub ↗
(draftAppId string)

Source from the content-addressed store, hash-verified

149}
150
151func RevertDraft(draftAppId string) error {
152 if err := ValidateAppId(draftAppId); err != nil {
153 return fmt.Errorf("invalid appId: %w", err)
154 }
155
156 appNS, appName, _ := ParseAppId(draftAppId)
157 if appNS != AppNSDraft {
158 return fmt.Errorf("appId must be in draft namespace, got: %s", appNS)
159 }
160
161 draftDir, err := GetAppDir(draftAppId)
162 if err != nil {
163 return err
164 }
165
166 localAppId := MakeAppId(AppNSLocal, appName)
167 localDir, err := GetAppDir(localAppId)
168 if err != nil {
169 return err
170 }
171
172 if _, err := os.Stat(localDir); os.IsNotExist(err) {
173 return fmt.Errorf("local app does not exist: %s", localDir)
174 }
175
176 return copyDir(localDir, draftDir)
177}
178
179func MakeDraftFromLocal(localAppId string) (string, error) {
180 if err := ValidateAppId(localAppId); err != nil {

Callers

nothing calls this directly

Calls 6

ValidateAppIdFunction · 0.85
ParseAppIdFunction · 0.85
GetAppDirFunction · 0.85
MakeAppIdFunction · 0.85
copyDirFunction · 0.85
StatMethod · 0.80

Tested by

no test coverage detected