Skip to content

Commit 83353a8

Browse files
author
Aly Sewelam
committed
Add .org to Git path preparation
markdown files still take priority over org files if both are present
1 parent 676a785 commit 83353a8

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

services/wiki/wiki.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ func InitWiki(ctx context.Context, repo *repo_model.Repository) error {
5555
// prepareGitPath try to find a suitable file path with file name by the given raw wiki name.
5656
// return: existence, prepared file path with name, error
5757
func prepareGitPath(gitRepo *git.Repository, defaultWikiBranch string, wikiPath WebPath) (bool, string, error) {
58-
unescaped := string(wikiPath) + ".md"
58+
unescapedMd := string(wikiPath) + ".md"
59+
unescapedOrg := string(wikiPath) + ".org"
5960
gitPath := WebPathToGitPath(wikiPath)
6061

61-
// Look for both files
62-
filesInIndex, err := gitRepo.LsTree(defaultWikiBranch, unescaped, gitPath)
62+
// Look for .md, .org, and escaped file
63+
filesInIndex, err := gitRepo.LsTree(defaultWikiBranch, unescapedMd, unescapedOrg, gitPath)
6364
if err != nil {
6465
if strings.Contains(err.Error(), "Not a valid object name") {
6566
return false, gitPath, nil // branch doesn't exist
@@ -71,9 +72,11 @@ func prepareGitPath(gitRepo *git.Repository, defaultWikiBranch string, wikiPath
7172
foundEscaped := false
7273
for _, filename := range filesInIndex {
7374
switch filename {
74-
case unescaped:
75-
// if we find the unescaped file return it
76-
return true, unescaped, nil
75+
// if we find unescaped file (.md or .org) return it
76+
case unescapedMd:
77+
return true, unescapedMd, nil
78+
case unescapedOrg:
79+
return true, unescapedOrg, nil
7780
case gitPath:
7881
foundEscaped = true
7982
}

0 commit comments

Comments
 (0)