Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: coderabbitai/bitbucket
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.2
Choose a base ref
...
head repository: coderabbitai/bitbucket
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.1.3
Choose a head ref
  • 2 commits
  • 6 files changed
  • 2 contributors

Commits on Mar 4, 2025

  1. 🏷️ Override Bitbucket Cloud's schema to create new branches (#41)

    * 🏷️ Override Bitbucket Cloud's schema to create new branches
    
    * 🔥 Remove test accidentally left in
    NatoBoram authored Mar 4, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    26db646 View commit details
  2. 🔖 v1.1.3

    NatoBoram committed Mar 4, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    NatoBoram Nato Boram
    Copy the full SHA
    677da9e View commit details
Showing with 69 additions and 2 deletions.
  1. +1 −1 package.json
  2. +1 −1 src/cloud/client.ts
  3. +1 −0 src/cloud/index.ts
  4. +1 −0 src/cloud/interfaces/index.ts
  5. +30 −0 src/cloud/interfaces/paths.test.ts
  6. +35 −0 src/cloud/interfaces/paths.ts
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coderabbitai/bitbucket",
"version": "1.1.2",
"version": "1.1.3",
"description": "CodeRabbit's TypeScript API client for connecting to Bitbucket Cloud and Bitbucket Data Center",
"keywords": [
"bitbucket-api-v1",
2 changes: 1 addition & 1 deletion src/cloud/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Client, ClientOptions } from "openapi-fetch"
import createClient from "openapi-fetch"
import type { paths } from "./openapi/index.ts"
import type { paths } from "./interfaces/paths.ts"

/**
* Creates an `openapi-fetch` client using {@link createClient}.
1 change: 1 addition & 0 deletions src/cloud/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./client.ts"
export type * from "./interfaces/index.ts"
export type * as OpenApi from "./openapi/index.ts"
1 change: 1 addition & 0 deletions src/cloud/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type * from "./paths.ts"
30 changes: 30 additions & 0 deletions src/cloud/interfaces/paths.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { test } from "vitest"
import { createBitbucketCloudClient } from "../client.js"
import type { CreateBranchRequest } from "./paths.ts"

async function fetch() {
const response = new Response(JSON.stringify({}), { status: 200 })
return Promise.resolve(response)
}

const client = createBitbucketCloudClient({
baseUrl: "https://api.bitbucket.org/2.0",
fetch,
})

test("CreateBranchRequest", async ({ expect }) => {
const example: CreateBranchRequest = {
name: "smf/create-feature",
target: { hash: "default" },
}

const { response } = await client.POST(
"/repositories/{workspace}/{repo_slug}/refs/branches",
{
params: { path: { repo_slug: "repo_slug", workspace: "workspace" } },
body: example,
},
)

expect(response.status).toBe(200)
})
35 changes: 35 additions & 0 deletions src/cloud/interfaces/paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { paths as openapi } from "../openapi/openapi-typescript.ts"

/**
* Overrides Bitbucket Cloud's OpenAPI schema.
*/
export interface paths
extends Omit<openapi, "/repositories/{workspace}/{repo_slug}/refs/branches"> {
readonly "/repositories/{workspace}/{repo_slug}/refs/branches": Omit<
openapi["/repositories/{workspace}/{repo_slug}/refs/branches"],
"post"
> & {
readonly post: Omit<
openapi["/repositories/{workspace}/{repo_slug}/refs/branches"]["post"],
"requestBody"
> & {
readonly requestBody: {
readonly content: {
readonly "application/json": CreateBranchRequest
}
}
}
}
}

/** Request to create a branch. */
export interface CreateBranchRequest {
/** Name of the new branch */
readonly name: string
/** Where to point the new branch to */
readonly target: Target
}

export interface Target {
readonly hash: string
}