Skip to content

Commit a8f061f

Browse files
authored
Merge branch 'main' into fix-migration-dns-error
2 parents 4dea49e + 3725fa2 commit a8f061f

File tree

20 files changed

+222
-17
lines changed

20 files changed

+222
-17
lines changed

integrations/api_team_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"testing"
1212

1313
"code.gitea.io/gitea/models/organization"
14+
"code.gitea.io/gitea/models/repo"
1415
"code.gitea.io/gitea/models/unit"
1516
"code.gitea.io/gitea/models/unittest"
1617
user_model "code.gitea.io/gitea/models/user"
@@ -239,3 +240,26 @@ func TestAPITeamSearch(t *testing.T) {
239240
req = NewRequestf(t, "GET", "/api/v1/orgs/%s/teams/search?q=%s&token=%s", org.Name, "team", token5)
240241
MakeRequest(t, req, http.StatusForbidden)
241242
}
243+
244+
func TestAPIGetTeamRepo(t *testing.T) {
245+
defer prepareTestEnv(t)()
246+
247+
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 15}).(*user_model.User)
248+
teamRepo := unittest.AssertExistsAndLoadBean(t, &repo.Repository{ID: 24}).(*repo.Repository)
249+
team := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: 5}).(*organization.Team)
250+
251+
var results api.Repository
252+
253+
token := getUserToken(t, user.Name)
254+
req := NewRequestf(t, "GET", "/api/v1/teams/%d/repos/%s/?token=%s", team.ID, teamRepo.FullName(), token)
255+
resp := MakeRequest(t, req, http.StatusOK)
256+
DecodeJSON(t, resp, &results)
257+
assert.Equal(t, "big_test_private_4", teamRepo.Name)
258+
259+
// no access if not organization member
260+
user5 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 5}).(*user_model.User)
261+
token5 := getUserToken(t, user5.Name)
262+
263+
req = NewRequestf(t, "GET", "/api/v1/teams/%d/repos/%s/?token=%s", team.ID, teamRepo.FullName(), token5)
264+
MakeRequest(t, req, http.StatusNotFound)
265+
}

routers/api/v1/api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,8 @@ func Routes() *web.Route {
11211121
m.Get("", org.GetTeamRepos)
11221122
m.Combo("/{org}/{reponame}").
11231123
Put(org.AddTeamRepository).
1124-
Delete(org.RemoveTeamRepository)
1124+
Delete(org.RemoveTeamRepository).
1125+
Get(org.GetTeamRepo)
11251126
})
11261127
}, orgAssignment(false, true), reqToken(), reqTeamMembership())
11271128

routers/api/v1/org/team.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,55 @@ func GetTeamRepos(ctx *context.APIContext) {
558558
ctx.JSON(http.StatusOK, repos)
559559
}
560560

561+
// GetTeamRepo api for get a particular repo of team
562+
func GetTeamRepo(ctx *context.APIContext) {
563+
// swagger:operation GET /teams/{id}/repos/{org}/{repo} organization orgListTeamRepo
564+
// ---
565+
// summary: List a particular repo of team
566+
// produces:
567+
// - application/json
568+
// parameters:
569+
// - name: id
570+
// in: path
571+
// description: id of the team
572+
// type: integer
573+
// format: int64
574+
// required: true
575+
// - name: org
576+
// in: path
577+
// description: organization that owns the repo to list
578+
// type: string
579+
// required: true
580+
// - name: repo
581+
// in: path
582+
// description: name of the repo to list
583+
// type: string
584+
// required: true
585+
// responses:
586+
// "200":
587+
// "$ref": "#/responses/Repository"
588+
// "404":
589+
// "$ref": "#/responses/notFound"
590+
591+
repo := getRepositoryByParams(ctx)
592+
if ctx.Written() {
593+
return
594+
}
595+
596+
if !organization.HasTeamRepo(ctx, ctx.Org.Team.OrgID, ctx.Org.Team.ID, repo.ID) {
597+
ctx.NotFound()
598+
return
599+
}
600+
601+
access, err := models.AccessLevel(ctx.Doer, repo)
602+
if err != nil {
603+
ctx.Error(http.StatusInternalServerError, "GetTeamRepos", err)
604+
return
605+
}
606+
607+
ctx.JSON(http.StatusOK, convert.ToRepo(repo, access))
608+
}
609+
561610
// getRepositoryByParams get repository by a team's organization ID and repo name
562611
func getRepositoryByParams(ctx *context.APIContext) *repo_model.Repository {
563612
repo, err := repo_model.GetRepositoryByName(ctx.Org.Team.OrgID, ctx.Params(":reponame"))

templates/admin/auth/list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</div>
1111
</h4>
1212
<div class="ui attached table segment">
13-
<table class="ui very basic striped table">
13+
<table class="ui very basic striped table unstackable">
1414
<thead>
1515
<tr>
1616
<th>ID</th>

templates/admin/cron.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</h4>
44
<div class="ui attached table segment">
55
<form method="post" action="{{AppSubUrl}}/admin">
6-
<table class="ui very basic striped table">
6+
<table class="ui very basic striped table unstackable">
77
<thead>
88
<tr>
99
<th></th>

templates/admin/emails/list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</form>
3131
</div>
3232
<div class="ui attached table segment">
33-
<table class="ui very basic striped table">
33+
<table class="ui very basic striped table unstackable">
3434
<thead>
3535
<tr>
3636
<th data-sortt-asc="username" data-sortt-desc="reverseusername">

templates/admin/monitor.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{.i18n.Tr "admin.monitor.queues"}}
99
</h4>
1010
<div class="ui attached table segment">
11-
<table class="ui very basic striped table">
11+
<table class="ui very basic striped table unstackable">
1212
<thead>
1313
<tr>
1414
<th>{{.i18n.Tr "admin.monitor.queue.name"}}</th>

templates/admin/notice.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{{.i18n.Tr "admin.notices.system_notice_list"}} ({{.i18n.Tr "admin.total" .Total}})
88
</h4>
99
<div class="ui attached table segment">
10-
<table id="notice-table" class="ui very basic select selectable table">
10+
<table id="notice-table" class="ui very basic select selectable table unstackable">
1111
<thead>
1212
<tr>
1313
<th></th>

templates/admin/org/list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{{template "admin/base/search" .}}
1414
</div>
1515
<div class="ui attached table segment">
16-
<table class="ui very basic striped table">
16+
<table class="ui very basic striped table unstackable">
1717
<thead>
1818
<tr>
1919
<th data-sortt-asc="oldest" data-sortt-desc="newest">ID{{SortArrow "oldest" "newest" $.SortType false}}</th>

templates/admin/packages/list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</form>
3030
</div>
3131
<div class="ui attached table segment">
32-
<table class="ui very basic striped table">
32+
<table class="ui very basic striped table unstackable">
3333
<thead>
3434
<tr>
3535
<th>ID</th>

0 commit comments

Comments
 (0)