Skip to content

Instantly share code, notes, and snippets.

@fnnzzz
Last active January 28, 2022 13:11
Show Gist options
  • Select an option

  • Save fnnzzz/4af3a3542ae6692e70ab5f3d62b645b3 to your computer and use it in GitHub Desktop.

Select an option

Save fnnzzz/4af3a3542ae6692e70ab5f3d62b645b3 to your computer and use it in GitHub Desktop.
sentry owners
// 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': '[email protected]',
'@uikitcheuko': '[email protected]',
'@JustDenis': '[email protected]',
'@maksimry': '[email protected]',
'@BespalkoSergey': '[email protected]',
'@ihor-pidhornyi': '[email protected]',
'@troospieler': '[email protected]',
'@TamaraGalaktionova': '[email protected]',
'@MaxGerasymov': '[email protected]',
'@nicholas-vi': '[email protected]',
'@anton-skybun': '[email protected]',
'@DenysMaruzhenko': '[email protected]',
'@fnnzzz': '[email protected]'
}
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