Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub relative internal repository links in PULL_REQUEST_TEMPLATE.md

Using a relative link as directed (https://help.github.com/articles/about-readmes/#relative-links-and-image-paths-in-readme-files) in a PULL_REQUEST_TEMPLATE.md does not relatively link correctly.

When viewed in an actual PR:

  • [CONTRIBUTING.md](/.github/CONTRIBUTING.md)

routes to: https://github.com/.github/CONTRIBUTING.md.

  • [CONTRIBUTING.md](.github/CONTRIBUTING.md)
  • [CONTRIBUTING.md](./.github/CONTRIBUTING.md)

route to: https://github.com/owner/repo/compare/.github/CONTRIBUTING.md

instead of https://github.com/owner/repo/.github/CONTRIBUTING.md.

Changing to ../ to go up a level would work for PRs, but would break the link when viewed in the GitHub UI.

Clicking the link as viewed on GitHub works: https://github.com/fs-webdev/fs-dialog/blob/master/.github/PULL_REQUEST_TEMPLATE.md, just not inside a PR.

(I feel like this used to work in 2017)

What is the correct way to have the relative link function as expected in both cases?

like image 719
Clif Avatar asked Mar 12 '18 18:03

Clif


People also ask

What is a PR template?

Pull request templates allow your organizations to have a default text when you create a pull request on GitHub. It is quite useful to make sure to follow a standard process for every pull request and to have a to-do list for the author to check before requesting a review.

How do pull requests work GitHub?

Pull requests let you tell others about changes you've pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.

What happens after a pull request is approved?

Once the repository maintainer has approved a pull request, the developer's new updates in the forked repository are merged with the main project repository. The product is then updated with the new feature or bug fix, and can now be viewed by end users.


1 Answers

Background

Unfortunately, the given implementation seems to consider only the current URL instead of the actual file path in the repository.

The same limitation can be noted when creating issues (through e.g.: https://github.com/owner/repo/issues/new):

[CONTRIBUTING.md](.github/CONTRIBUTING.md)

->

https://github.com/owner/repo/issues/.github/CONTRIBUTING.md

Workaround

I only managed to make the relative link work by specifying the full URL path (including the leading /):

[CONTRIBUTING.md](/owner/repo/.github/CONTRIBUTING.md)

->

https://github.com/owner/repo/.github/CONTRIBUTING.md

With that said, the abstraction can only go up to the URL host (i.e.: https://github.com).

like image 129
kelvin Avatar answered Nov 02 '22 17:11

kelvin