git root calculation for idea goal

Testing Done:
tested in dev mode locally. ci passes.

Reviewed at https://rbcommons.com/s/twitter/r/1189/
Sync of https://github.com/pantsbuild/pants/commit/8818ff8ce5b87c5f3b3cd83a63ba4ed79a43dd7f