add owner role

Signed-off-by: dzdidi <deniszalessky@gmail.com>
This commit is contained in:
dzdidi
2024-02-11 15:59:06 +00:00
parent 217a1dc971
commit 26faea1003

View File

@@ -2,6 +2,9 @@ const home = require('./home')
const fs = require('fs')
const ROLES = {
owner: {
description: 'Read and write to all branches, and ACL management',
},
admin: {
description: 'Read and write to all branches',
},
@@ -23,9 +26,16 @@ function getUserRole (repoName, user) {
return acl.ACL[user]
}
function getOwners (repoName) {
const acl = getACL(repoName)
return Object.keys(acl.ACL).filter(user => acl.ACL[user] === 'owner')
}
function getAdmins (repoName) {
const acl = getACL(repoName)
return Object.keys(acl.ACL).filter(user => acl.ACL[user] === 'admin')
const admins = Object.keys(acl.ACL).filter(user => acl.ACL[user] === 'admin')
const owners = getOwners(repoName)
return [...admins, ...owners].filter((user, i, arr) => arr.indexOf(user) === i)
}
function getContributors (repoName) {
@@ -113,6 +123,7 @@ module.exports = {
getACL,
addProtectedBranch,
removeProtectedBranch,
getOwners,
getAdmins,
getContributors,
getViewers,