I added a script in my workflow, to make merge conflicts visible early in the development process. Perhaps this can help others too.
For each commit, I’d like to know if it could cause merge conflicts to (in my case) develop . So at the end of my normal workflow where I run the unit tests, I check out the develop branch, try to merge the changed branch, and run unit tests on the result.
This helps me to find merge conflicts sooner in our development process.
Here is the script build step that works for me:
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
TARGET_BRANCH="develop"
SOURCE_BRANCH="$BITRISE_GIT_BRANCH"
git reset --hard
git "checkout" "$SOURCE_BRANCH"
git merge "origin/$SOURCE_BRANCH"
git fetch "origin" "$TARGET_BRANCH"
git reset --hard
git checkout origin/$TARGET_BRANCH
git merge $SOURCE_BRANCH
Actually Bitrise Pull Request builds do the same automatically: it clones the target (the one the PR/MR is meant to be merged into) then it git merges the source onto it.
If you remove the Pull Request items from the Trigger Map then no pre-merge will be performed.
You can do it on the web UI as well, but in the YML I’m referring to these as pull request items in the trigger map: