fix: not able to update local created non-urlencoded wiki pages #16139
No reviewers
Labels
No Label
backport/done
backport/v1.0
backport/v1.1
backport/v1.10
backport/v1.11
backport/v1.12
backport/v1.13
backport/v1.14
backport/v1.15
backport/v1.2
backport/v1.3
backport/v1.4
backport/v1.5
backport/v1.6
backport/v1.7
backport/v1.8
backport/v1.9
bounty
changelog
dependencies
frontport/done
frontport/main
good first issue
Hacktoberfest
hacktoberfest-accepted
in progress
kind/api
kind/breaking
kind/bug
kind/build
kind/deployment
kind/deprecated
kind/docs
kind/enhancement
kind/feature
kind/lint
kind/misc
kind/moderation
kind/package
kind/proposal
kind/question
kind/refactor
kind/regression
kind/security
kind/summary
kind/testing
kind/translation
kind/ui
kind/upstream-related
kind/usability
kind/ux
lgtm/done
lgtm/need 1
lgtm/need 2
performance/bigrepo
performance/cpu
performance/memory
performance/speed
priority/critical
priority/low
priority/maybe
priority/medium
proposal/rejected
reviewed/confirmed
reviewed/duplicate
reviewed/fixed
reviewed/invalid
reviewed/not-a-bug
reviewed/wontfix
skip-changelog
stale
status/blocked
status/needs-feedback
status/wip
theme/2fa
theme/authentication
theme/avatar
theme/backup-restore
theme/docker
theme/federation
theme/issues
theme/kanban
theme/markdown
theme/migration
theme/mobile
theme/pr
theme/signing
theme/sqlite
theme/timetracker
theme/webhook
theme/wiki
No Milestone
No project
No Assignees
4 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: lunny/gitea#16139
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix-local-wiki-update"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Related to issue #16122, this patch intended to resolve part of the bug mentioned in https://github.com/go-gitea/gitea/issues/16122#issuecomment-859570030
If we clone the wiki repo locally and create some markdown file without urlencoded its filename, the file can be displayed correctly if we then push back it to the remote repo, but if we attempt to update these pages, it will create a new urlencoded file with updated content and the old non-urlencoded file is still here with content unchanged. This PR intended to resolve that by doing:
By the way, since resolving #16122 completely still need some other patches, there is something we still need to discuss:
If necessary, we can discuss these in #16122.
@ -83,1 +83,4 @@
// prepareWikiFileName try to find a suitable file path with file name by the given raw wiki name.
// return: existence, prepared file path with name, error
func prepareWikiFileName(gitRepo *git.Repository, wikiName string) (bool, string, error) {
repeatedly running this is very expensive. gitRepo.LsFiles(...) is not free.
Why don't we do somethings else:
@ -83,1 +83,4 @@
// prepareWikiFileName try to find a suitable file path with file name by the given raw wiki name.
// return: existence, prepared file path with name, error
func prepareWikiFileName(gitRepo *git.Repository, wikiName string) (bool, string, error) {
Hi and I updated my patch, added a
prepareWikiFileName()
function that did what you described, but I'm not sure if I understood you correctly.Yeah
gitRepo.LsFiles(...)
is not free, but adding that function seems could only make the code looks cleaner, it still requires twoLsFiles()
calls to look for the file inside that function, or is there another method that better suitable for this use case?@ -83,1 +83,4 @@
// prepareWikiFileName try to find a suitable file path with file name by the given raw wiki name.
// return: existence, prepared file path with name, error
func prepareWikiFileName(gitRepo *git.Repository, wikiName string) (bool, string, error) {
No, this wasn't what I was meaning.
You look for two filenames: The one passed in and the normalized path.
Although you should be a bit more efficient.
@ -83,1 +83,4 @@
// prepareWikiFileName try to find a suitable file path with file name by the given raw wiki name.
// return: existence, prepared file path with name, error
func prepareWikiFileName(gitRepo *git.Repository, wikiName string) (bool, string, error) {
Oh, I thought
LsFiles()
only check if the passed file exists. Sorry I don't code in Go too much and I should read the docs first XDThanks for your guidance!
Do we still need to do this (replace space to dash) for unescaped filename?
I'd drop it.
Ignore me I'm getting confused
We need to make:
make sense with the changes in prepareWikiFileName
This is fine
// Pass in the raw unchanged name
// Add ".md" suffix if not there.
where is the check if it end with .md ?
@ -84,0 +88,4 @@
escaped := NameToFilename(wikiName)
// Look for both files
filesInIndex, err := gitRepo.LsFiles(unescaped, escaped)
a smal unit test would be nice :D
That's the recommended step from this inline review. I notice that the original
NameToFilename()
didn't do that either, so do I need to add that logic to bothNameToUnescapedFilename()
andNameToFilename()
or just remove that comment?@ -84,0 +88,4 @@
escaped := NameToFilename(wikiName)
// Look for both files
filesInIndex, err := gitRepo.LsFiles(unescaped, escaped)
I'd like to but since I'm also not very familiar with the whole Gitea codebase and how these tests works, I think it's better to not add a test case for this PR.
@ -84,0 +88,4 @@
escaped := NameToFilename(wikiName)
// Look for both files
filesInIndex, err := gitRepo.LsFiles(unescaped, escaped)
Hmm ok. If i get time I'll write one, or at least a frame :)
The function then seems bit useles and we should remove it then
@ -82,2 +82,4 @@
}
// prepareWikiFileName try to find a suitable file path with file name by the given raw wiki name.
// return: existence, prepared file path with name, error
I'd prefer to remove this comment and don't do the check since Markdown is the only supported markup language in Wiki. User doesn't need to know or manually specify the file extension here.
I prefer to remove the comment and added a commit to remove these two lines of comment, let me know if you think I should add the check instead of remove it, thanks!
Oh! Sorry I missed this comment. A new commit has been added to remove that function now.
Thanks :)
@ -84,0 +88,4 @@
escaped := NameToFilename(wikiName)
// Look for both files
filesInIndex, err := gitRepo.LsFiles(unescaped, escaped)
-> https://github.com/go-gitea/gitea/pull/16487