Files
renovate/lib/modules/platform/gitlab/roles.ts
T
Stephen Breakey e59b10a17c chore(gitlab): tidy up around gitlab codeowner role support (#44796)
* chore: add zod schema for gitlab getProjectMembers

* chore: swap getRoleAccessLevel regex for startsWith and slice

* chore: drop unnecessary as const
2026-07-23 12:28:44 +00:00

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;
}