check-commit.cjs 453 B

12345678910111213141516
  1. const fs = require('fs')
  2. const {
  3. execSync
  4. } = require('child_process')
  5. const message = fs.readFileSync(process.argv[2]).toString('utf8').toLowerCase()
  6. const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim()
  7. if (
  8. (branch === 'master' || branch === 'alpha') &&
  9. !message.startsWith('merge') &&
  10. !message.startsWith('*')
  11. ) {
  12. console.log('You are not allowed to commit directly to master or alpha branch')
  13. process.exit(1)
  14. }