Pre-commit lint hook had made the use of ternaries harder to read
than I'd originally intended so I introduced an additional
variable which explains what is being checked and keeps ternaries
from becoming obscured.
Based on review by @nirname. I had originally been trying
to minimise number of new arguments being passed to
rerouting check but as the branch curve check is not used
elsewhere and is part of the same rerouting check it makes
sense for them to be together.
Position information now passed to rerouting fn instead.
My focus earlier on had been on relationship to `main` branch
so this is to ensure that we have some tests that cover
relationship between a pair of branches that doesn't
include `main`.
Hypothesised that working out which branch needed checking for
overlapping commits might be missing, so added that as a
nested ternary and passed result as new argument to rerouting
check.
If commits are found on the branch which will be getting the
curve (whichever branch is lower or more to the right of main
than the other, for now), then the arrow will be rerouted.
I may refactor in a follow-up commit and I think there's scope
to simplify the logic but this is a test for now.
In these tests, a new branch is created but then a commit is made
on the main branch before the new branch gets a commit. This
important to see what happens with rerouting of arrows.
Suggested by @nirname in PR review of #4927.
Followed practice of other tests so that commit IDs are
stabilised (i.e., not randomly generated) and therefore
don't show repeatedly in Cypress diff output screenshots
Checking if branch was same as main turned out to be redundant
for now, since there don't seem to be any cases where routing
curves into main.
This fixes issue found in review by @nirname and avoids a
situation where branching from the same commit results in
unnecessary rerouting.
The function also now does an additional check to see
if source branch in overlap check is on main.
As we're no longer purely checking for an overlap and
the only use of this function is to reroute the arrows
to avoid running over commits, this more literal name
should be clearer.