mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 23:11:31 +00:00
e59b10a17c
* chore: add zod schema for gitlab getProjectMembers * chore: swap getRoleAccessLevel regex for startsWith and slice * chore: drop unnecessary as const
25 lines
735 B
TypeScript
25 lines
735 B
TypeScript
// See: https://docs.gitlab.com/api/users/#list-projects-and-groups-that-a-user-is-a-member-of
|
|
const roleAccessLevels: Record<string, number> = {
|
|
no_access: 0,
|
|
minimal_access: 5,
|
|
guest: 10,
|
|
planner: 15,
|
|
reporter: 20,
|
|
developer: 30,
|
|
maintainer: 40,
|
|
owner: 50,
|
|
};
|
|
|
|
/**
|
|
* Parse a GitLab CODEOWNERS role handle (`@@developer`, `@@maintainer`,
|
|
* `@@owner`, etc) into its access level. Returns `null` when the handle is not a
|
|
* recognized role, so `getRoleAccessLevel(x) !== null` doubles as a role check.
|
|
*/
|
|
export function getRoleAccessLevel(handle: string): number | null {
|
|
if (!handle.startsWith('@@')) {
|
|
return null;
|
|
}
|
|
const role = handle.slice(2).toLowerCase();
|
|
return roleAccessLevels[role] ?? null;
|
|
}
|