type Bitbucket = {
username: string;
password: string;
};
/**
* List changes on an issue
* Returns the list of all changes that have been made to the specified
issue.
*/
export async function main(
auth: Bitbucket,
issue_id: string,
repo_slug: string,
workspace: string,
q: string | undefined,
sort: string | undefined
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/${issue_id}/changes`
);
for (const [k, v] of [
["q", q],
["sort", sort],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
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 375 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* List changes on an issue
* Returns the list of all changes that have been made to the specified
issue.
*/
export async function main(
auth: Bitbucket,
issue_id: string,
repo_slug: string,
workspace: string,
q: string | undefined,
sort: string | undefined
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/${issue_id}/changes`
);
for (const [k, v] of [
["q", q],
["sort", sort],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
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 935 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* List changes on an issue
* Returns the list of all changes that have been made to the specified
issue. Changes are returned in chronological order with the oldest
change first.
Each time an issue is edited in the UI or through the API, an immutable
change record is created under the `/issues/123/changes` endpoint. It
also has a comment associated with the change.
Note that this operation is changing significantly, due to privacy changes.
See the [announcement](https://developer.atlassian.com/cloud/bitbucket/bitbucket-api-changes-gdpr/#changes-to-the-issue-changes-api)
for details.
Changes support [filtering and sorting](/cloud/bitbucket/rest/intro/#filtering) that
can be used to search for specific changes. For instance, to see
when an issue transitioned to "resolved":
```
$ curl -s https://api.bitbucket.org/2.0/repositories/site/master/issues/1/changes \
-G --data-urlencode='q=changes.state.new = "resolved"'
```
This resource is only available on repositories that have the issue
tracker enabled.
N.B.
The `changes.assignee` and `changes.assignee_account_id` fields are not
a `user` object. Instead, they contain the raw `username` and
`account_id` of the user. This is to protect the integrity of the audit
log even after a user account gets deleted.
The `changes.assignee` field is deprecated will disappear in the
future. Use `changes.assignee_account_id` instead.
*/
export async function main(
auth: Bitbucket,
issue_id: string,
repo_slug: string,
workspace: string,
q: string | undefined,
sort: string | undefined
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/${issue_id}/changes`
);
for (const [k, v] of [
["q", q],
["sort", sort],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
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 935 days ago