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

anonymize-branch.js 1019 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
23
24
25
26
27
28
29
  1. #!/usr/bin/env node
  2. // [start-readme]
  3. //
  4. // Flatten all the commits in the current branch into a single anonymized @Octomerger commit
  5. //
  6. // Usage: script/anonymize-branch.js <new-commit-message> [base-branch]
  7. // Example: script/anonymize-branch.js "nothing to see here"
  8. // If the optional [base-branch] argument is omitted, it will default to `main`
  9. //
  10. // [end-readme]
  11. process.env.GIT_AUTHOR_NAME = process.env.GIT_COMMITTER_NAME = 'Octomerger Bot'
  12. process.env.GIT_AUTHOR_EMAIL = process.env.GIT_COMMITTER_EMAIL = '63058869+Octomerger@users.noreply.github.com'
  13. const { execSync: exec } = require('child_process')
  14. const path = require('path')
  15. const args = process.argv.slice(2)
  16. const message = args[0]
  17. const base = args[1] || 'main'
  18. if (!message || !message.length) {
  19. console.error(`Specify a new commit message in quotes. Example:\n\nscript/${path.basename(module.filename)} "new commit"`)
  20. process.exit()
  21. }
  22. exec(`git reset $(git merge-base ${base} HEAD)`)
  23. exec('git add -A')
  24. exec(`git commit -m "${message}"`)
Tip!

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

Comments

Loading...