API: Add GitHub-compatible GET /repos/{owner}/{repo}/commits/{ref} endpoint
type/proposal
### What problem would this solve?
Tools that target both GitHub and Gitea APIs need to handle two different paths for the same operation.
- GitHub: `GET /repos/{owner}/{repo}/commits/{ref}` → returns a single commit
- Gitea: `GET /repos/{owner}/{repo}/commits/{ref}` → 404 (only `git/commits/{sha}` works)
This forces clients to implement fallback logic or detect which server they're talking to.
### What do you propose?
Add a route alias at `GET /repos/{owner}/{repo}/commits/{ref}` that delegates to the existing `GetSingleCommit` handler.
Currently in `routers/api/v1/api.go`:
```go
m.Group("/commits", func() {
m.Get("", context.ReferencesGitRepo(), repo.GetAllCommits)
// add: m.Get("/{ref}", repo.GetSingleCommit)
})
```
This would be a one-line change that improves GitHub API compatibility.
0 条评论