Skip to content

Commit 030ed94

Browse files
GiteaBotkemzeb
andauthored
Don't assume the default wiki branch is master in the wiki API (go-gitea#34244) (go-gitea#34245)
Backport go-gitea#34244 by kemzeb Resolves go-gitea#34218. In the recent past, the default wiki branch was made to be changeable. This change reflects this. Co-authored-by: Kemal Zebari <[email protected]>
1 parent 60f175f commit 030ed94

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

routers/api/v1/repo/wiki.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func getWikiPage(ctx *context.APIContext, wikiName wiki_service.WebPath) *api.Wi
193193
}
194194

195195
// get commit count - wiki revisions
196-
commitsCount, _ := wikiRepo.FileCommitsCount("master", pageFilename)
196+
commitsCount, _ := wikiRepo.FileCommitsCount(ctx.Repo.Repository.DefaultWikiBranch, pageFilename)
197197

198198
// Get last change information.
199199
lastCommit, err := wikiRepo.GetCommitByPath(pageFilename)
@@ -432,7 +432,7 @@ func ListPageRevisions(ctx *context.APIContext) {
432432
}
433433

434434
// get commit count - wiki revisions
435-
commitsCount, _ := wikiRepo.FileCommitsCount("master", pageFilename)
435+
commitsCount, _ := wikiRepo.FileCommitsCount(ctx.Repo.Repository.DefaultWikiBranch, pageFilename)
436436

437437
page := ctx.FormInt("page")
438438
if page <= 1 {
@@ -442,7 +442,7 @@ func ListPageRevisions(ctx *context.APIContext) {
442442
// get Commit Count
443443
commitsHistory, err := wikiRepo.CommitsByFileAndRange(
444444
git.CommitsByFileAndRangeOptions{
445-
Revision: "master",
445+
Revision: ctx.Repo.Repository.DefaultWikiBranch,
446446
File: pageFilename,
447447
Page: page,
448448
})
@@ -486,7 +486,7 @@ func findWikiRepoCommit(ctx *context.APIContext) (*git.Repository, *git.Commit)
486486
return nil, nil
487487
}
488488

489-
commit, err := wikiRepo.GetBranchCommit("master")
489+
commit, err := wikiRepo.GetBranchCommit(ctx.Repo.Repository.DefaultWikiBranch)
490490
if err != nil {
491491
if git.IsErrNotExist(err) {
492492
ctx.NotFound(err)

0 commit comments

Comments
 (0)