RMHogervorst / badgecreatr

Quickly place relevant badges at the top of your readme, stop copy pasting, start on your project
http://rmhogervorst.nl/badgecreatr
61 stars 22 forks source link

badge_last_change(): "404: This is not the web page you are looking for." #57

Open rempsyc opened 2 years ago

rempsyc commented 2 years ago

The following command: badge_last_change(location = ".") creates the following rmarkdown code:

[![Last-changedate](https://img.shields.io/badge/last%20change-`r gsub('-', '--', Sys.Date())`-yellowgreen.svg)](/commits/master)

But on my package page, the link created on the badge (https://github.com/RemPsyc/rempsyc/commits/master) seems invalid and leads to the following GitHub error page:

404: This is not the web page you are looking for.

Indeed I do have a /commits but no /master directory. I've tried changing the location argument but it always output the same result:

badge_last_change(location = "")
badge_last_change(location = "/commits")
badge_last_change(location = "rempsyc/commits")

Any idea what I'm doing wrong?

rempsyc commented 2 years ago

/master seems to be a vestige of the time before the transition to main, and accordingly, the adapted URL does work as expected:

https://github.com/RemPsyc/rempsyc/commits/main

And can be changed in the rmarkdown readme manually [edit: that's incorrect after all]. I just wonder if the badge_last_change() function should be updated to reflect this, or at least whether the documentation should be updated to warn users about the change.

rempsyc commented 2 years ago

Actually, after further testing I thought that changing the link from /master to /main directly in the readme would work but alas it does not because it also adds an unwanted /blob/main which my repository doesn't have:

https://github.com/RemPsyc/rempsyc/blob/main/commits/main

Whereas the correct link should be:

https://github.com/RemPsyc/rempsyc/commits/main

So I have no working fix or workaround so far.

RMHogervorst commented 2 years ago

Hi Remy @RemPsyc , I would think switching to main would be much easier. I haven't touched this package in a while and I'm super busy, so I'm open to a pull request if you have one. I wish I changed this to main earlier, because I have changed almost all my repos to main

rempsyc commented 2 years ago

Thanks for your answer. I have never submitted a PR before, but I'm open to trying it. I've looked into it briefly but I'm already facing a few roadblocks.

  1. Normally I put my functions in the R folder but in your R folder I cannot find function badge_last_change() in: https://github.com/RMHogervorst/badgecreatr/tree/master/R

Edit: Oh they're actually all in the same badges.R file! https://github.com/RMHogervorst/badgecreatr/blob/master/R/badges.R

  1. I've tried changing the referlink = "/commits/master" argument to referlink = "/commits/main" inside the badge_last_change() function but it still adds the blob/main bit and I don't know where it's coming from since the rmarkdown code it outputs is this:

[![Last-changedate](https://img.shields.io/badge/last%20change-`r gsub('-', '--', Sys.Date())`-yellowgreen.svg)](/commits/main)"

Where can I change the blob/main then?

rempsyc commented 2 years ago

Ok one workaround for individual users (not related to the PR) is to simply put the full link at the end, like below, then it will work:

[![Last-changedate](https://img.shields.io/badge/last%20change-`r gsub('-', '--', Sys.Date())`-yellowgreen.svg)](https://github.com/RemPsyc/rempsyc/commits/main)