mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-25 11:16:11 +01:00
Merge branch 'forgejo' into forgejo-federated-star
This commit is contained in:
commit
130981af64
|
@ -22,7 +22,7 @@ jobs:
|
||||||
|
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: ghcr.io/visualon/renovate:37.385.0
|
image: ghcr.io/visualon/renovate:37.391.2
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Load renovate repo cache
|
- name: Load renovate repo cache
|
||||||
|
|
|
@ -46,7 +46,7 @@ jobs:
|
||||||
image: 'docker.io/node:20-bookworm'
|
image: 'docker.io/node:20-bookworm'
|
||||||
services:
|
services:
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
image: elasticsearch:7.5.0
|
image: elasticsearch:7.17.21
|
||||||
env:
|
env:
|
||||||
discovery.type: single-node
|
discovery.type: single-node
|
||||||
minio:
|
minio:
|
||||||
|
|
7
Makefile
7
Makefile
|
@ -36,7 +36,6 @@ SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0 # renova
|
||||||
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
||||||
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.6.0 # renovate: datasource=go
|
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.6.0 # renovate: datasource=go
|
||||||
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1 # renovate: datasource=go
|
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1 # renovate: datasource=go
|
||||||
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1.6.27 # renovate: datasource=go
|
|
||||||
DEADCODE_PACKAGE ?= golang.org/x/tools/internal/cmd/deadcode@v0.14.0 # renovate: datasource=go
|
DEADCODE_PACKAGE ?= golang.org/x/tools/internal/cmd/deadcode@v0.14.0 # renovate: datasource=go
|
||||||
GOMOCK_PACKAGE ?= go.uber.org/mock/mockgen@v0.4.0 # renovate: datasource=go
|
GOMOCK_PACKAGE ?= go.uber.org/mock/mockgen@v0.4.0 # renovate: datasource=go
|
||||||
|
|
||||||
|
@ -219,7 +218,6 @@ help:
|
||||||
@echo " - deps-py install python dependencies"
|
@echo " - deps-py install python dependencies"
|
||||||
@echo " - lint lint everything"
|
@echo " - lint lint everything"
|
||||||
@echo " - lint-fix lint everything and fix issues"
|
@echo " - lint-fix lint everything and fix issues"
|
||||||
@echo " - lint-actions lint action workflow files"
|
|
||||||
@echo " - lint-frontend lint frontend files"
|
@echo " - lint-frontend lint frontend files"
|
||||||
@echo " - lint-frontend-fix lint frontend files and fix issues"
|
@echo " - lint-frontend-fix lint frontend files and fix issues"
|
||||||
@echo " - lint-backend lint backend files"
|
@echo " - lint-backend lint backend files"
|
||||||
|
@ -472,10 +470,6 @@ lint-go-vet:
|
||||||
lint-editorconfig:
|
lint-editorconfig:
|
||||||
$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates .forgejo/workflows
|
$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates .forgejo/workflows
|
||||||
|
|
||||||
.PHONY: lint-actions
|
|
||||||
lint-actions:
|
|
||||||
$(GO) run $(ACTIONLINT_PACKAGE)
|
|
||||||
|
|
||||||
.PHONY: lint-templates
|
.PHONY: lint-templates
|
||||||
lint-templates: .venv node_modules
|
lint-templates: .venv node_modules
|
||||||
@node tools/lint-templates-svg.js
|
@node tools/lint-templates-svg.js
|
||||||
|
@ -882,7 +876,6 @@ deps-tools:
|
||||||
$(GO) install $(XGO_PACKAGE)
|
$(GO) install $(XGO_PACKAGE)
|
||||||
$(GO) install $(GO_LICENSES_PACKAGE)
|
$(GO) install $(GO_LICENSES_PACKAGE)
|
||||||
$(GO) install $(GOVULNCHECK_PACKAGE)
|
$(GO) install $(GOVULNCHECK_PACKAGE)
|
||||||
$(GO) install $(ACTIONLINT_PACKAGE)
|
|
||||||
$(GO) install $(GOMOCK_PACKAGE)
|
$(GO) install $(GOMOCK_PACKAGE)
|
||||||
|
|
||||||
node_modules: package-lock.json
|
node_modules: package-lock.json
|
||||||
|
|
6
go.mod
6
go.mod
|
@ -1,6 +1,8 @@
|
||||||
module code.gitea.io/gitea
|
module code.gitea.io/gitea
|
||||||
|
|
||||||
go 1.22.3
|
go 1.22.0
|
||||||
|
|
||||||
|
toolchain go1.22.3
|
||||||
|
|
||||||
require (
|
require (
|
||||||
code.forgejo.org/forgejo/reply v1.0.1
|
code.forgejo.org/forgejo/reply v1.0.1
|
||||||
|
@ -310,3 +312,5 @@ exclude github.com/gofrs/uuid v4.0.0+incompatible
|
||||||
exclude github.com/goccy/go-json v0.4.11
|
exclude github.com/goccy/go-json v0.4.11
|
||||||
|
|
||||||
exclude github.com/satori/go.uuid v1.2.0
|
exclude github.com/satori/go.uuid v1.2.0
|
||||||
|
|
||||||
|
replace github.com/mholt/archiver/v3 => code.forgejo.org/forgejo/archiver/v3 v3.5.1
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -2,6 +2,8 @@ cloud.google.com/go/compute v1.23.3 h1:6sVlXXBmbd7jNX0Ipq0trII3e4n1/MsADLK6a+aiV
|
||||||
cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI=
|
cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI=
|
||||||
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
|
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
|
||||||
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
|
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
|
||||||
|
code.forgejo.org/forgejo/archiver/v3 v3.5.1 h1:UmmbA7D5550uf71SQjarmrn6yKwOGxtEjb3jaYYtmSE=
|
||||||
|
code.forgejo.org/forgejo/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4=
|
||||||
code.forgejo.org/forgejo/reply v1.0.1 h1:usZi5yx7/g0D+xtGPJEM6mCvoDNdWvmtJu5J9/B/KBI=
|
code.forgejo.org/forgejo/reply v1.0.1 h1:usZi5yx7/g0D+xtGPJEM6mCvoDNdWvmtJu5J9/B/KBI=
|
||||||
code.forgejo.org/forgejo/reply v1.0.1/go.mod h1:RyZUfzQLc+fuLIGjTSQWDAJWPiL4WtKXB/FifT5fM7U=
|
code.forgejo.org/forgejo/reply v1.0.1/go.mod h1:RyZUfzQLc+fuLIGjTSQWDAJWPiL4WtKXB/FifT5fM7U=
|
||||||
code.gitea.io/actions-proto-go v0.4.0 h1:OsPBPhodXuQnsspG1sQ4eRE1PeoZyofd7+i73zCwnsU=
|
code.gitea.io/actions-proto-go v0.4.0 h1:OsPBPhodXuQnsspG1sQ4eRE1PeoZyofd7+i73zCwnsU=
|
||||||
|
@ -515,8 +517,6 @@ github.com/meilisearch/meilisearch-go v0.26.1 h1:3bmo2uLijX7kvBmiZ9LupVfC95TFcRJ
|
||||||
github.com/meilisearch/meilisearch-go v0.26.1/go.mod h1:SxuSqDcPBIykjWz1PX+KzsYzArNLSCadQodWs8extS0=
|
github.com/meilisearch/meilisearch-go v0.26.1/go.mod h1:SxuSqDcPBIykjWz1PX+KzsYzArNLSCadQodWs8extS0=
|
||||||
github.com/mholt/acmez/v2 v2.0.1 h1:3/3N0u1pLjMK4sNEAFSI+bcvzbPhRpY383sy1kLHJ6k=
|
github.com/mholt/acmez/v2 v2.0.1 h1:3/3N0u1pLjMK4sNEAFSI+bcvzbPhRpY383sy1kLHJ6k=
|
||||||
github.com/mholt/acmez/v2 v2.0.1/go.mod h1:fX4c9r5jYwMyMsC+7tkYRxHibkOTgta5DIFGoe67e1U=
|
github.com/mholt/acmez/v2 v2.0.1/go.mod h1:fX4c9r5jYwMyMsC+7tkYRxHibkOTgta5DIFGoe67e1U=
|
||||||
github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo=
|
|
||||||
github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4=
|
|
||||||
github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58=
|
github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58=
|
||||||
github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs=
|
github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs=
|
||||||
github.com/miekg/dns v1.1.59 h1:C9EXc/UToRwKLhK5wKU/I4QVsBUc8kE6MkHBkeypWZs=
|
github.com/miekg/dns v1.1.59 h1:C9EXc/UToRwKLhK5wKU/I4QVsBUc8kE6MkHBkeypWZs=
|
||||||
|
|
|
@ -431,6 +431,21 @@ func (pr *PullRequest) GetGitHeadBranchRefName() string {
|
||||||
return fmt.Sprintf("%s%s", git.BranchPrefix, pr.HeadBranch)
|
return fmt.Sprintf("%s%s", git.BranchPrefix, pr.HeadBranch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetReviewCommentsCount returns the number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)
|
||||||
|
func (pr *PullRequest) GetReviewCommentsCount(ctx context.Context) int {
|
||||||
|
opts := FindCommentsOptions{
|
||||||
|
Type: CommentTypeReview,
|
||||||
|
IssueID: pr.IssueID,
|
||||||
|
}
|
||||||
|
conds := opts.ToConds()
|
||||||
|
|
||||||
|
count, err := db.GetEngine(ctx).Where(conds).Count(new(Comment))
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return int(count)
|
||||||
|
}
|
||||||
|
|
||||||
// IsChecking returns true if this pull request is still checking conflict.
|
// IsChecking returns true if this pull request is still checking conflict.
|
||||||
func (pr *PullRequest) IsChecking() bool {
|
func (pr *PullRequest) IsChecking() bool {
|
||||||
return pr.Status == PullRequestStatusChecking
|
return pr.Status == PullRequestStatusChecking
|
||||||
|
|
|
@ -10,30 +10,30 @@ import (
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
var UninitializedStorage = discardStorage("uninitialized storage")
|
var UninitializedStorage = DiscardStorage("uninitialized storage")
|
||||||
|
|
||||||
type discardStorage string
|
type DiscardStorage string
|
||||||
|
|
||||||
func (s discardStorage) Open(_ string) (Object, error) {
|
func (s DiscardStorage) Open(_ string) (Object, error) {
|
||||||
return nil, fmt.Errorf("%s", s)
|
return nil, fmt.Errorf("%s", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s discardStorage) Save(_ string, _ io.Reader, _ int64) (int64, error) {
|
func (s DiscardStorage) Save(_ string, _ io.Reader, _ int64) (int64, error) {
|
||||||
return 0, fmt.Errorf("%s", s)
|
return 0, fmt.Errorf("%s", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s discardStorage) Stat(_ string) (os.FileInfo, error) {
|
func (s DiscardStorage) Stat(_ string) (os.FileInfo, error) {
|
||||||
return nil, fmt.Errorf("%s", s)
|
return nil, fmt.Errorf("%s", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s discardStorage) Delete(_ string) error {
|
func (s DiscardStorage) Delete(_ string) error {
|
||||||
return fmt.Errorf("%s", s)
|
return fmt.Errorf("%s", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s discardStorage) URL(_, _ string) (*url.URL, error) {
|
func (s DiscardStorage) URL(_, _ string) (*url.URL, error) {
|
||||||
return nil, fmt.Errorf("%s", s)
|
return nil, fmt.Errorf("%s", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s discardStorage) IterateObjects(_ string, _ func(string, Object) error) error {
|
func (s DiscardStorage) IterateObjects(_ string, _ func(string, Object) error) error {
|
||||||
return fmt.Errorf("%s", s)
|
return fmt.Errorf("%s", s)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_discardStorage(t *testing.T) {
|
func Test_discardStorage(t *testing.T) {
|
||||||
tests := []discardStorage{
|
tests := []DiscardStorage{
|
||||||
UninitializedStorage,
|
UninitializedStorage,
|
||||||
discardStorage("empty"),
|
DiscardStorage("empty"),
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(string(tt), func(t *testing.T) {
|
t.Run(string(tt), func(t *testing.T) {
|
||||||
|
|
|
@ -170,7 +170,7 @@ func initAvatars() (err error) {
|
||||||
|
|
||||||
func initAttachments() (err error) {
|
func initAttachments() (err error) {
|
||||||
if !setting.Attachment.Enabled {
|
if !setting.Attachment.Enabled {
|
||||||
Attachments = discardStorage("Attachment isn't enabled")
|
Attachments = DiscardStorage("Attachment isn't enabled")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.Info("Initialising Attachment storage with type: %s", setting.Attachment.Storage.Type)
|
log.Info("Initialising Attachment storage with type: %s", setting.Attachment.Storage.Type)
|
||||||
|
@ -180,7 +180,7 @@ func initAttachments() (err error) {
|
||||||
|
|
||||||
func initLFS() (err error) {
|
func initLFS() (err error) {
|
||||||
if !setting.LFS.StartServer {
|
if !setting.LFS.StartServer {
|
||||||
LFS = discardStorage("LFS isn't enabled")
|
LFS = DiscardStorage("LFS isn't enabled")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.Info("Initialising LFS storage with type: %s", setting.LFS.Storage.Type)
|
log.Info("Initialising LFS storage with type: %s", setting.LFS.Storage.Type)
|
||||||
|
@ -202,7 +202,7 @@ func initRepoArchives() (err error) {
|
||||||
|
|
||||||
func initPackages() (err error) {
|
func initPackages() (err error) {
|
||||||
if !setting.Packages.Enabled {
|
if !setting.Packages.Enabled {
|
||||||
Packages = discardStorage("Packages isn't enabled")
|
Packages = DiscardStorage("Packages isn't enabled")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.Info("Initialising Packages storage with type: %s", setting.Packages.Storage.Type)
|
log.Info("Initialising Packages storage with type: %s", setting.Packages.Storage.Type)
|
||||||
|
@ -212,8 +212,8 @@ func initPackages() (err error) {
|
||||||
|
|
||||||
func initActions() (err error) {
|
func initActions() (err error) {
|
||||||
if !setting.Actions.Enabled {
|
if !setting.Actions.Enabled {
|
||||||
Actions = discardStorage("Actions isn't enabled")
|
Actions = DiscardStorage("Actions isn't enabled")
|
||||||
ActionsArtifacts = discardStorage("ActionsArtifacts isn't enabled")
|
ActionsArtifacts = DiscardStorage("ActionsArtifacts isn't enabled")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.Info("Initialising Actions storage with type: %s", setting.Actions.LogStorage.Type)
|
log.Info("Initialising Actions storage with type: %s", setting.Actions.LogStorage.Type)
|
||||||
|
|
|
@ -30,6 +30,7 @@ type PullRequestMeta struct {
|
||||||
HasMerged bool `json:"merged"`
|
HasMerged bool `json:"merged"`
|
||||||
Merged *time.Time `json:"merged_at"`
|
Merged *time.Time `json:"merged_at"`
|
||||||
IsWorkInProgress bool `json:"draft"`
|
IsWorkInProgress bool `json:"draft"`
|
||||||
|
HTMLURL string `json:"html_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RepositoryMeta basic repository information
|
// RepositoryMeta basic repository information
|
||||||
|
|
|
@ -21,8 +21,14 @@ type PullRequest struct {
|
||||||
Assignees []*User `json:"assignees"`
|
Assignees []*User `json:"assignees"`
|
||||||
RequestedReviewers []*User `json:"requested_reviewers"`
|
RequestedReviewers []*User `json:"requested_reviewers"`
|
||||||
State StateType `json:"state"`
|
State StateType `json:"state"`
|
||||||
|
Draft bool `json:"draft"`
|
||||||
IsLocked bool `json:"is_locked"`
|
IsLocked bool `json:"is_locked"`
|
||||||
Comments int `json:"comments"`
|
Comments int `json:"comments"`
|
||||||
|
// number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)
|
||||||
|
ReviewComments int `json:"review_comments"`
|
||||||
|
Additions int `json:"additions"`
|
||||||
|
Deletions int `json:"deletions"`
|
||||||
|
ChangedFiles int `json:"changed_files"`
|
||||||
|
|
||||||
HTMLURL string `json:"html_url"`
|
HTMLURL string `json:"html_url"`
|
||||||
DiffURL string `json:"diff_url"`
|
DiffURL string `json:"diff_url"`
|
||||||
|
|
|
@ -27,6 +27,8 @@ type User struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
// URL to the user's avatar
|
// URL to the user's avatar
|
||||||
AvatarURL string `json:"avatar_url"`
|
AvatarURL string `json:"avatar_url"`
|
||||||
|
// URL to the user's gitea page
|
||||||
|
HTMLURL string `json:"html_url"`
|
||||||
// User locale
|
// User locale
|
||||||
Language string `json:"language"`
|
Language string `json:"language"`
|
||||||
// Is the user an administrator
|
// Is the user an administrator
|
||||||
|
|
1
release-notes/8.0.0/feat/4027.md
Normal file
1
release-notes/8.0.0/feat/4027.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
- Gitea/Forgejo webhook payload include additional fields (`html_url`, `additions`, `deletions`, `review_comments`...) for better compatbility with [OpenProject](https://www.openproject.org/), ported from [gitea#28435](https://github.com/go-gitea/gitea/pull/28435).
|
1
release-notes/8.0.0/fix/4026.md
Normal file
1
release-notes/8.0.0/fix/4026.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
- when an OAuth grant request submitted to a Forgejo user is denied, the server from which the request originates is not notified that it has been denied
|
|
@ -28,7 +28,8 @@
|
||||||
"python",
|
"python",
|
||||||
"golang",
|
"golang",
|
||||||
"docker.io/golang",
|
"docker.io/golang",
|
||||||
"docker.io/library/golang"
|
"docker.io/library/golang",
|
||||||
|
"mcr.microsoft.com/devcontainers/go"
|
||||||
],
|
],
|
||||||
"matchUpdateTypes": ["minor"],
|
"matchUpdateTypes": ["minor"],
|
||||||
"dependencyDashboardApproval": true
|
"dependencyDashboardApproval": true
|
||||||
|
@ -74,7 +75,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Split minor and patch updates",
|
"description": "Split minor and patch updates",
|
||||||
"matchDepNames": ["vue", "github.com/urfave/cli/v2", "swagger-ui-dist"],
|
"matchDepNames": [
|
||||||
|
"docker.io/golang",
|
||||||
|
"docker.io/library/golang",
|
||||||
|
"github.com/urfave/cli/v2",
|
||||||
|
"go",
|
||||||
|
"golang",
|
||||||
|
"python",
|
||||||
|
"swagger-ui-dist",
|
||||||
|
"vue"
|
||||||
|
],
|
||||||
"separateMinorPatch": true
|
"separateMinorPatch": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -89,6 +99,13 @@
|
||||||
"matchDepNames": ["ghcr.io/visualon/renovate"],
|
"matchDepNames": ["ghcr.io/visualon/renovate"],
|
||||||
"prPriority": 10
|
"prPriority": 10
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "Update go patch with higher prio to come through rate limit",
|
||||||
|
"matchDepNames": ["go", "golang", "docker.io/golang", "docker.io/library/golang"],
|
||||||
|
"matchUpdateTypes": ["patch"],
|
||||||
|
"prPriority": 10,
|
||||||
|
"schedule": ["at any time"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "Disable actions/cascading-pr for now <https://github.com/renovatebot/renovate/issues/28120>",
|
"description": "Disable actions/cascading-pr for now <https://github.com/renovatebot/renovate/issues/28120>",
|
||||||
"matchDepNames": ["actions/cascading-pr"],
|
"matchDepNames": ["actions/cascading-pr"],
|
||||||
|
@ -99,23 +116,23 @@
|
||||||
"description": "Automerge some packages when CI succeeds",
|
"description": "Automerge some packages when CI succeeds",
|
||||||
"extends": ["packages:linters", "packages:test"],
|
"extends": ["packages:linters", "packages:test"],
|
||||||
"matchDepNames": [
|
"matchDepNames": [
|
||||||
"github.com/golangci/golangci-lint/cmd/golangci-lint",
|
"github.com/golangci/golangci-lint/cmd/golangci-lint",
|
||||||
"github.com/go-testfixtures/testfixtures",
|
"github.com/go-testfixtures/testfixtures",
|
||||||
"github.com/PuerkitoBio/goquery",
|
"github.com/PuerkitoBio/goquery",
|
||||||
"happy-dom",
|
"happy-dom",
|
||||||
"markdownlint-cli",
|
"markdownlint-cli",
|
||||||
"updates",
|
"updates",
|
||||||
"vite-string-plugin",
|
"vite-string-plugin",
|
||||||
"@vue/test-utils"
|
"@vue/test-utils"
|
||||||
],
|
],
|
||||||
"matchPackagePrefixes": [
|
"matchPackagePrefixes": [
|
||||||
"@eslint-community/",
|
"@eslint-community/",
|
||||||
"@playwright/",
|
"@playwright/",
|
||||||
"@stoplight/spectral-cli",
|
"@stoplight/spectral-cli",
|
||||||
"@stylistic/",
|
"@stylistic/",
|
||||||
"ghcr.io/devcontainers/features/",
|
"ghcr.io/devcontainers/features/",
|
||||||
"ghcr.io/devcontainers-contrib/features/",
|
"ghcr.io/devcontainers-contrib/features/",
|
||||||
"mcr.microsoft.com/devcontainers/"
|
"mcr.microsoft.com/devcontainers/"
|
||||||
],
|
],
|
||||||
"automerge": true
|
"automerge": true
|
||||||
},
|
},
|
||||||
|
@ -126,7 +143,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "disallow `eslint-plugin-no-use-extend-native` v0.6.0+, requires eslint v9",
|
"description": "disallow `eslint-plugin-no-use-extend-native` v0.6.0+, requires eslint v9",
|
||||||
"matchDepNames":["eslint-plugin-no-use-extend-native"],
|
"matchDepNames": ["eslint-plugin-no-use-extend-native"],
|
||||||
"allowedVersions": "<0.6.0"
|
"allowedVersions": "<0.6.0"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -502,11 +503,11 @@ func AuthorizeOAuth(ctx *context.Context) {
|
||||||
ctx.Data["Scope"] = form.Scope
|
ctx.Data["Scope"] = form.Scope
|
||||||
ctx.Data["Nonce"] = form.Nonce
|
ctx.Data["Nonce"] = form.Nonce
|
||||||
if user != nil {
|
if user != nil {
|
||||||
ctx.Data["ApplicationCreatorLinkHTML"] = fmt.Sprintf(`<a href="%s">@%s</a>`, html.EscapeString(user.HomeLink()), html.EscapeString(user.Name))
|
ctx.Data["ApplicationCreatorLinkHTML"] = template.HTML(fmt.Sprintf(`<a href="%s">@%s</a>`, html.EscapeString(user.HomeLink()), html.EscapeString(user.Name)))
|
||||||
} else {
|
} else {
|
||||||
ctx.Data["ApplicationCreatorLinkHTML"] = fmt.Sprintf(`<a href="%s">%s</a>`, html.EscapeString(setting.AppSubURL+"/"), html.EscapeString(setting.AppName))
|
ctx.Data["ApplicationCreatorLinkHTML"] = template.HTML(fmt.Sprintf(`<a href="%s">%s</a>`, html.EscapeString(setting.AppSubURL+"/"), html.EscapeString(setting.AppName)))
|
||||||
}
|
}
|
||||||
ctx.Data["ApplicationRedirectDomainHTML"] = "<strong>" + html.EscapeString(form.RedirectURI) + "</strong>"
|
ctx.Data["ApplicationRedirectDomainHTML"] = template.HTML("<strong>" + html.EscapeString(form.RedirectURI) + "</strong>")
|
||||||
// TODO document SESSION <=> FORM
|
// TODO document SESSION <=> FORM
|
||||||
err = ctx.Session.Set("client_id", app.ClientID)
|
err = ctx.Session.Set("client_id", app.ClientID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -107,6 +107,8 @@ func toIssue(ctx context.Context, doer *user_model.User, issue *issues_model.Iss
|
||||||
if issue.PullRequest.HasMerged {
|
if issue.PullRequest.HasMerged {
|
||||||
apiIssue.PullRequest.Merged = issue.PullRequest.MergedUnix.AsTimePtr()
|
apiIssue.PullRequest.Merged = issue.PullRequest.MergedUnix.AsTimePtr()
|
||||||
}
|
}
|
||||||
|
// Add pr's html url
|
||||||
|
apiIssue.PullRequest.HTMLURL = issue.HTMLURL()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if issue.DeadlineUnix != 0 {
|
if issue.DeadlineUnix != 0 {
|
||||||
|
|
|
@ -61,29 +61,31 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u
|
||||||
}
|
}
|
||||||
|
|
||||||
apiPullRequest := &api.PullRequest{
|
apiPullRequest := &api.PullRequest{
|
||||||
ID: pr.ID,
|
ID: pr.ID,
|
||||||
URL: pr.Issue.HTMLURL(),
|
URL: pr.Issue.HTMLURL(),
|
||||||
Index: pr.Index,
|
Index: pr.Index,
|
||||||
Poster: apiIssue.Poster,
|
Poster: apiIssue.Poster,
|
||||||
Title: apiIssue.Title,
|
Title: apiIssue.Title,
|
||||||
Body: apiIssue.Body,
|
Body: apiIssue.Body,
|
||||||
Labels: apiIssue.Labels,
|
Labels: apiIssue.Labels,
|
||||||
Milestone: apiIssue.Milestone,
|
Milestone: apiIssue.Milestone,
|
||||||
Assignee: apiIssue.Assignee,
|
Assignee: apiIssue.Assignee,
|
||||||
Assignees: apiIssue.Assignees,
|
Assignees: apiIssue.Assignees,
|
||||||
State: apiIssue.State,
|
State: apiIssue.State,
|
||||||
IsLocked: apiIssue.IsLocked,
|
Draft: pr.IsWorkInProgress(ctx),
|
||||||
Comments: apiIssue.Comments,
|
IsLocked: apiIssue.IsLocked,
|
||||||
HTMLURL: pr.Issue.HTMLURL(),
|
Comments: apiIssue.Comments,
|
||||||
DiffURL: pr.Issue.DiffURL(),
|
ReviewComments: pr.GetReviewCommentsCount(ctx),
|
||||||
PatchURL: pr.Issue.PatchURL(),
|
HTMLURL: pr.Issue.HTMLURL(),
|
||||||
HasMerged: pr.HasMerged,
|
DiffURL: pr.Issue.DiffURL(),
|
||||||
MergeBase: pr.MergeBase,
|
PatchURL: pr.Issue.PatchURL(),
|
||||||
Mergeable: pr.Mergeable(ctx),
|
HasMerged: pr.HasMerged,
|
||||||
Deadline: apiIssue.Deadline,
|
MergeBase: pr.MergeBase,
|
||||||
Created: pr.Issue.CreatedUnix.AsTimePtr(),
|
Mergeable: pr.Mergeable(ctx),
|
||||||
Updated: pr.Issue.UpdatedUnix.AsTimePtr(),
|
Deadline: apiIssue.Deadline,
|
||||||
PinOrder: apiIssue.PinOrder,
|
Created: pr.Issue.CreatedUnix.AsTimePtr(),
|
||||||
|
Updated: pr.Issue.UpdatedUnix.AsTimePtr(),
|
||||||
|
PinOrder: apiIssue.PinOrder,
|
||||||
|
|
||||||
AllowMaintainerEdit: pr.AllowMaintainerEdit,
|
AllowMaintainerEdit: pr.AllowMaintainerEdit,
|
||||||
|
|
||||||
|
@ -178,6 +180,12 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Outer scope variables to be used in diff calculation
|
||||||
|
var (
|
||||||
|
startCommitID string
|
||||||
|
endCommitID string
|
||||||
|
)
|
||||||
|
|
||||||
if git.IsErrBranchNotExist(err) {
|
if git.IsErrBranchNotExist(err) {
|
||||||
headCommitID, err := headGitRepo.GetRefCommitID(apiPullRequest.Head.Ref)
|
headCommitID, err := headGitRepo.GetRefCommitID(apiPullRequest.Head.Ref)
|
||||||
if err != nil && !git.IsErrNotExist(err) {
|
if err != nil && !git.IsErrNotExist(err) {
|
||||||
|
@ -186,6 +194,7 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
apiPullRequest.Head.Sha = headCommitID
|
apiPullRequest.Head.Sha = headCommitID
|
||||||
|
endCommitID = headCommitID
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
commit, err := headBranch.GetCommit()
|
commit, err := headBranch.GetCommit()
|
||||||
|
@ -196,8 +205,17 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u
|
||||||
if err == nil {
|
if err == nil {
|
||||||
apiPullRequest.Head.Ref = pr.HeadBranch
|
apiPullRequest.Head.Ref = pr.HeadBranch
|
||||||
apiPullRequest.Head.Sha = commit.ID.String()
|
apiPullRequest.Head.Sha = commit.ID.String()
|
||||||
|
endCommitID = commit.ID.String()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculate diff
|
||||||
|
startCommitID = pr.MergeBase
|
||||||
|
|
||||||
|
apiPullRequest.ChangedFiles, apiPullRequest.Additions, apiPullRequest.Deletions, err = gitRepo.GetDiffShortStat(startCommitID, endCommitID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("GetDiffShortStat: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(apiPullRequest.Head.Sha) == 0 && len(apiPullRequest.Head.Ref) != 0 {
|
if len(apiPullRequest.Head.Sha) == 0 && len(apiPullRequest.Head.Ref) != 0 {
|
||||||
|
|
|
@ -53,6 +53,7 @@ func toUser(ctx context.Context, user *user_model.User, signed, authed bool) *ap
|
||||||
FullName: user.FullName,
|
FullName: user.FullName,
|
||||||
Email: user.GetPlaceholderEmail(),
|
Email: user.GetPlaceholderEmail(),
|
||||||
AvatarURL: user.AvatarLink(ctx),
|
AvatarURL: user.AvatarLink(ctx),
|
||||||
|
HTMLURL: user.HTMLURL(),
|
||||||
Created: user.CreatedUnix.AsTime(),
|
Created: user.CreatedUnix.AsTime(),
|
||||||
Restricted: user.IsRestricted,
|
Restricted: user.IsRestricted,
|
||||||
Location: user.Location,
|
Location: user.Location,
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"image"
|
"image"
|
||||||
"image/png"
|
"image/png"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
|
@ -18,30 +19,62 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type alreadyDeletedStorage struct {
|
||||||
|
storage.DiscardStorage
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s alreadyDeletedStorage) Delete(_ string) error {
|
||||||
|
return os.ErrNotExist
|
||||||
|
}
|
||||||
|
|
||||||
func TestUserDeleteAvatar(t *testing.T) {
|
func TestUserDeleteAvatar(t *testing.T) {
|
||||||
myImage := image.NewRGBA(image.Rect(0, 0, 1, 1))
|
myImage := image.NewRGBA(image.Rect(0, 0, 1, 1))
|
||||||
var buff bytes.Buffer
|
var buff bytes.Buffer
|
||||||
png.Encode(&buff, myImage)
|
png.Encode(&buff, myImage)
|
||||||
|
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
||||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
|
||||||
|
|
||||||
err := UploadAvatar(db.DefaultContext, user, buff.Bytes())
|
|
||||||
assert.NoError(t, err)
|
|
||||||
verification := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
|
||||||
assert.NotEqual(t, "", verification.Avatar)
|
|
||||||
|
|
||||||
t.Run("AtomicStorageFailure", func(t *testing.T) {
|
t.Run("AtomicStorageFailure", func(t *testing.T) {
|
||||||
defer test.MockVariableValue[storage.ObjectStorage](&storage.Avatars, storage.UninitializedStorage)()
|
defer test.MockProtect[storage.ObjectStorage](&storage.Avatars)()
|
||||||
|
|
||||||
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||||
|
|
||||||
|
err := UploadAvatar(db.DefaultContext, user, buff.Bytes())
|
||||||
|
assert.NoError(t, err)
|
||||||
|
verification := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||||
|
assert.NotEqual(t, "", verification.Avatar)
|
||||||
|
|
||||||
|
// fail to delete ...
|
||||||
|
storage.Avatars = storage.UninitializedStorage
|
||||||
err = DeleteAvatar(db.DefaultContext, user)
|
err = DeleteAvatar(db.DefaultContext, user)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
verification := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
|
||||||
|
// ... the avatar is not removed from the database
|
||||||
|
verification = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||||
assert.True(t, verification.UseCustomAvatar)
|
assert.True(t, verification.UseCustomAvatar)
|
||||||
|
|
||||||
|
// already deleted ...
|
||||||
|
storage.Avatars = alreadyDeletedStorage{}
|
||||||
|
err = DeleteAvatar(db.DefaultContext, user)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
// ... the avatar is removed from the database
|
||||||
|
verification = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||||
|
assert.Equal(t, "", verification.Avatar)
|
||||||
})
|
})
|
||||||
|
|
||||||
err = DeleteAvatar(db.DefaultContext, user)
|
t.Run("Success", func(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||||
|
|
||||||
verification = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
err := UploadAvatar(db.DefaultContext, user, buff.Bytes())
|
||||||
assert.Equal(t, "", verification.Avatar)
|
assert.NoError(t, err)
|
||||||
|
verification := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||||
|
assert.NotEqual(t, "", verification.Avatar)
|
||||||
|
|
||||||
|
err = DeleteAvatar(db.DefaultContext, user)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
verification = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||||
|
assert.Equal(t, "", verification.Avatar)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/json"
|
"code.gitea.io/gitea/modules/json"
|
||||||
webhook_module "code.gitea.io/gitea/modules/webhook"
|
webhook_module "code.gitea.io/gitea/modules/webhook"
|
||||||
|
|
||||||
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -222,3 +223,38 @@ func TestForgejoPayload(t *testing.T) {
|
||||||
assert.Equal(t, "refs/heads/test", body.Ref) // full ref
|
assert.Equal(t, "refs/heads/test", body.Ref) // full ref
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOpenProjectPayload(t *testing.T) {
|
||||||
|
t.Run("PullRequest", func(t *testing.T) {
|
||||||
|
p := pullRequestTestPayload()
|
||||||
|
data, err := p.JSONPayload()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// adapted from https://github.com/opf/openproject/blob/4c5c45fe995da0060902bc8dd5f1bf704d0b8737/modules/github_integration/lib/open_project/github_integration/services/upsert_pull_request.rb#L56
|
||||||
|
j := jsoniter.Get(data, "pull_request")
|
||||||
|
|
||||||
|
assert.Equal(t, 12, j.Get("id").MustBeValid().ToInt())
|
||||||
|
assert.Equal(t, "user1", j.Get("user", "login").MustBeValid().ToString())
|
||||||
|
assert.Equal(t, 12, j.Get("number").MustBeValid().ToInt())
|
||||||
|
assert.Equal(t, "http://localhost:3000/test/repo/pulls/12", j.Get("html_url").MustBeValid().ToString())
|
||||||
|
assert.Equal(t, jsoniter.NilValue, j.Get("updated_at").ValueType())
|
||||||
|
assert.Equal(t, "", j.Get("state").MustBeValid().ToString())
|
||||||
|
assert.Equal(t, "Fix bug", j.Get("title").MustBeValid().ToString())
|
||||||
|
assert.Equal(t, "fixes bug #2", j.Get("body").MustBeValid().ToString())
|
||||||
|
|
||||||
|
assert.Equal(t, "test/repo", j.Get("base", "repo", "full_name").MustBeValid().ToString())
|
||||||
|
assert.Equal(t, "http://localhost:3000/test/repo", j.Get("base", "repo", "html_url").MustBeValid().ToString())
|
||||||
|
|
||||||
|
assert.Equal(t, false, j.Get("draft").MustBeValid().ToBool())
|
||||||
|
assert.Equal(t, jsoniter.NilValue, j.Get("merge_commit_sha").ValueType())
|
||||||
|
assert.Equal(t, false, j.Get("merged").MustBeValid().ToBool())
|
||||||
|
assert.Equal(t, jsoniter.NilValue, j.Get("merged_by").ValueType())
|
||||||
|
assert.Equal(t, jsoniter.NilValue, j.Get("merged_at").ValueType())
|
||||||
|
assert.Equal(t, 0, j.Get("comments").MustBeValid().ToInt())
|
||||||
|
assert.Equal(t, 0, j.Get("review_comments").MustBeValid().ToInt())
|
||||||
|
assert.Equal(t, 0, j.Get("additions").MustBeValid().ToInt())
|
||||||
|
assert.Equal(t, 0, j.Get("deletions").MustBeValid().ToInt())
|
||||||
|
assert.Equal(t, 0, j.Get("changed_files").MustBeValid().ToInt())
|
||||||
|
// assert.Equal(t,"labels:", j.Get("labels").map { |values| extract_label_values(values) )
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -281,6 +281,17 @@ func pullRequestTestPayload() *api.PullRequestPayload {
|
||||||
Title: "Milestone Title",
|
Title: "Milestone Title",
|
||||||
Description: "Milestone Description",
|
Description: "Milestone Description",
|
||||||
},
|
},
|
||||||
|
Base: &api.PRBranchInfo{
|
||||||
|
Name: "branch1",
|
||||||
|
Ref: "refs/pull/2/head",
|
||||||
|
Sha: "4a357436d925b5c974181ff12a994538ddc5a269",
|
||||||
|
RepoID: 1,
|
||||||
|
Repository: &api.Repository{
|
||||||
|
HTMLURL: "http://localhost:3000/test/repo",
|
||||||
|
Name: "repo",
|
||||||
|
FullName: "test/repo",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Review: &api.ReviewPayload{
|
Review: &api.ReviewPayload{
|
||||||
Content: "good job",
|
Content: "good job",
|
||||||
|
|
34
templates/swagger/v1_json.tmpl
generated
34
templates/swagger/v1_json.tmpl
generated
|
@ -23413,6 +23413,11 @@
|
||||||
"description": "PullRequest represents a pull request",
|
"description": "PullRequest represents a pull request",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"additions": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"x-go-name": "Additions"
|
||||||
|
},
|
||||||
"allow_maintainer_edit": {
|
"allow_maintainer_edit": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"x-go-name": "AllowMaintainerEdit"
|
"x-go-name": "AllowMaintainerEdit"
|
||||||
|
@ -23434,6 +23439,11 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Body"
|
"x-go-name": "Body"
|
||||||
},
|
},
|
||||||
|
"changed_files": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"x-go-name": "ChangedFiles"
|
||||||
|
},
|
||||||
"closed_at": {
|
"closed_at": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
|
@ -23449,10 +23459,19 @@
|
||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
"x-go-name": "Created"
|
"x-go-name": "Created"
|
||||||
},
|
},
|
||||||
|
"deletions": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"x-go-name": "Deletions"
|
||||||
|
},
|
||||||
"diff_url": {
|
"diff_url": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "DiffURL"
|
"x-go-name": "DiffURL"
|
||||||
},
|
},
|
||||||
|
"draft": {
|
||||||
|
"type": "boolean",
|
||||||
|
"x-go-name": "Draft"
|
||||||
|
},
|
||||||
"due_date": {
|
"due_date": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
|
@ -23529,6 +23548,12 @@
|
||||||
},
|
},
|
||||||
"x-go-name": "RequestedReviewers"
|
"x-go-name": "RequestedReviewers"
|
||||||
},
|
},
|
||||||
|
"review_comments": {
|
||||||
|
"description": "number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)",
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"x-go-name": "ReviewComments"
|
||||||
|
},
|
||||||
"state": {
|
"state": {
|
||||||
"$ref": "#/definitions/StateType"
|
"$ref": "#/definitions/StateType"
|
||||||
},
|
},
|
||||||
|
@ -23559,6 +23584,10 @@
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"x-go-name": "IsWorkInProgress"
|
"x-go-name": "IsWorkInProgress"
|
||||||
},
|
},
|
||||||
|
"html_url": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "HTMLURL"
|
||||||
|
},
|
||||||
"merged": {
|
"merged": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"x-go-name": "HasMerged"
|
"x-go-name": "HasMerged"
|
||||||
|
@ -24904,6 +24933,11 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "FullName"
|
"x-go-name": "FullName"
|
||||||
},
|
},
|
||||||
|
"html_url": {
|
||||||
|
"description": "URL to the user's gitea page",
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "HTMLURL"
|
||||||
|
},
|
||||||
"id": {
|
"id": {
|
||||||
"description": "the user's id",
|
"description": "the user's id",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
|
|
@ -608,3 +608,24 @@ func TestSignUpViaOAuthWithMissingFields(t *testing.T) {
|
||||||
resp := MakeRequest(t, req, http.StatusSeeOther)
|
resp := MakeRequest(t, req, http.StatusSeeOther)
|
||||||
assert.Equal(t, test.RedirectURL(resp), "/user/link_account")
|
assert.Equal(t, test.RedirectURL(resp), "/user/link_account")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOAuth_GrantApplicationOAuth(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", "/login/oauth/authorize?client_id=da7da3ba-9a13-4167-856f-3899de0b0138&redirect_uri=a&response_type=code&state=thestate")
|
||||||
|
ctx := loginUser(t, "user4")
|
||||||
|
resp := ctx.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
htmlDoc.AssertElement(t, "#authorize-app", true)
|
||||||
|
|
||||||
|
req = NewRequestWithValues(t, "POST", "/login/oauth/grant", map[string]string{
|
||||||
|
"_csrf": htmlDoc.GetCSRF(),
|
||||||
|
"client_id": "da7da3ba-9a13-4167-856f-3899de0b0138",
|
||||||
|
"redirect_uri": "a",
|
||||||
|
"state": "thestate",
|
||||||
|
"granted": "false",
|
||||||
|
})
|
||||||
|
resp = ctx.MakeRequest(t, req, http.StatusSeeOther)
|
||||||
|
assert.Contains(t, test.RedirectURL(resp), "error=access_denied&error_description=the+request+is+denied")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue