Last active
January 28, 2022 13:11
-
-
Save fnnzzz/4af3a3542ae6692e70ab5f3d62b645b3 to your computer and use it in GitHub Desktop.
sentry owners
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 - create file `sentry.js` in root and copy&paste code | |
// 2 - run `node sentry.js` | |
// 3 - paste result here https://sentry.io/settings/rabotaua-eb/projects/alliance-desktop/ownership/ | |
const fs = require('fs') | |
const path = require('path') | |
const codeowners = fs.readFileSync(path.join(__dirname, '.github/CODEOWNERS'), 'utf-8') | |
const usernamesMap = { | |
'@mac2000': 'alexandrm@rabota.ua', | |
'@uikitcheuko': 'alexandrn@rabota.ua', | |
'@JustDenis': 'denise@rabota.ua', | |
'@maksimry': 'maksimry@rabota.ua', | |
'@BespalkoSergey': 'sergeyb@rabota.ua', | |
'@ihor-pidhornyi': 'ihorp@rabota.ua', | |
'@troospieler': 'SergeyPe@rabota.ua', | |
'@TamaraGalaktionova': 'tamaraga@rabota.ua', | |
'@MaxGerasymov': 'maksymg@rabota.ua', | |
'@nicholas-vi': 'nikolayvi@rabota.ua', | |
'@anton-skybun': 'AntonSk@rabota.ua', | |
'@DenysMaruzhenko': 'DenisMa@rabota.ua', | |
'@fnnzzz': 'vladislavf@rabota.ua' | |
} | |
const res = codeowners | |
.split('\n') | |
.filter(line => line.includes('@')) // exclude projects without owners | |
.map(line => { | |
const usernameRegex = /@\w+[-\.]?\w+/g | |
let owners = line.match(usernameRegex) // ['@alex', '@john'] | |
const path = line.replace(usernameRegex, '').trim() // 'libs/acme/feature-bar' | |
owners = owners.map(owner => usernamesMap[owner] || `__PLEASE_UPDATE_MAP_${owner}__`) | |
return { path, owners } | |
}) | |
// handle dir without slash, dir with slash, file extension | |
res.map(i => { | |
try { | |
let _path = '' | |
if (fs.lstatSync(i.path).isDirectory()) { | |
_path = i.path.replace(/\/$/, '') + '/*' | |
} else { | |
_path = i.path | |
} | |
console.log(`path:${_path} ${i.owners.join(' ')}`) | |
} catch (e) { | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment