Introspect Commit Range

Is there any way of a script running on CircleCI to introspect the commit range that triggered the build (as listed at the top of the build page). Parsing CIRCLE_COMPARE_URL seems to provide an answer, but not always (e.g. on forced pushes).