Created
August 17, 2018 21:07
-
-
Save jgornick/79a4d9334d914058ce0a9146b2a1d21f to your computer and use it in GitHub Desktop.
git: Pre-push confirmation
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
#!/usr/bin/env node | |
const split = require('lodash/split'); | |
const includes = require('lodash/includes'); | |
const Confirm = require('prompt-confirm'); | |
void async function() { | |
console.log(`HUSKY_GIT_PARAMS=${process.env.HUSKY_GIT_PARAMS}`) | |
console.log(`HUSKY_GIT_STDIN=${process.env.HUSKY_GIT_STDIN}`) | |
const [ remote, repositoryUri ] = split(process.env.HUSKY_GIT_PARAMS, ' '); | |
const [ localRef, localSha1, remoteRef, remoteSha1 ] = split(process.env.HUSKY_GIT_STDIN, ' '); | |
if (localRef === '') { | |
process.exit(0); | |
} | |
if (includes(remoteRef, 'feature/webui/')) { | |
const prompt = new Confirm(`Are you sure you want to push to ${remoteRef}?`); | |
const result = await prompt.run(); | |
if (result === false) { | |
process.exit(1); | |
} | |
} | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment