diff --git a/docs/abstract-api.md b/docs/abstract-api.md index d118dbcc..236c2528 100644 --- a/docs/abstract-api.md +++ b/docs/abstract-api.md @@ -260,7 +260,7 @@ A branch merge state is a description of whether a branch can be cleanly merged | Property | Type | Description | |------------------------|----------|---------------------------------------------------------------------------------------------------| | `state` | `string` | The merge state of the branch relative to its parent branch. May be one of `CLEAN`, `NEEDS_UPDATE`, or `NEEDS_REMOTE_UPDATE` | -| `parentId` | `string` | UUID of the parent btanch | +| `parentId` | `string` | UUID of the parent branch | | `parentCommit` | `string` | SHA that represents the latest commit on the parent branch | | `branchId` | `string` | UUID identifier of the branch, or the string "master" | | `branchCommit` | `string` | SHA that represents the latest commit on the branch | @@ -271,7 +271,7 @@ A branch merge state is a description of whether a branch can be cleanly merged ![CLI][cli-icon] ![API][api-icon] -`branches.mergeState(BranchDescriptor, options?: { parent?: string }): Promise` +`branches.mergeState(BranchDescriptor, { ...RequestOptions, parentId?: string }): Promise` Load the merge state for a specific branch in a project. @@ -282,7 +282,7 @@ abstract.branches.mergeState({ }); ``` -> Note: The API and CLI [transports](/docs/transports) behave differently for merge state. The CLI transport ignores `options.parent`, and _only_ returns one of the three possible merge states (no other fields are included). The API transport includes a value for each field of `BranchMergeState`, and only returns statuses `CLEAN` or `NEEDS_UPDATE`. +> Note: The API and CLI [transports](/docs/transports) behave differently for merge state. The CLI transport ignores `options.parentId`, and _only_ returns one of the three possible merge states (no other fields are included). The API transport includes a value for each field of `BranchMergeState`, and only returns statuses `CLEAN` or `NEEDS_UPDATE`. ## Changesets diff --git a/src/endpoints/Branches.js b/src/endpoints/Branches.js index 610dae3f..7a6f7424 100644 --- a/src/endpoints/Branches.js +++ b/src/endpoints/Branches.js @@ -83,16 +83,18 @@ export default class Branches extends Endpoint { }); } - mergeState(descriptor: BranchDescriptor, options?: { parent?: string }) { + mergeState( + descriptor: BranchDescriptor, + options?: { ...RequestOptions, parentId?: string } = {} + ) { + const { parentId, ...requestOptions } = options; + return this.configureRequest>({ api: async () => { let requestUrl = `projects/${descriptor.projectId}/branches/${descriptor.branchId}/merge_state`; - if (options) { - const { parent } = options; - if (parent) { - const query = querystring.stringify({ parentId: parent }); - requestUrl = `${requestUrl}?${query}`; - } + if (parentId) { + const query = querystring.stringify({ parentId }); + requestUrl = `${requestUrl}?${query}`; } const response = await this.apiRequest(requestUrl, { headers }); return wrap(response.data, response); @@ -107,7 +109,9 @@ export default class Branches extends Endpoint { ]); return wrap(response, response); - } + }, + + requestOptions }); } } diff --git a/tests/endpoints/Branches.test.js b/tests/endpoints/Branches.test.js index b8a36091..f4b80fd7 100644 --- a/tests/endpoints/Branches.test.js +++ b/tests/endpoints/Branches.test.js @@ -246,7 +246,7 @@ describe("branches", () => { branchId: "branch-id", projectId: "project-id" }, - { parent: "parent-id" } + { parentId: "parent-id" } ); expect(response).toEqual({ state: "CLEAN"