Browser extension: fix GitHub file info detection
Created by: chrismwendt
Prior to this change, the revision was found by inspecting the branch/tree button and whether or not the text was truncated. That seemed error-prone to me.
After this change, the file path is found first (by inspecting the "Copy path" button), then the revision is derived from that and the URL. This seems a bit more robust and simpler.
Test plan: make sure the "Open on Sourcegraph" button appears in the file header for these:
- https://github.com/sourcegraph/sourcegraph/blob/alert-bg/cmd/frontend/internal/session/session.go
- https://github.com/sourcegraph/sourcegraph/blob/01d571ba62853db43d5dd0b73436ec47eca7662b/cmd/frontend/internal/session/session.go
Fixes https://github.com/sourcegraph/sourcegraph/issues/4280
Test Plan
Code Hosts
-
GitHub -
GitHub Enterprise -
Refined GitHub PhabricatorPhabricator integrationBitbucketGitlab
Browsers
-
Chrome -
Firefox