Skip to content

Instantly share code, notes, and snippets.

@mmieluch
Created March 6, 2019 09:30
Show Gist options
  • Save mmieluch/74118e38347ac56fd4084dd889a80390 to your computer and use it in GitHub Desktop.
Save mmieluch/74118e38347ac56fd4084dd889a80390 to your computer and use it in GitHub Desktop.
`git unhush` command; takes optional filenames. If no filenames provided it will look for all files currently "assumed unchanged" in the repository and "unhush" them. The underlying Git command is `git update-index --no-assume-unchanged`
#!/usr/bin/env node
const util = require('util')
const exec = util.promisify(require('child_process').exec)
const args = process.argv.slice(2)
if (!args.length) {
console.log('No filenames provided. Aborting!')
process.exitCode = 9
return
}
function _write (...arguments) {
for (let item of arguments) {
if (typeof item === 'string' && item.trim().length) {
console.log(item)
}
}
}
async function unhush () {
const cmdArg = args.join(' ')
const cmd = `git update-index --assume-unchanged ${cmdArg}`
try {
const { stdout, stderr } = await exec(cmd)
if (stderr) {
_write(err.message)
process.exitCode = 1
}
} catch (err) {
_write(err.message)
process.exitCode = 1
}
}
unhush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment