Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

prevent-pushes-to-main.js 766 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  1. #!/usr/bin/env node
  2. const { execSync } = require('child_process')
  3. // [start-readme]
  4. // This script is intended to be used as a git "prepush" hook.
  5. // If the current branch is main, it will exit unsuccessfully and prevent the push.
  6. // [end-readme]
  7. const productionBranch = 'main'
  8. const currentBranch = execSync('git symbolic-ref --short HEAD', { encoding: 'utf8' }).trim()
  9. if (currentBranch === productionBranch) {
  10. console.error('')
  11. console.error(`🤚 Whoa! Pushing to the ${productionBranch} branch has been disabled to prevent accidental deployments to production.`)
  12. console.error('')
  13. console.error('If you\'re aware of the risks and really want to push to this branch, add --no-verify to bypass this check.')
  14. console.error('')
  15. process.exit(1)
  16. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...