Skip to content

Commit a93cf01

Browse files
committed
Don't assume the default wiki branch is master in the wiki API
In the recent past, the default wiki branch was made to be changeable.
1 parent 21b43fc commit a93cf01

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

routers/api/v1/repo/wiki.go

Lines changed: 4 additions & 4 deletions
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.APIErrorNotFound(err)

0 commit comments

Comments
 (0)