Skip to content

Commit ea3fb69

Browse files
committed
Inital routes to git refs api
1 parent 3379141 commit ea3fb69

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
lines changed

routers/api/v1/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,9 @@ func RegisterRoutes(m *macaron.Macaron) {
573573
m.Get("/status", repo.GetCombinedCommitStatusByRef)
574574
m.Get("/statuses", repo.GetCommitStatusesByRef)
575575
})
576+
m.Group("/git", func() {
577+
m.Get("/refs/*", repo.GetGitRefs)
578+
})
576579
}, repoAssignment())
577580
})
578581

routers/api/v1/repo/git_ref.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2018 Gitea. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package repo
6+
7+
import (
8+
"code.gitea.io/gitea/modules/context"
9+
)
10+
11+
// GetGitRefs get ref or an list all the refs of a repository
12+
func GetGitRefs(ctx *context.APIContext) {
13+
// swagger:operation GET /repos/{owner}/{repo}/git/refs/{ref} repository repoListGitRefs
14+
// ---
15+
// summary: Get specified ref or filtered repository's refs
16+
// produces:
17+
// - application/json
18+
// parameters:
19+
// - name: owner
20+
// in: path
21+
// description: owner of the repo
22+
// type: string
23+
// required: true
24+
// - name: repo
25+
// in: path
26+
// description: name of the repo
27+
// type: string
28+
// required: true
29+
// - name: ref
30+
// in: path
31+
// description: part or full name of the ref
32+
// type: string
33+
// required: false
34+
// responses:
35+
// "200":
36+
// "$ref": "#/responses/Ref"
37+
// "$ref": "#/responses/RefList"
38+
}

templates/swagger/v1_json.tmpl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,45 @@
15601560
}
15611561
}
15621562
},
1563+
"/repos/{owner}/{repo}/git/refs/{ref}": {
1564+
"get": {
1565+
"produces": [
1566+
"application/json"
1567+
],
1568+
"tags": [
1569+
"repository"
1570+
],
1571+
"summary": "Get specified ref or filtered repository's refs",
1572+
"operationId": "repoListGitRefs",
1573+
"parameters": [
1574+
{
1575+
"type": "string",
1576+
"description": "owner of the repo",
1577+
"name": "owner",
1578+
"in": "path",
1579+
"required": true
1580+
},
1581+
{
1582+
"type": "string",
1583+
"description": "name of the repo",
1584+
"name": "repo",
1585+
"in": "path",
1586+
"required": true
1587+
},
1588+
{
1589+
"type": "string",
1590+
"description": "part or full name of the ref",
1591+
"name": "ref",
1592+
"in": "path"
1593+
}
1594+
],
1595+
"responses": {
1596+
"200": {
1597+
"$ref": "#/responses/RefList"
1598+
}
1599+
}
1600+
}
1601+
},
15631602
"/repos/{owner}/{repo}/hooks": {
15641603
"get": {
15651604
"produces": [

vendor/code.gitea.io/sdk/gitea/repo_git_ref.go

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)