-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix Github Wiki Page Links #4538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix Github Wiki Page Links #4538
Conversation
pkg/giturl/giturl.go
Outdated
| if line > 0 { | ||
| baseLink += "#L" + strconv.FormatInt(line, 10) | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I'm being persnickety but this newline is bugging me :/
pkg/giturl/giturl.go
Outdated
| // GitHub Wiki links are formatted differently | ||
| baseLink = repo[:len(repo)-9] + "/wiki/" | ||
| if file != "" { | ||
| baseLink += strings.TrimSuffix(file, ".md") + "/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that if file is empty, the actual file we care about is a markdown file, right? That seems very specific. How do we know that?
In any case, this seems like something that should be explained in a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this comment because my assumption was that wiki documents can only be created in markdown format, but it turns out github supports all of these:

Even though markdown is set by default and most wikis would be using markdown, best solution would be to just remove the file extension, whatever it is. I'll do that
| if commit != "" { | ||
| baseLink += commit | ||
| } | ||
| if line > 0 { | ||
| baseLink += "#L" + strconv.FormatInt(line, 10) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are real possibilities, I think they should have test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
…-not-work-for-GH-Wiki-pages
rosecodym
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am taking it on faith that the base link mangling is correct, but you're the expert here!
Description:
This PR fixes a bug with link generation for GH wiki pages.
Checklist:
make test-community)?make lintthis requires golangci-lint)?