Skip to content

Commit

Permalink
Fix API raw file content access for default branch (#2849)
Browse files Browse the repository at this point in the history
  • Loading branch information
lafriks authored Nov 4, 2017
1 parent 76b8c3c commit 57de1ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions integrations/api_repo_raw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 5 additions & 1 deletion modules/context/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 57de1ff

Please sign in to comment.