type Bitbucket = {
username: string;
password: string;
};
/**
* List commits for revision using include/exclude
* Identical to `GET /repositories/{workspace}/{repo_slug}/commits/{revision}`,
except that POST allows clients to place the include and exclude
parameters in the request body to avoid URL length issues.
**Note that this resource does NOT support new commit creation.**
*/
export async function main(
auth: Bitbucket,
repo_slug: string,
revision: string,
workspace: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commits/${revision}`
);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 394 days ago