0
List effective default reviewers
One script reply has been approved by the moderators Verified

Returns the repository's effective default reviewers. This includes both default reviewers defined at the repository level as well as those inherited from its project.

These are the users that are automatically added as reviewers on every new pull request that is created.

Created by hugo697 277 days ago Viewed 8921 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 277 days ago
1
type Bitbucket = {
2
  username: string;
3
  password: string;
4
};
5
/**
6
 * List effective default reviewers
7
 * Returns the repository's effective default reviewers. This includes both default
8
reviewers defined at the repository level as well as those inherited from its project.
9

10
These are the users that are automatically added as reviewers on every
11
new pull request that is created.
12
 */
13
export async function main(
14
  auth: Bitbucket,
15
  repo_slug: string,
16
  workspace: string
17
) {
18
  const url = new URL(
19
    `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/effective-default-reviewers`
20
  );
21

22
  const response = await fetch(url, {
23
    method: "GET",
24
    headers: {
25
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
26
    },
27
    body: undefined,
28
  });
29
  if (!response.ok) {
30
    const text = await response.text();
31
    throw new Error(`${response.status} ${text}`);
32
  }
33
  return await response.json();
34
}
35