Clean up source-code version detection

Rewrite and avoid the regex that incorrectly used the /s switch; also simplify: we only need to support git nowadays.

(Also: I'm sure you're like me and o_O when you see a naked 'rescue', but in this case I think it's warranted: we don't want to propagate failure if the git command doesn't work.)