0

Retrieves list of branches for a given owner and repository

by
Published Oct 17, 2025

Retrieves branch data for a given owner and repository.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Retrieves list of branches for a given owner and repository
4
 * Retrieves branch data for a given owner and repository.
5
 */
6
export async function main(
7
	auth: RT.Sentry,
8
	owner: string,
9
	repository: string,
10
	limit?: string | undefined,
11
	navigation?: string | undefined,
12
	cursor?: string | undefined,
13
	term?: string | undefined
14
) {
15
	const url = new URL(
16
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/prevent/owner/${owner}/repository/${repository}/branches/`
17
	)
18
	for (const [k, v] of [
19
		['limit', limit],
20
		['navigation', navigation],
21
		['cursor', cursor],
22
		['term', term]
23
	]) {
24
		if (v !== undefined && v !== '') {
25
			url.searchParams.append(k, v)
26
		}
27
	}
28
	const response = await fetch(url, {
29
		method: 'GET',
30
		headers: {
31
			Authorization: 'Bearer ' + auth.token
32
		},
33
		body: undefined
34
	})
35
	if (!response.ok) {
36
		const text = await response.text()
37
		throw new Error(`${response.status} ${text}`)
38
	}
39
	return await response.json()
40
}
41