I am making a routine to be executed before every merge. It will run unit test and check other config files. FYI, it is coded in node.
At the end, if all is allright, it will check if there is any conflict with develop, and just output yes or no to user. Pull request should be manage on gitlab, not on local branch. So there shouldn't be a 'real' merge on the local branch.
Is there any git command available like git -conflitcs-with-this-branch ? And a way to retrive it from nodejs?
Thanks,
Stéphane.
The command that finds merge conflicts is
git merge. Rungit merge, optionally with--no-commitand optionally on a detached HEAD.If there are conflicts,
git mergeexits with a nonzero status. If there are no conflicts,git mergeexits with a zero status. If run with--no-commitGit makes no commit in either case; if run without it, Git makes a merge commit on the current HEAD. If HEAD is detached, this commit affects only HEAD.If you used a detached HEAD, you can now re-attach HEAD to its original branch or commit.
If you used
--no-commit, you can simply rungit merge --abortregardless of whether the merge succeeded or failed.Hence, the simplest command sequence is to run
git merge --no-commit, save exit status, then rungit merge --abort.Note that in all cases, Git will use the index and work-tree during the merge process, so you must make sure they are safe for Git to use for that entire period. (In particular the index and work-tree must be "clean" at the start of the process. They will be clean at the end as well, provided there are no merge drivers that leave messes behind.)
(How to get the exit status of
git mergefrom node.js, I have no idea.)