Use this package to check if two given references (
HEAD
, branch name, commit hash, etc.) would produce any conflicts on a merge or rebase attempt.
npm i --save conflicted
const { conflicted, mergable } = require('conflicted');
if (mergable('master', 'feature/branch')) {
console.log('no conflicts!');
} else {
console.log('conflicts');
}
// or
if (conflicted('master', 'feature/branch')) {
console.log('conflicts!');
} else {
console.log('no conflicts');
}
Make sure to install conflicted
globally to use it as a CLI command (npm i -g conflicted
).
#!/bin/bash
if conflicted master feature/branch
then
echo conflicted
else
echo mergable
fi
{
"scripts": {
"postversion": "mergable HEAD master && echo mergable"
}
}
- tests