Skip to content

Commit ce9328e

Browse files
feat(api): add build compare to v0
1 parent ac9557a commit ce9328e

File tree

3 files changed

+68
-4
lines changed

3 files changed

+68
-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: 14
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-0a783d3d5e880034a48debf3b4c2d24ff2762b13554609850833c642c904c35e.yml
3-
openapi_spec_hash: 188380eea2d43b13fdf51ba482c33766
4-
config_hash: 7902a744b4100cecc9894905e856d10b
1+
configured_endpoints: 15
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-6707704fb4cbc87d367d0813979036b8acbcc7f6eff62f7f5e8b9f016920d3ad.yml
3+
openapi_spec_hash: 3af7623ae449e42f72c7319fa3f8e387
4+
config_hash: 47554631761ae001c9bf76a4fb4ba43a

build.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,52 @@ var buildsList = cli.Command{
188188
HideHelpCommand: true,
189189
}
190190

191+
var buildsCompare = cli.Command{
192+
Name: "compare",
193+
Usage: "Creates two builds whose outputs can be compared directly",
194+
Flags: []cli.Flag{
195+
&cli.StringFlag{
196+
Name: "base.revision",
197+
Action: getAPIFlagAction[string]("body", "base.revision"),
198+
},
199+
&cli.StringFlag{
200+
Name: "base.branch",
201+
Action: getAPIFlagAction[string]("body", "base.branch"),
202+
},
203+
&cli.StringFlag{
204+
Name: "base.commit_message",
205+
Action: getAPIFlagAction[string]("body", "base.commit_message"),
206+
},
207+
&cli.StringFlag{
208+
Name: "head.revision",
209+
Action: getAPIFlagAction[string]("body", "head.revision"),
210+
},
211+
&cli.StringFlag{
212+
Name: "head.branch",
213+
Action: getAPIFlagAction[string]("body", "head.branch"),
214+
},
215+
&cli.StringFlag{
216+
Name: "head.commit_message",
217+
Action: getAPIFlagAction[string]("body", "head.commit_message"),
218+
},
219+
&cli.StringFlag{
220+
Name: "project",
221+
Action: getAPIFlagAction[string]("body", "project"),
222+
},
223+
&cli.StringFlag{
224+
Name: "targets",
225+
Action: getAPIFlagAction[string]("body", "targets.#"),
226+
},
227+
&cli.StringFlag{
228+
Name: "+target",
229+
Action: getAPIFlagAction[string]("body", "targets.-1"),
230+
},
231+
},
232+
Before: initAPICommand,
233+
Action: handleBuildsCompare,
234+
HideHelpCommand: true,
235+
}
236+
191237
func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error {
192238
cc := getAPICommandContext(ctx, cmd)
193239

@@ -450,3 +496,20 @@ func handleBuildsList(ctx context.Context, cmd *cli.Command) error {
450496
fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
451497
return nil
452498
}
499+
500+
func handleBuildsCompare(ctx context.Context, cmd *cli.Command) error {
501+
cc := getAPICommandContext(ctx, cmd)
502+
503+
res, err := cc.client.Builds.Compare(
504+
context.TODO(),
505+
stainlessv0.BuildCompareParams{},
506+
option.WithMiddleware(cc.AsMiddleware()),
507+
option.WithRequestBody("application/json", cc.body),
508+
)
509+
if err != nil {
510+
return err
511+
}
512+
513+
fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
514+
return nil
515+
}

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func main() {
6262
&buildsCreate,
6363
&buildsRetrieve,
6464
&buildsList,
65+
&buildsCompare,
6566
},
6667
},
6768

0 commit comments

Comments
 (0)