From 3d908d8215d1dab7917972068d01723f19558c5e Mon Sep 17 00:00:00 2001 From: Patrick Stevens Date: Wed, 29 Mar 2023 22:54:45 +0100 Subject: [PATCH] More settings (#28) --- Gitea.Declarative.Lib/ConfigSchema.fs | 77 +- Gitea.Declarative.Lib/GiteaConfig.schema.json | 81 +- .../SerialisedConfigSchema.fs | 56 +- Gitea.Declarative.Lib/swagger.v1.json | 1618 +++++++++++++++-- Gitea.Declarative.Test/GiteaConfig.json | 8 +- Gitea.Declarative/Program.fs | 26 +- 6 files changed, 1725 insertions(+), 141 deletions(-) diff --git a/Gitea.Declarative.Lib/ConfigSchema.fs b/Gitea.Declarative.Lib/ConfigSchema.fs index 897f2e1..6859d79 100644 --- a/Gitea.Declarative.Lib/ConfigSchema.fs +++ b/Gitea.Declarative.Lib/ConfigSchema.fs @@ -4,22 +4,77 @@ open System open System.IO open Newtonsoft.Json +type MergeStyle = + | Merge + | Rebase + | RebaseMerge + | Squash + + static member Parse (s : string) : MergeStyle = + if s = "merge" then MergeStyle.Merge + elif s = "squash" then MergeStyle.Squash + elif s = "rebase" then MergeStyle.Rebase + elif s = "rebase-merge" then MergeStyle.RebaseMerge + else failwithf "Unrecognised merge style '%s'" s + type NativeRepo = { DefaultBranch : string Private : bool option + IgnoreWhitespaceConflicts : bool option + HasPullRequests : bool option + HasProjects : bool option + HasIssues : bool option + HasWiki : bool option + DefaultMergeStyle : MergeStyle option + DeleteBranchAfterMerge : bool option + AllowSquashMerge : bool option + AllowRebaseUpdate : bool option + AllowRebase : bool option + AllowRebaseExplicit : bool option + AllowMergeCommits : bool option } static member internal OfSerialised (s : SerialisedNativeRepo) = { NativeRepo.DefaultBranch = s.DefaultBranch Private = s.Private |> Option.ofNullable + IgnoreWhitespaceConflicts = s.IgnoreWhitespaceConflicts |> Option.ofNullable + HasPullRequests = s.HasPullRequests |> Option.ofNullable + HasProjects = s.HasProjects |> Option.ofNullable + HasIssues = s.HasIssues |> Option.ofNullable + HasWiki = s.HasWiki |> Option.ofNullable + DefaultMergeStyle = s.DefaultMergeStyle |> Option.ofObj |> Option.map MergeStyle.Parse + DeleteBranchAfterMerge = s.DeleteBranchAfterMerge |> Option.ofNullable + AllowSquashMerge = s.AllowSquashMerge |> Option.ofNullable + AllowRebaseUpdate = s.AllowRebaseUpdate |> Option.ofNullable + AllowRebase = s.AllowRebase |> Option.ofNullable + AllowRebaseExplicit = s.AllowRebaseExplicit |> Option.ofNullable + AllowMergeCommits = s.AllowMergeCommits |> Option.ofNullable + } + +type GitHubRepo = + { + Uri : Uri + /// This is a Golang string. + MirrorInterval : string + } + + static member internal OfSerialised (s : SerialisedGitHubRepo) : GitHubRepo = + { + Uri = Uri s.Uri + MirrorInterval = + // Rather odd behaviour of the API here! + if s.MirrorInterval = null then + "8h0m0s" + else + s.MirrorInterval } type Repo = { Description : string - GitHub : Uri option + GitHub : GitHubRepo option Native : NativeRepo option } @@ -30,12 +85,28 @@ type Repo = if String.IsNullOrEmpty u.OriginalUrl then None else - Some (Uri u.OriginalUrl) + { + Uri = Uri u.OriginalUrl + MirrorInterval = u.MirrorInterval + } + |> Some Native = if String.IsNullOrEmpty u.OriginalUrl then { Private = u.Private DefaultBranch = u.DefaultBranch + IgnoreWhitespaceConflicts = u.IgnoreWhitespaceConflicts + HasPullRequests = u.HasProjects + HasProjects = u.HasProjects + HasIssues = u.HasIssues + HasWiki = u.HasWiki + DefaultMergeStyle = u.DefaultMergeStyle |> Option.ofObj |> Option.map MergeStyle.Parse + DeleteBranchAfterMerge = u.DefaultDeleteBranchAfterMerge + AllowSquashMerge = u.AllowSquashMerge + AllowRebaseUpdate = u.AllowRebaseUpdate + AllowRebase = u.AllowRebase + AllowRebaseExplicit = u.AllowRebaseExplicit + AllowMergeCommits = u.AllowMergeCommits } |> Some else @@ -45,7 +116,7 @@ type Repo = static member internal OfSerialised (s : SerialisedRepo) = { Repo.Description = s.Description - GitHub = Option.ofObj s.GitHub + GitHub = Option.ofNullable s.GitHub |> Option.map GitHubRepo.OfSerialised Native = s.Native |> Option.ofNullable |> Option.map NativeRepo.OfSerialised } diff --git a/Gitea.Declarative.Lib/GiteaConfig.schema.json b/Gitea.Declarative.Lib/GiteaConfig.schema.json index 1277996..086601b 100644 --- a/Gitea.Declarative.Lib/GiteaConfig.schema.json +++ b/Gitea.Declarative.Lib/GiteaConfig.schema.json @@ -62,12 +62,15 @@ "description": "The text that will accompany this repository in the Gitea UI" }, "gitHub": { - "type": [ - "null", - "string" - ], - "description": "If this repo is to sync from GitHub, the URI (e.g. 'https://github.com/Smaug123/nix-maui')", - "format": "uri" + "description": "If this repo is to sync from GitHub, information about the repo.", + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/SerialisedGitHubRepo" + } + ] }, "native": { "description": "If this repo is to be created natively on Gitea, the information about the repo.", @@ -96,6 +99,24 @@ } ] }, + "SerialisedGitHubRepo": { + "type": "object", + "description": "Information about a repo that is being mirrored from GitHub.", + "additionalProperties": false, + "required": [ + "uri" + ], + "properties": { + "uri": { + "type": "string", + "description": "e.g. https://github.com/Smaug123/nix-maui" + }, + "mirrorInterval": { + "type": "string", + "description": "A Golang string, e.g. \"8h30m0s\"" + } + } + }, "SerialisedNativeRepo": { "type": "object", "description": "Information about a repo that is to be created on Gitea without syncing from GitHub.", @@ -111,6 +132,54 @@ "private": { "type": "boolean", "description": "Whether this repository is a Gitea private repo" + }, + "ignoreWhitespaceConflicts": { + "type": "boolean", + "description": "either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace." + }, + "hasPullRequests": { + "type": "boolean", + "description": "either `true` to allow pull requests, or `false` to prevent pull request." + }, + "hasProjects": { + "type": "boolean", + "description": "either `true` to enable project unit, or `false` to disable them." + }, + "hasIssues": { + "type": "boolean", + "description": "either `true` to enable issues for this repository or `false` to disable them." + }, + "hasWiki": { + "type": "boolean", + "description": "either `true` to enable the wiki for this repository or `false` to disable it." + }, + "defaultMergeStyle": { + "type": "string", + "description": "set to a merge style to be used by this repository: \"merge\", \"rebase\", \"rebase-merge\", or \"squash\"." + }, + "deleteBranchAfterMerge": { + "type": "boolean", + "description": "set to `true` to delete pr branch after merge by default." + }, + "allowSquashMerge": { + "type": "boolean", + "description": "either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging." + }, + "allowRebaseUpdate": { + "type": "boolean", + "description": "either `true` to allow updating pull request branch by rebase, or `false` to prevent it." + }, + "allowRebase": { + "type": "boolean", + "description": "either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging." + }, + "allowRebaseExplicit": { + "type": "boolean", + "description": "either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits." + }, + "allowMergeCommits": { + "type": "boolean", + "description": "either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits." } } } diff --git a/Gitea.Declarative.Lib/SerialisedConfigSchema.fs b/Gitea.Declarative.Lib/SerialisedConfigSchema.fs index 3fc3351..d53e898 100644 --- a/Gitea.Declarative.Lib/SerialisedConfigSchema.fs +++ b/Gitea.Declarative.Lib/SerialisedConfigSchema.fs @@ -5,8 +5,11 @@ open System.Collections.Generic open System.ComponentModel open Newtonsoft.Json +type SerialisedMergeStyle = string + [] [] +[] [] type internal SerialisedNativeRepo = { @@ -16,6 +19,55 @@ type internal SerialisedNativeRepo = [] [] Private : Nullable + [] + [] + IgnoreWhitespaceConflicts : Nullable + [] + [] + HasPullRequests : Nullable + [] + [] + HasProjects : Nullable + [] + [] + HasIssues : Nullable + [] + [] + HasWiki : Nullable + [] + [] + DefaultMergeStyle : SerialisedMergeStyle + [] + [] + DeleteBranchAfterMerge : Nullable + [] + [] + AllowSquashMerge : Nullable + [] + [] + AllowRebaseUpdate : Nullable + [] + [] + AllowRebase : Nullable + [] + [] + AllowRebaseExplicit : Nullable + [] + [] + AllowMergeCommits : Nullable + } + +[] +[] +[] +type internal SerialisedGitHubRepo = + { + [] + [] + Uri : string + [] + [] + MirrorInterval : string } [] @@ -25,9 +77,9 @@ type internal SerialisedRepo = [] [] Description : string - [] + [] [] - GitHub : Uri + GitHub : Nullable [] [] Native : Nullable diff --git a/Gitea.Declarative.Lib/swagger.v1.json b/Gitea.Declarative.Lib/swagger.v1.json index befc2c7..e1aefa2 100644 --- a/Gitea.Declarative.Lib/swagger.v1.json +++ b/Gitea.Declarative.Lib/swagger.v1.json @@ -19,10 +19,62 @@ "name": "MIT", "url": "http://opensource.org/licenses/MIT" }, - "version": "1.17.4" + "version": "1.19.0" }, "basePath": "/api/v1", "paths": { + "/activitypub/user/{username}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "activitypub" + ], + "summary": "Returns the Person actor for a user", + "operationId": "activitypubPerson", + "parameters": [ + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/ActivityPub" + } + } + } + }, + "/activitypub/user/{username}/inbox": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "activitypub" + ], + "summary": "Send to the inbox", + "operationId": "activitypubPersonInbox", + "parameters": [ + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + } + }, "/admin/cron": { "get": { "produces": [ @@ -86,6 +138,127 @@ } } }, + "/admin/hooks": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "List system's webhooks", + "operationId": "adminListHooks", + "parameters": [ + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/HookList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Create a hook", + "operationId": "adminCreateHook", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateHookOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Hook" + } + } + } + }, + "/admin/hooks/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Get a hook", + "operationId": "adminGetHook", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the hook to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Hook" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Update a hook", + "operationId": "adminEditHook", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the hook to update", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditHookOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Hook" + } + } + } + }, "/admin/orgs": { "get": { "produces": [ @@ -320,6 +493,12 @@ "name": "username", "in": "path", "required": true + }, + { + "type": "boolean", + "description": "purge the user from the system completely", + "name": "purge", + "in": "query" } ], "responses": { @@ -534,6 +713,9 @@ "201": { "$ref": "#/responses/Repository" }, + "400": { + "$ref": "#/responses/error" + }, "403": { "$ref": "#/responses/forbidden" }, @@ -549,6 +731,33 @@ } } }, + "/amdin/hooks/{id}": { + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Delete a hook", + "operationId": "adminDeleteHook", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the hook to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + } + }, "/markdown": { "post": { "consumes": [ @@ -1079,9 +1288,7 @@ "$ref": "#/responses/HookList" } } - } - }, - "/orgs/{org}/hooks/": { + }, "post": { "consumes": [ "application/json" @@ -1722,6 +1929,9 @@ "201": { "$ref": "#/responses/Repository" }, + "400": { + "$ref": "#/responses/error" + }, "403": { "$ref": "#/responses/forbidden" }, @@ -1902,16 +2112,21 @@ }, { "enum": [ + "cargo", + "chef", "composer", "conan", + "conda", "container", "generic", "helm", "maven", "npm", "nuget", + "pub", "pypi", - "rubygems" + "rubygems", + "vagrant" ], "type": "string", "description": "package type filter", @@ -3212,6 +3427,12 @@ "name": "path", "in": "query" }, + { + "type": "boolean", + "description": "include diff stats for every commit (disable for speedup, default 'true')", + "name": "stat", + "in": "query" + }, { "type": "integer", "description": "page number of results to return (1-based)", @@ -5037,6 +5258,273 @@ } } }, + "/repos/{owner}/{repo}/issues/comments/{id}/assets": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List comment's attachments", + "operationId": "issueListIssueCommentAttachments", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the comment", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/AttachmentList" + }, + "404": { + "$ref": "#/responses/error" + } + } + }, + "post": { + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Create a comment attachment", + "operationId": "issueCreateIssueCommentAttachment", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the comment", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the attachment", + "name": "name", + "in": "query" + }, + { + "type": "file", + "description": "attachment to upload", + "name": "attachment", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "$ref": "#/responses/Attachment" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/error" + } + } + } + }, + "/repos/{owner}/{repo}/issues/comments/{id}/assets/{attachment_id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get a comment attachment", + "operationId": "issueGetIssueCommentAttachment", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the comment", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to get", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Attachment" + }, + "404": { + "$ref": "#/responses/error" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Delete a comment attachment", + "operationId": "issueDeleteIssueCommentAttachment", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the comment", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to delete", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/error" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Edit a comment attachment", + "operationId": "issueEditIssueCommentAttachment", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the comment", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to edit", + "name": "attachment_id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditAttachmentOptions" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Attachment" + }, + "404": { + "$ref": "#/responses/error" + } + } + } + }, "/repos/{owner}/{repo}/issues/comments/{id}/reactions": { "get": { "consumes": [ @@ -5335,6 +5823,273 @@ } } }, + "/repos/{owner}/{repo}/issues/{index}/assets": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List issue's attachments", + "operationId": "issueListIssueAttachments", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/AttachmentList" + }, + "404": { + "$ref": "#/responses/error" + } + } + }, + "post": { + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Create an issue attachment", + "operationId": "issueCreateIssueAttachment", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the attachment", + "name": "name", + "in": "query" + }, + { + "type": "file", + "description": "attachment to upload", + "name": "attachment", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "$ref": "#/responses/Attachment" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/error" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/assets/{attachment_id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get an issue attachment", + "operationId": "issueGetIssueAttachment", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to get", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Attachment" + }, + "404": { + "$ref": "#/responses/error" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Delete an issue attachment", + "operationId": "issueDeleteIssueAttachment", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to delete", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/error" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Edit an issue attachment", + "operationId": "issueEditIssueAttachment", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to edit", + "name": "attachment_id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditAttachmentOptions" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Attachment" + }, + "404": { + "$ref": "#/responses/error" + } + } + } + }, "/repos/{owner}/{repo}/issues/{index}/comments": { "get": { "produces": [ @@ -7967,6 +8722,80 @@ } } }, + "/repos/{owner}/{repo}/pulls/{index}/files": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get changed files for a pull request", + "operationId": "repoGetPullRequestFiles", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "index of the pull request to get", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "skip to given file", + "name": "skip-to", + "in": "query" + }, + { + "enum": [ + "ignore-all", + "ignore-change", + "ignore-eol", + "show-all" + ], + "type": "string", + "description": "whitespace behavior", + "name": "whitespace", + "in": "query" + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/ChangedFileList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, "/repos/{owner}/{repo}/pulls/{index}/merge": { "get": { "produces": [ @@ -8724,6 +9553,233 @@ } } }, + "/repos/{owner}/{repo}/push_mirrors": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get all push mirrors of the repository", + "operationId": "repoListPushMirrors", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/PushMirrorList" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "add a push mirror to the repository", + "operationId": "repoAddPushMirror", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreatePushMirrorOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/PushMirror" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + } + }, + "/repos/{owner}/{repo}/push_mirrors-sync": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Sync all push mirrored repository", + "operationId": "repoPushMirrorSync", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to sync", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to sync", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/empty" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + } + }, + "/repos/{owner}/{repo}/push_mirrors/{name}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get push mirror of the repository by remoteName", + "operationId": "repoGetPushMirrorByRemoteName", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "remote name of push mirror", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/PushMirror" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "deletes a push mirror from a repository by remoteName", + "operationId": "repoDeletePushMirror", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "remote name of the pushMirror", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, "/repos/{owner}/{repo}/raw/{filepath}": { "get": { "produces": [ @@ -8883,6 +9939,42 @@ } } }, + "/repos/{owner}/{repo}/releases/latest": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Gets the most recent non-prerelease, non-draft release of a repository, sorted by created_at", + "operationId": "repoGetLatestRelease", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Release" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, "/repos/{owner}/{repo}/releases/tags/{tag}": { "get": { "produces": [ @@ -12143,6 +13235,9 @@ "201": { "$ref": "#/responses/Repository" }, + "400": { + "$ref": "#/responses/error" + }, "409": { "description": "The repository with the same name already exists." }, @@ -13004,14 +14099,13 @@ "parameters": [ { "type": "string", - "x-go-name": "Name", "description": "username of user", "name": "username", "in": "path", "required": true }, { - "name": "userCreateToken", + "name": "body", "in": "body", "schema": { "$ref": "#/definitions/CreateAccessTokenOption" @@ -13114,6 +14208,13 @@ "type": "string", "x-go-name": "Name" }, + "scopes": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Scopes" + }, "sha1": { "type": "string", "x-go-name": "Token" @@ -13125,6 +14226,17 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "ActivityPub": { + "description": "ActivityPub type", + "type": "object", + "properties": { + "@context": { + "type": "string", + "x-go-name": "Context" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "AddCollaboratorOption": { "description": "AddCollaboratorOption options when adding a user as a collaborator of a repository", "type": "object", @@ -13329,6 +14441,7 @@ "x-go-name": "BlockOnRejectedReviews" }, "branch_name": { + "description": "Deprecated: true", "type": "string", "x-go-name": "BranchName" }, @@ -13406,6 +14519,10 @@ "format": "int64", "x-go-name": "RequiredApprovals" }, + "rule_name": { + "type": "string", + "x-go-name": "RuleName" + }, "status_check_contexts": { "type": "array", "items": { @@ -13425,6 +14542,52 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "ChangedFile": { + "description": "ChangedFile store information about files affected by the pull request", + "type": "object", + "properties": { + "additions": { + "type": "integer", + "format": "int64", + "x-go-name": "Additions" + }, + "changes": { + "type": "integer", + "format": "int64", + "x-go-name": "Changes" + }, + "contents_url": { + "type": "string", + "x-go-name": "ContentsURL" + }, + "deletions": { + "type": "integer", + "format": "int64", + "x-go-name": "Deletions" + }, + "filename": { + "type": "string", + "x-go-name": "Filename" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "previous_filename": { + "type": "string", + "x-go-name": "PreviousFilename" + }, + "raw_url": { + "type": "string", + "x-go-name": "RawURL" + }, + "status": { + "type": "string", + "x-go-name": "Status" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "CombinedStatus": { "description": "CombinedStatus holds the combined state of several statuses for a single commit", "type": "object", @@ -13466,6 +14629,13 @@ "description": "Comment represents a comment on a commit or issue", "type": "object", "properties": { + "assets": { + "type": "array", + "items": { + "$ref": "#/definitions/Attachment" + }, + "x-go-name": "Attachments" + }, "body": { "type": "string", "x-go-name": "Body" @@ -13730,6 +14900,10 @@ "type": "string", "x-go-name": "HTMLURL" }, + "last_commit_sha": { + "type": "string", + "x-go-name": "LastCommitSHA" + }, "name": { "type": "string", "x-go-name": "Name" @@ -13772,10 +14946,20 @@ "CreateAccessTokenOption": { "description": "CreateAccessTokenOption options when create access token", "type": "object", + "required": [ + "name" + ], "properties": { "name": { "type": "string", "x-go-name": "Name" + }, + "scopes": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Scopes" } }, "x-go-package": "code.gitea.io/gitea/modules/structs" @@ -13811,6 +14995,7 @@ "x-go-name": "BlockOnRejectedReviews" }, "branch_name": { + "description": "Deprecated: true", "type": "string", "x-go-name": "BranchName" }, @@ -13883,6 +15068,10 @@ "format": "int64", "x-go-name": "RequiredApprovals" }, + "rule_name": { + "type": "string", + "x-go-name": "RuleName" + }, "status_check_contexts": { "type": "array", "items": { @@ -14028,6 +15217,10 @@ "default": false, "x-go-name": "Active" }, + "authorization_header": { + "type": "string", + "x-go-name": "AuthorizationHeader" + }, "branch_filter": { "type": "string", "x-go-name": "BranchFilter" @@ -14186,6 +15379,11 @@ "type": "string", "x-go-name": "Description" }, + "exclusive": { + "type": "boolean", + "x-go-name": "Exclusive", + "example": false + }, "name": { "type": "string", "x-go-name": "Name" @@ -14225,6 +15423,10 @@ "description": "CreateOAuth2ApplicationOptions holds options to create an oauth2 application", "type": "object", "properties": { + "confidential_client": { + "type": "boolean", + "x-go-name": "ConfidentialClient" + }, "name": { "type": "string", "x-go-name": "Name" @@ -14388,6 +15590,33 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "CreatePushMirrorOption": { + "type": "object", + "title": "CreatePushMirrorOption represents need information to create a push mirror of a repository.", + "properties": { + "interval": { + "type": "string", + "x-go-name": "Interval" + }, + "remote_address": { + "type": "string", + "x-go-name": "RemoteAddress" + }, + "remote_password": { + "type": "string", + "x-go-name": "RemotePassword" + }, + "remote_username": { + "type": "string", + "x-go-name": "RemoteUsername" + }, + "sync_on_commit": { + "type": "boolean", + "x-go-name": "SyncOnCommit" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "CreateReleaseOption": { "description": "CreateReleaseOption options when creating a release", "type": "object", @@ -14593,7 +15822,16 @@ "type": "string" }, "x-go-name": "UnitsMap", - "example": "{\"repo.code\":\"read\",\"repo.issues\":\"write\",\"repo.ext_issues\":\"none\",\"repo.wiki\":\"admin\",\"repo.pulls\":\"owner\",\"repo.releases\":\"none\",\"repo.projects\":\"none\",\"repo.ext_wiki\":\"none\"]" + "example": { + "repo.code": "read", + "repo.ext_issues": "none", + "repo.ext_wiki": "none", + "repo.issues": "write", + "repo.projects": "none", + "repo.pulls": "owner", + "repo.releases": "none", + "repo.wiki": "admin" + } } }, "x-go-package": "code.gitea.io/gitea/modules/structs" @@ -14607,6 +15845,12 @@ "password" ], "properties": { + "created_at": { + "description": "For explicitly setting the user creation timestamp. Useful when users are\nmigrated from other systems. When omitted, the user's creation timestamp\nwill be set to \"now\".", + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, "email": { "type": "string", "format": "email", @@ -14981,6 +16225,10 @@ "type": "boolean", "x-go-name": "Active" }, + "authorization_header": { + "type": "string", + "x-go-name": "AuthorizationHeader" + }, "branch_filter": { "type": "string", "x-go-name": "BranchFilter" @@ -15071,12 +16319,18 @@ "properties": { "color": { "type": "string", - "x-go-name": "Color" + "x-go-name": "Color", + "example": "#00aabb" }, "description": { "type": "string", "x-go-name": "Description" }, + "exclusive": { + "type": "boolean", + "x-go-name": "Exclusive", + "example": false + }, "name": { "type": "string", "x-go-name": "Name" @@ -15252,32 +16506,32 @@ "type": "object", "properties": { "allow_manual_merge": { - "description": "either `true` to allow mark pr as merged manually, or `false` to prevent it. `has_pull_requests` must be `true`.", + "description": "either `true` to allow mark pr as merged manually, or `false` to prevent it.", "type": "boolean", "x-go-name": "AllowManualMerge" }, "allow_merge_commits": { - "description": "either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. `has_pull_requests` must be `true`.", + "description": "either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits.", "type": "boolean", "x-go-name": "AllowMerge" }, "allow_rebase": { - "description": "either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging. `has_pull_requests` must be `true`.", + "description": "either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging.", "type": "boolean", "x-go-name": "AllowRebase" }, "allow_rebase_explicit": { - "description": "either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits. `has_pull_requests` must be `true`.", + "description": "either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits.", "type": "boolean", "x-go-name": "AllowRebaseMerge" }, "allow_rebase_update": { - "description": "either `true` to allow updating pull request branch by rebase, or `false` to prevent it. `has_pull_requests` must be `true`.", + "description": "either `true` to allow updating pull request branch by rebase, or `false` to prevent it.", "type": "boolean", "x-go-name": "AllowRebaseUpdate" }, "allow_squash_merge": { - "description": "either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. `has_pull_requests` must be `true`.", + "description": "either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging.", "type": "boolean", "x-go-name": "AllowSquash" }, @@ -15287,10 +16541,15 @@ "x-go-name": "Archived" }, "autodetect_manual_merge": { - "description": "either `true` to enable AutodetectManualMerge, or `false` to prevent it. `has_pull_requests` must be `true`, Note: In some special cases, misjudgments can occur.", + "description": "either `true` to enable AutodetectManualMerge, or `false` to prevent it. Note: In some special cases, misjudgments can occur.", "type": "boolean", "x-go-name": "AutodetectManualMerge" }, + "default_allow_maintainer_edit": { + "description": "set to `true` to allow edits from maintainers by default", + "type": "boolean", + "x-go-name": "DefaultAllowMaintainerEdit" + }, "default_branch": { "description": "sets the default branch for this repository.", "type": "string", @@ -15302,7 +16561,7 @@ "x-go-name": "DefaultDeleteBranchAfterMerge" }, "default_merge_style": { - "description": "set to a merge style to be used by this repository: \"merge\", \"rebase\", \"rebase-merge\", or \"squash\". `has_pull_requests` must be `true`.", + "description": "set to a merge style to be used by this repository: \"merge\", \"rebase\", \"rebase-merge\", or \"squash\".", "type": "string", "x-go-name": "DefaultMergeStyle" }, @@ -15343,7 +16602,7 @@ "x-go-name": "HasWiki" }, "ignore_whitespace_conflicts": { - "description": "either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace. `has_pull_requests` must be `true`.", + "description": "either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace.", "type": "boolean", "x-go-name": "IgnoreWhitespaceConflicts" }, @@ -15434,7 +16693,16 @@ "type": "string" }, "x-go-name": "UnitsMap", - "example": "{\"repo.code\":\"read\",\"repo.issues\":\"write\",\"repo.ext_issues\":\"none\",\"repo.wiki\":\"admin\",\"repo.pulls\":\"owner\",\"repo.releases\":\"none\",\"repo.projects\":\"none\",\"repo.ext_wiki\":\"none\"]" + "example": { + "repo.code": "read", + "repo.ext_issues": "none", + "repo.ext_wiki": "none", + "repo.issues": "write", + "repo.projects": "none", + "repo.pulls": "owner", + "repo.releases": "none", + "repo.wiki": "admin" + } } }, "x-go-package": "code.gitea.io/gitea/modules/structs" @@ -15554,8 +16822,13 @@ "type": "string", "x-go-name": "ExternalTrackerFormat" }, + "external_tracker_regexp_pattern": { + "description": "External Issue Tracker issue regular expression", + "type": "string", + "x-go-name": "ExternalTrackerRegexpPattern" + }, "external_tracker_style": { - "description": "External Issue Tracker Number Format, either `numeric` or `alphanumeric`", + "description": "External Issue Tracker Number Format, either `numeric`, `alphanumeric`, or `regexp`", "type": "string", "x-go-name": "ExternalTrackerStyle" }, @@ -16030,12 +17303,6 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, - "GitServiceType": { - "description": "GitServiceType represents a git service", - "type": "integer", - "format": "int64", - "x-go-package": "code.gitea.io/gitea/modules/structs" - }, "GitTreeResponse": { "description": "GitTreeResponse returns a git tree", "type": "object", @@ -16080,6 +17347,10 @@ "type": "boolean", "x-go-name": "Active" }, + "authorization_header": { + "type": "string", + "x-go-name": "AuthorizationHeader" + }, "config": { "type": "object", "additionalProperties": { @@ -16158,6 +17429,13 @@ "description": "Issue represents an issue in a repository", "type": "object", "properties": { + "assets": { + "type": "array", + "items": { + "$ref": "#/definitions/Attachment" + }, + "x-go-name": "Attachments" + }, "assignee": { "$ref": "#/definitions/User" }, @@ -16273,6 +17551,35 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "IssueFormField": { + "description": "IssueFormField represents a form field", + "type": "object", + "properties": { + "attributes": { + "type": "object", + "additionalProperties": {}, + "x-go-name": "Attributes" + }, + "id": { + "type": "string", + "x-go-name": "ID" + }, + "type": { + "$ref": "#/definitions/IssueFormFieldType" + }, + "validations": { + "type": "object", + "additionalProperties": {}, + "x-go-name": "Validations" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "IssueFormFieldType": { + "type": "string", + "title": "IssueFormFieldType defines issue form field type, can be \"markdown\", \"textarea\", \"input\", \"dropdown\" or \"checkboxes\"", + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "IssueLabelsOption": { "description": "IssueLabelsOption a collection of labels", "type": "object", @@ -16297,6 +17604,13 @@ "type": "string", "x-go-name": "About" }, + "body": { + "type": "array", + "items": { + "$ref": "#/definitions/IssueFormField" + }, + "x-go-name": "Fields" + }, "content": { "type": "string", "x-go-name": "Content" @@ -16306,11 +17620,7 @@ "x-go-name": "FileName" }, "labels": { - "type": "array", - "items": { - "type": "string" - }, - "x-go-name": "Labels" + "$ref": "#/definitions/IssueTemplateLabels" }, "name": { "type": "string", @@ -16327,6 +17637,13 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "IssueTemplateLabels": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "Label": { "description": "Label a label to an issue or a pr", "type": "object", @@ -16340,6 +17657,11 @@ "type": "string", "x-go-name": "Description" }, + "exclusive": { + "type": "boolean", + "x-go-name": "Exclusive", + "example": false + }, "id": { "type": "integer", "format": "int64", @@ -16425,94 +17747,6 @@ "x-go-name": "MergePullRequestForm", "x-go-package": "code.gitea.io/gitea/services/forms" }, - "MigrateRepoForm": { - "description": "MigrateRepoForm form for migrating repository\nthis is used to interact with web ui", - "type": "object", - "required": [ - "clone_addr", - "uid", - "repo_name" - ], - "properties": { - "auth_password": { - "type": "string", - "x-go-name": "AuthPassword" - }, - "auth_token": { - "type": "string", - "x-go-name": "AuthToken" - }, - "auth_username": { - "type": "string", - "x-go-name": "AuthUsername" - }, - "clone_addr": { - "type": "string", - "x-go-name": "CloneAddr" - }, - "description": { - "type": "string", - "x-go-name": "Description" - }, - "issues": { - "type": "boolean", - "x-go-name": "Issues" - }, - "labels": { - "type": "boolean", - "x-go-name": "Labels" - }, - "lfs": { - "type": "boolean", - "x-go-name": "LFS" - }, - "lfs_endpoint": { - "type": "string", - "x-go-name": "LFSEndpoint" - }, - "milestones": { - "type": "boolean", - "x-go-name": "Milestones" - }, - "mirror": { - "type": "boolean", - "x-go-name": "Mirror" - }, - "mirror_interval": { - "type": "string", - "x-go-name": "MirrorInterval" - }, - "private": { - "type": "boolean", - "x-go-name": "Private" - }, - "pull_requests": { - "type": "boolean", - "x-go-name": "PullRequests" - }, - "releases": { - "type": "boolean", - "x-go-name": "Releases" - }, - "repo_name": { - "type": "string", - "x-go-name": "RepoName" - }, - "service": { - "$ref": "#/definitions/GitServiceType" - }, - "uid": { - "type": "integer", - "format": "int64", - "x-go-name": "UID" - }, - "wiki": { - "type": "boolean", - "x-go-name": "Wiki" - } - }, - "x-go-package": "code.gitea.io/gitea/services/forms" - }, "MigrateRepoOptions": { "description": "MigrateRepoOptions options for migrating repository's\nthis is used to interact with api v1", "type": "object", @@ -16898,6 +18132,10 @@ "type": "string", "x-go-name": "ClientSecret" }, + "confidential_client": { + "type": "boolean", + "x-go-name": "ConfidentialClient" + }, "created": { "type": "string", "format": "date-time", @@ -16947,11 +18185,16 @@ "type": "string", "x-go-name": "Location" }, + "name": { + "type": "string", + "x-go-name": "Name" + }, "repo_admin_change_team_access": { "type": "boolean", "x-go-name": "RepoAdminChangeTeamAccess" }, "username": { + "description": "deprecated", "type": "string", "x-go-name": "UserName" }, @@ -17458,6 +18701,11 @@ "team": { "$ref": "#/definitions/Team" }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, "user": { "$ref": "#/definitions/User" } @@ -17556,6 +18804,45 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "PushMirror": { + "description": "PushMirror represents information of a push mirror", + "type": "object", + "properties": { + "created": { + "type": "string", + "x-go-name": "CreatedUnix" + }, + "interval": { + "type": "string", + "x-go-name": "Interval" + }, + "last_error": { + "type": "string", + "x-go-name": "LastError" + }, + "last_update": { + "type": "string", + "x-go-name": "LastUpdateUnix" + }, + "remote_address": { + "type": "string", + "x-go-name": "RemoteAddress" + }, + "remote_name": { + "type": "string", + "x-go-name": "RemoteName" + }, + "repo_name": { + "type": "string", + "x-go-name": "RepoName" + }, + "sync_on_commit": { + "type": "boolean", + "x-go-name": "SyncOnCommit" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "Reaction": { "description": "Reaction contain one reaction", "type": "object", @@ -17761,6 +19048,10 @@ "type": "boolean", "x-go-name": "AllowRebaseMerge" }, + "allow_rebase_update": { + "type": "boolean", + "x-go-name": "AllowRebaseUpdate" + }, "allow_squash_merge": { "type": "boolean", "x-go-name": "AllowSquash" @@ -17782,10 +19073,18 @@ "format": "date-time", "x-go-name": "Created" }, + "default_allow_maintainer_edit": { + "type": "boolean", + "x-go-name": "DefaultAllowMaintainerEdit" + }, "default_branch": { "type": "string", "x-go-name": "DefaultBranch" }, + "default_delete_branch_after_merge": { + "type": "boolean", + "x-go-name": "DefaultDeleteBranchAfterMerge" + }, "default_merge_style": { "type": "string", "x-go-name": "DefaultMergeStyle" @@ -17861,6 +19160,10 @@ "type": "string", "x-go-name": "LanguagesURL" }, + "link": { + "type": "string", + "x-go-name": "Link" + }, "mirror": { "type": "boolean", "x-go-name": "Mirror" @@ -18155,7 +19458,16 @@ "type": "string" }, "x-go-name": "UnitsMap", - "example": "{\"repo.code\":\"read\",\"repo.issues\":\"write\",\"repo.ext_issues\":\"none\",\"repo.wiki\":\"admin\",\"repo.pulls\":\"owner\",\"repo.releases\":\"none\",\"repo.projects\":\"none\",\"repo.ext_wiki\":\"none\"]" + "example": { + "repo.code": "read", + "repo.ext_issues": "none", + "repo.ext_wiki": "none", + "repo.issues": "write", + "repo.projects": "none", + "repo.pulls": "owner", + "repo.releases": "none", + "repo.wiki": "admin" + } } }, "x-go-package": "code.gitea.io/gitea/modules/structs" @@ -18527,6 +19839,12 @@ "type": "string", "x-go-name": "UserName" }, + "login_name": { + "description": "the user's authentication sign-in name.", + "type": "string", + "default": "empty", + "x-go-name": "LoginName" + }, "prohibit_login": { "description": "Is user login prohibited", "type": "boolean", @@ -18568,7 +19886,7 @@ "$ref": "#/definitions/TimeStamp" } }, - "x-go-package": "code.gitea.io/gitea/models" + "x-go-package": "code.gitea.io/gitea/models/activities" }, "UserSettings": { "description": "UserSettings represents user settings", @@ -18808,6 +20126,12 @@ } } }, + "ActivityPub": { + "description": "ActivityPub", + "schema": { + "$ref": "#/definitions/ActivityPub" + } + }, "AnnotatedTag": { "description": "AnnotatedTag", "schema": { @@ -18859,6 +20183,41 @@ } } }, + "ChangedFileList": { + "description": "ChangedFileList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ChangedFile" + } + }, + "headers": { + "X-HasMore": { + "type": "boolean", + "description": "True if there is another page" + }, + "X-Page": { + "type": "integer", + "format": "int64", + "description": "The current page" + }, + "X-PageCount": { + "type": "integer", + "format": "int64", + "description": "Total number of pages" + }, + "X-PerPage": { + "type": "integer", + "format": "int64", + "description": "Commits per page" + }, + "X-Total": { + "type": "integer", + "format": "int64", + "description": "Total commit count" + } + } + }, "CombinedStatus": { "description": "CombinedStatus", "schema": { @@ -19312,6 +20671,21 @@ } } }, + "PushMirror": { + "description": "PushMirror", + "schema": { + "$ref": "#/definitions/PushMirror" + } + }, + "PushMirrorList": { + "description": "PushMirrorList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PushMirror" + } + } + }, "Reaction": { "description": "Reaction", "schema": { @@ -19591,7 +20965,7 @@ "parameterBodies": { "description": "parameterBodies", "schema": { - "$ref": "#/definitions/CreateWikiPageOptions" + "$ref": "#/definitions/CreatePushMirrorOption" } }, "redirect": { diff --git a/Gitea.Declarative.Test/GiteaConfig.json b/Gitea.Declarative.Test/GiteaConfig.json index 9f02e9b..6ba71c9 100644 --- a/Gitea.Declarative.Test/GiteaConfig.json +++ b/Gitea.Declarative.Test/GiteaConfig.json @@ -16,11 +16,15 @@ "nonadmin-user": { "synced-from-github-repo-1": { "description": "A repo that is imported from GitHub", - "gitHub": "https://github.com/MyName/repo-name" + "gitHub": { + "uri": "https://github.com/MyName/repo-name" + } }, "synced-from-github-repo-2": { "description": "Another repo that is imported from GitHub", - "gitHub": "https://github.com/MyName/repo-name-2" + "gitHub": { + "uri": "https://github.com/MyName/repo-name-2" + } }, "new-repo": { "description": "A repo that's created directly on this Gitea", diff --git a/Gitea.Declarative/Program.fs b/Gitea.Declarative/Program.fs index f99c34f..7514f63 100644 --- a/Gitea.Declarative/Program.fs +++ b/Gitea.Declarative/Program.fs @@ -13,6 +13,7 @@ type ArgsFragments = | [] Gitea_Host of string | [] Gitea_Admin_Api_Token of string | [] GitHub_Api_Token of string + | Dry_Run interface IArgParserTemplate with member s.Usage = @@ -22,6 +23,7 @@ type ArgsFragments = | Gitea_Host _ -> "the Gitea host, e.g. https://gitea.mydomain.com" | Gitea_Admin_Api_Token _ -> "a Gitea admin user's API token" | GitHub_Api_Token _ -> "a GitHub API token with read access to every desired sync-from-GitHub repo" + | Dry_Run _ -> "don't actually perform the reconciliation" type Args = { @@ -29,6 +31,7 @@ type Args = GiteaHost : Uri GiteaAdminApiToken : string GitHubApiToken : string option + DryRun : bool } module Program = @@ -55,6 +58,7 @@ module Program = GiteaHost = parsed.GetResult ArgsFragments.Gitea_Host |> Uri GiteaAdminApiToken = parsed.GetResult ArgsFragments.Gitea_Admin_Api_Token GitHubApiToken = parsed.TryGetResult ArgsFragments.GitHub_Api_Token + DryRun = parsed.TryGetResult ArgsFragments.Dry_Run |> Option.isSome } let config = GiteaConfig.get args.ConfigFile @@ -85,16 +89,26 @@ module Program = logger.LogInformation "Checking users..." let! userErrors = Gitea.checkUsers config client - match userErrors with - | Ok () -> () - | Error errors -> do! Gitea.reconcileUserErrors logger getUserInput client errors + match userErrors, args.DryRun with + | Ok (), _ -> () + | Error errors, false -> do! Gitea.reconcileUserErrors logger getUserInput client errors + | Error errors, true -> + logger.LogError ( + "Differences encountered in user configuration, but not reconciling them due to --dry-run. Errors may occur while checking repo configuration. {UserErrors}", + errors + ) logger.LogInformation "Checking repos..." let! repoErrors = Gitea.checkRepos config client - match repoErrors with - | Ok () -> () - | Error errors -> do! Gitea.reconcileRepoErrors logger client args.GitHubApiToken errors + match repoErrors, args.DryRun with + | Ok (), _ -> () + | Error errors, false -> do! Gitea.reconcileRepoErrors logger client args.GitHubApiToken errors + | Error errors, true -> + logger.LogError ( + "Differences encountered in repo configuration, but not reconciling them due to --dry-run. {RepoErrors}", + errors + ) match userErrors, repoErrors with | Ok (), Ok () -> return 0