Skip to content

Commit 4e9115f

Browse files
feat: allow direct upload of spec/config to v0 builds api when merging/rebasing
1 parent 0e00b9c commit 4e9115f

4 files changed

Lines changed: 53 additions & 12 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 22
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless/stainless-v0-4dbed62ce27b115068721f69e83b644ca0b7922e5be12b6469c0c054a371a170.yml
3-
openapi_spec_hash: f4a68de1cb28c33de769c08f68f543ab
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless/stainless-v0-21e9e0ca130a61ba2ba52d51980a6f4b726708fe8094b45045a8ac0ceb7e544c.yml
3+
openapi_spec_hash: 752810fe6848884333c1bcacf28bc777
44
config_hash: 63178ec4b1d2ea5636c8619cffcf129b

pkg/cmd/build_test.go

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func TestBuildsCreate(t *testing.T) {
1717
"builds", "create",
1818
"--wait", "none",
1919
"--project", "project",
20-
"--revision", "string",
20+
"--revision", "{files: {foo: {content: content}}, merge: merge}",
2121
"--allow-empty=true",
2222
"--branch", "branch",
2323
"--commit-message", "commit_message",
@@ -38,7 +38,7 @@ func TestBuildsCreate(t *testing.T) {
3838
"builds", "create",
3939
"--wait", "none",
4040
"--project", "project",
41-
"--revision", "string",
41+
"--revision", "{files: {foo: {content: content}}, merge: merge}",
4242
"--allow-empty=true",
4343
"--branch", "branch",
4444
"--commit-message", "commit_message",
@@ -64,7 +64,11 @@ func TestBuildsCreate(t *testing.T) {
6464
// Test piping YAML data over stdin
6565
pipeData := []byte("" +
6666
"project: project\n" +
67-
"revision: string\n" +
67+
"revision:\n" +
68+
" files:\n" +
69+
" foo:\n" +
70+
" content: content\n" +
71+
" merge: merge\n" +
6872
"allow_empty: true\n" +
6973
"branch: branch\n" +
7074
"commit_message: commit_message\n" +
@@ -127,8 +131,8 @@ func TestBuildsCompare(t *testing.T) {
127131
t,
128132
"--api-key", "string",
129133
"builds", "compare",
130-
"--base", "{branch: branch, revision: string, commit_message: commit_message}",
131-
"--head", "{branch: branch, revision: string, commit_message: commit_message}",
134+
"--base", "{branch: branch, revision: {files: {foo: {content: content}}, merge: merge}, commit_message: commit_message}",
135+
"--head", "{branch: branch, revision: {files: {foo: {content: content}}, merge: merge}, commit_message: commit_message}",
132136
"--project", "project",
133137
"--target", "node",
134138
)
@@ -144,10 +148,10 @@ func TestBuildsCompare(t *testing.T) {
144148
"--api-key", "string",
145149
"builds", "compare",
146150
"--base.branch", "branch",
147-
"--base.revision", "string",
151+
"--base.revision", "{files: {foo: {content: content}}, merge: merge}",
148152
"--base.commit-message", "commit_message",
149153
"--head.branch", "branch",
150-
"--head.revision", "string",
154+
"--head.revision", "{files: {foo: {content: content}}, merge: merge}",
151155
"--head.commit-message", "commit_message",
152156
"--project", "project",
153157
"--target", "node",
@@ -159,11 +163,19 @@ func TestBuildsCompare(t *testing.T) {
159163
pipeData := []byte("" +
160164
"base:\n" +
161165
" branch: branch\n" +
162-
" revision: string\n" +
166+
" revision:\n" +
167+
" files:\n" +
168+
" foo:\n" +
169+
" content: content\n" +
170+
" merge: merge\n" +
163171
" commit_message: commit_message\n" +
164172
"head:\n" +
165173
" branch: branch\n" +
166-
" revision: string\n" +
174+
" revision:\n" +
175+
" files:\n" +
176+
" foo:\n" +
177+
" content: content\n" +
178+
" merge: merge\n" +
167179
" commit_message: commit_message\n" +
168180
"project: project\n" +
169181
"targets:\n" +

pkg/cmd/projectbranch.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ var projectsBranchesRebase = cli.Command{
135135
DefaultText: "main",
136136
QueryPath: "base",
137137
},
138+
&requestflag.Flag[string]{
139+
Name: "commit-message",
140+
Usage: "Optional commit message to use when `files` is provided.",
141+
BodyPath: "commit_message",
142+
},
143+
&requestflag.Flag[map[string]any]{
144+
Name: "files",
145+
Usage: "File contents to commit directly on top of `base`. When provided,\nthe auto-rebase is skipped and the branch is hard-reset to `base`\nbefore the files are committed.",
146+
BodyPath: "files",
147+
},
138148
},
139149
Action: handleProjectsBranchesRebase,
140150
HideHelpCommand: true,
@@ -381,7 +391,7 @@ func handleProjectsBranchesRebase(ctx context.Context, cmd *cli.Command) error {
381391
cmd,
382392
apiquery.NestedQueryFormatBrackets,
383393
apiquery.ArrayQueryFormatComma,
384-
EmptyBody,
394+
ApplicationJSON,
385395
false,
386396
)
387397
if err != nil {

pkg/cmd/projectbranch_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,25 @@ func TestProjectsBranchesRebase(t *testing.T) {
8383
"--project", "project",
8484
"--branch", "branch",
8585
"--base", "base",
86+
"--commit-message", "commit_message",
87+
"--files", "{foo: {content: content}}",
88+
)
89+
})
90+
91+
t.Run("piping data", func(t *testing.T) {
92+
// Test piping YAML data over stdin
93+
pipeData := []byte("" +
94+
"commit_message: commit_message\n" +
95+
"files:\n" +
96+
" foo:\n" +
97+
" content: content\n")
98+
mocktest.TestRunMockTestWithPipeAndFlags(
99+
t, pipeData,
100+
"--api-key", "string",
101+
"projects:branches", "rebase",
102+
"--project", "project",
103+
"--branch", "branch",
104+
"--base", "base",
86105
)
87106
})
88107
}

0 commit comments

Comments
 (0)