瀏覽代碼

Fix API raw file content access for default branch (#2849)

tags/v1.3.0-rc1
Lauris BH 6 年之前
父節點
當前提交
57de1ff991
沒有連結到貢獻者的電子郵件帳戶。
共有 2 個檔案被更改,包括 8 行新增1 行删除
  1. 3
    0
      integrations/api_repo_raw_test.go
  2. 5
    1
      modules/context/repo.go

+ 3
- 0
integrations/api_repo_raw_test.go 查看文件

@@ -25,4 +25,7 @@ func TestAPIReposRaw(t *testing.T) {
req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/%s/README.md", user.Name, ref)
session.MakeRequest(t, req, http.StatusOK)
}
// Test default branch
req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/README.md", user.Name)
session.MakeRequest(t, req, http.StatusOK)
}

+ 5
- 1
modules/context/repo.go 查看文件

@@ -507,7 +507,11 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
if refName := getRefName(ctx, RepoRefTag); len(refName) > 0 {
return refName
}
return getRefName(ctx, RepoRefCommit)
if refName := getRefName(ctx, RepoRefCommit); len(refName) > 0 {
return refName
}
ctx.Repo.TreePath = path
return ctx.Repo.Repository.DefaultBranch
case RepoRefBranch:
return getRefNameFromPath(ctx, path, ctx.Repo.GitRepo.IsBranchExist)
case RepoRefTag:

Loading…
取消
儲存