Skip to content

Commit f1aafe1

Browse files
stainless-app[bot]yjp20
authored andcommitted
feat: [WIP] add branch rebasing to the API
1 parent 1b670f3 commit f1aafe1

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 18
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-c9dbcee416d3ce938a657e6fa1883ea8c40202b0bfb46d7dd5617cf2e844786c.yml
3-
openapi_spec_hash: 4bf38db5a15196d74647490ceebfbb9b
4-
config_hash: e968e8b5403abb8f4faa0b9753db713e
1+
configured_endpoints: 19
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-a3a29065ad8fdc320ffaa9b130843b1d0dc3670a045795fc624936bded3bfe0f.yml
3+
openapi_spec_hash: e1b7059453520913dc4a07ccc9114ed8
4+
config_hash: 2c8b076df3f32923bfff0b87a83c9bf5

pkg/cmd/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ stl builds create --branch <branch>`,
6767
&projectsBranchesRetrieve,
6868
&projectsBranchesList,
6969
&projectsBranchesDelete,
70+
&projectsBranchesRebase,
7071
},
7172
},
7273

pkg/cmd/projectbranch.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,28 @@ var projectsBranchesDelete = cli.Command{
103103
HideHelpCommand: true,
104104
}
105105

106+
var projectsBranchesRebase = cli.Command{
107+
Name: "rebase",
108+
Usage: "Rebase a project branch",
109+
Flags: []cli.Flag{
110+
&cli.StringFlag{
111+
Name: "project",
112+
},
113+
&cli.StringFlag{
114+
Name: "branch",
115+
},
116+
&jsonflag.JSONStringFlag{
117+
Name: "base",
118+
Config: jsonflag.JSONConfig{
119+
Kind: jsonflag.Query,
120+
Path: "base",
121+
},
122+
},
123+
},
124+
Action: handleProjectsBranchesRebase,
125+
HideHelpCommand: true,
126+
}
127+
106128
func handleProjectsBranchesCreate(ctx context.Context, cmd *cli.Command) error {
107129
cc := getAPICommandContext(cmd)
108130
params := stainless.ProjectBranchNewParams{}
@@ -182,3 +204,23 @@ func handleProjectsBranchesDelete(ctx context.Context, cmd *cli.Command) error {
182204
fmt.Printf("%s\n", ColorizeJSON(string(res), os.Stdout))
183205
return nil
184206
}
207+
208+
func handleProjectsBranchesRebase(ctx context.Context, cmd *cli.Command) error {
209+
cc := getAPICommandContext(cmd)
210+
params := stainless.ProjectBranchRebaseParams{}
211+
if cmd.IsSet("project") {
212+
params.Project = stainless.String(cmd.Value("project").(string))
213+
}
214+
res, err := cc.client.Projects.Branches.Rebase(
215+
context.TODO(),
216+
cmd.Value("branch").(string),
217+
params,
218+
option.WithMiddleware(cc.AsMiddleware()),
219+
)
220+
if err != nil {
221+
return err
222+
}
223+
224+
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
225+
return nil
226+
}

0 commit comments

Comments
 (0)