github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/git/delete.go (about) 1 package git 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/keybase/client/go/libkb" 8 "github.com/keybase/client/go/protocol/keybase1" 9 ) 10 11 func DeleteMetadata(ctx context.Context, g *libkb.GlobalContext, folder keybase1.FolderHandle, repoName keybase1.GitRepoName) error { 12 teamer := NewTeamer(g) 13 mctx := libkb.NewMetaContext(ctx, g) 14 15 teamIDVis, err := teamer.LookupOrCreate(ctx, folder) 16 if err != nil { 17 return err 18 } 19 20 repos, err := GetMetadata(ctx, g, folder) 21 if err != nil { 22 return err 23 } 24 var repoID keybase1.RepoID 25 for _, repoResult := range repos { 26 repo, err := repoResult.GetIfOk() 27 if err != nil { 28 mctx.Debug("%v", err) 29 continue 30 } 31 if repo.LocalMetadata.RepoName == repoName { 32 repoID = repo.RepoID 33 break 34 } 35 } 36 if repoID == "" { 37 return fmt.Errorf("can't find repo named \"%s\"", repoName) 38 } 39 40 apiArg := libkb.APIArg{ 41 Endpoint: "kbfs/git/team/delete", 42 SessionType: libkb.APISessionTypeREQUIRED, 43 Args: libkb.HTTPArgs{ 44 "team_id": libkb.S{Val: string(teamIDVis.TeamID)}, 45 "repo_id": libkb.S{Val: string(repoID)}, 46 }, 47 } 48 _, err = mctx.G().GetAPI().Post(mctx, apiArg) 49 return err 50 }