aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/repo/repo.go')
-rw-r--r--routers/api/v1/repo/repo.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index c907bba66b..f7aa366b17 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -71,6 +71,11 @@ func Search(ctx *context.APIContext) {
// description: search only for repos that the user with the given id owns or contributes to
// type: integer
// format: int64
+ // - name: priority_owner_id
+ // in: query
+ // description: repo owner to prioritize in the results
+ // type: integer
+ // format: int64
// - name: starredBy
// in: query
// description: search only for repos that the user with the given id has starred
@@ -80,6 +85,10 @@ func Search(ctx *context.APIContext) {
// in: query
// description: include private repositories this user has access to (defaults to true)
// type: boolean
+ // - name: template
+ // in: query
+ // description: include template repositories this user has access to (defaults to true)
+ // type: boolean
// - name: page
// in: query
// description: page number of results to return (1-based)
@@ -116,17 +125,23 @@ func Search(ctx *context.APIContext) {
opts := &models.SearchRepoOptions{
Keyword: strings.Trim(ctx.Query("q"), " "),
OwnerID: ctx.QueryInt64("uid"),
+ PriorityOwnerID: ctx.QueryInt64("priority_owner_id"),
Page: ctx.QueryInt("page"),
PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")),
TopicOnly: ctx.QueryBool("topic"),
Collaborate: util.OptionalBoolNone,
Private: ctx.IsSigned && (ctx.Query("private") == "" || ctx.QueryBool("private")),
+ Template: util.OptionalBoolNone,
UserIsAdmin: ctx.IsUserSiteAdmin(),
UserID: ctx.Data["SignedUserID"].(int64),
StarredByID: ctx.QueryInt64("starredBy"),
IncludeDescription: ctx.QueryBool("includeDesc"),
}
+ if ctx.Query("template") != "" {
+ opts.Template = util.OptionalBoolOf(ctx.QueryBool("template"))
+ }
+
if ctx.QueryBool("exclusive") {
opts.Collaborate = util.OptionalBoolFalse
}
@@ -678,6 +693,10 @@ func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) err
repo.IsPrivate = *opts.Private
}
+ if opts.Template != nil {
+ repo.IsTemplate = *opts.Template
+ }
+
if err := models.UpdateRepository(repo, visibilityChanged); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateRepository", err)
return err