I think we can simplify this and make the if earlier, otherwise it sounds like a good place for this fix, well done :)
if repo is fork it will always have a parent (or we have a bigger problem)
so what if repo is a fork here?
Looks good to me, thanks for working on this!
Thanks to you :)