@@ -157,6 +157,30 @@ func (r *ProjectBranchService) Rebase(ctx context.Context, branch string, params
157157 return
158158}
159159
160+ // Reset a project branch.
161+ //
162+ // If `branch` === `main`, the branch is reset to `target_config_sha`. Otherwise,
163+ // the branch is reset to `main`.
164+ func (r * ProjectBranchService ) Reset (ctx context.Context , branch string , params ProjectBranchResetParams , opts ... option.RequestOption ) (res * ProjectBranch , err error ) {
165+ opts = slices .Concat (r .Options , opts )
166+ precfg , err := requestconfig .PreRequestOptions (opts ... )
167+ if err != nil {
168+ return
169+ }
170+ requestconfig .UseDefaultParam (& params .Project , precfg .Project )
171+ if params .Project .Value == "" {
172+ err = errors .New ("missing required project parameter" )
173+ return
174+ }
175+ if branch == "" {
176+ err = errors .New ("missing required branch parameter" )
177+ return
178+ }
179+ path := fmt .Sprintf ("v0/projects/%s/branches/%s/reset" , url .PathEscape (params .Project .Value ), url .PathEscape (branch ))
180+ err = requestconfig .ExecuteNewRequest (ctx , http .MethodPut , path , params , & res , opts ... )
181+ return
182+ }
183+
160184// A project branch names a line of development for a project. Like a Git branch,
161185// it points to a Git commit with a set of config files. In addition, a project
162186// branch also points to a set of custom code changes, corresponding to Git
@@ -384,3 +408,21 @@ func (r ProjectBranchRebaseParams) URLQuery() (v url.Values, err error) {
384408 NestedFormat : apiquery .NestedQueryFormatBrackets ,
385409 })
386410}
411+
412+ type ProjectBranchResetParams struct {
413+ // Use [option.WithProject] on the client to set a global default for this field.
414+ Project param.Opt [string ] `path:"project,omitzero,required" json:"-"`
415+ // The commit SHA to reset the main branch to. Required if resetting the main
416+ // branch; disallowed otherwise.
417+ TargetConfigSha param.Opt [string ] `query:"target_config_sha,omitzero" json:"-"`
418+ paramObj
419+ }
420+
421+ // URLQuery serializes [ProjectBranchResetParams]'s query parameters as
422+ // `url.Values`.
423+ func (r ProjectBranchResetParams ) URLQuery () (v url.Values , err error ) {
424+ return apiquery .MarshalWithSettings (r , apiquery.QuerySettings {
425+ ArrayFormat : apiquery .ArrayQueryFormatComma ,
426+ NestedFormat : apiquery .NestedQueryFormatBrackets ,
427+ })
428+ }
0 commit comments