Always assume origin is a GitHub instance (adds support for self-hosted GitHub Enterprise URLs) #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #18!
This PR assumes that the origin repo is always a GitHub instance, which adds compatibility for company-hosted GitHub Enterprise instances with a different site name. This replaces the hard-coded
github.comin the regex andhttps://github.comin the URL output with an additionalsedcommand to capture the site name and reuse it in the URL.For example, with an upstream origin URL of...
[email protected]:example-org/example-repo.git...this PR would produce this URL for a few lines on
README.md:https://github.mycompany.com/example-org/example-repo/blob/caf758b2dbe03480dd340dd339379ca86797e6b6/README.md#L11-L27Prior to this PR, a URL like this is produced:
https://github.com///blob/caf758b2dbe03480dd340dd339379ca86797e6b6/README.md#L11-L27