Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/issue_23440
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Mar 15, 2023
2 parents 66f84ee + 202803f commit 1e7af8d
Show file tree
Hide file tree
Showing 136 changed files with 9,938 additions and 8,962 deletions.
107 changes: 40 additions & 67 deletions .drone.yml

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions .stylelintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ ignoreFiles:
- "**/*.go"

overrides:
- files: ["**/*.less"]
customSyntax: postcss-less
- files: ["**/chroma/*", "**/codemirror/*", "**/standalone/*", "**/console/*"]
rules:
scale-unlimited/declaration-strict-value: null
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ AIR_PACKAGE ?= github.com/cosmtrek/air@v1.40.4
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.6.0
ERRCHECK_PACKAGE ?= github.com/kisielk/errcheck@v1.6.2
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.4.0
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.10
MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.4
Expand Down Expand Up @@ -105,7 +105,7 @@ GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/m

FOMANTIC_WORK_DIR := web_src/fomantic

WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
WEBPACK_CONFIGS := webpack.config.js
WEBPACK_DEST := public/js/index.js public/css/index.css
WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack public/serviceworker.js
Expand All @@ -131,7 +131,7 @@ TEST_TAGS ?= sqlite sqlite_unlock_notify
TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMANTIC_WORK_DIR)/node_modules $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR) $(GO_LICENSE_TMP_DIR)

GO_DIRS := cmd tests models modules routers build services tools
WEB_DIRS := web_src/js web_src/less
WEB_DIRS := web_src/js web_src/css

GO_SOURCES := $(wildcard *.go)
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" -not -path modules/options/bindata.go -not -path modules/public/bindata.go -not -path modules/templates/bindata.go)
Expand Down Expand Up @@ -342,7 +342,7 @@ lint: lint-frontend lint-backend
.PHONY: lint-frontend
lint-frontend: node_modules
npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js docs/assets/js tests/e2e
npx stylelint --color --max-warnings=0 web_src/less
npx stylelint --color --max-warnings=0 web_src/css
npx spectral lint -q -F hint $(SWAGGER_SPEC)
npx markdownlint docs *.md

Expand Down
2 changes: 1 addition & 1 deletion custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
;; - The environment variable `$GITEA_WORK_DIR`
;; - A built-in value set at build time (see building from source)
;; - Otherwise it defaults to the directory of the _`AppPath`_
;; - If any of the above are relative paths then they are made absolute against the
;; - If any of the above are relative paths then they are made absolute against
;; the directory of the _`AppPath`_
;; - _`CustomPath`_: This is the base directory for custom templates and other options.
;; It is determined by using the first set thing in the following hierarchy:
Expand Down
2 changes: 1 addition & 1 deletion docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ reported as part of the default configuration when running `gitea --help` or on
- The environment variable `$GITEA_WORK_DIR`
- A built-in value set at build time (see building from source)
- Otherwise it defaults to the directory of the _`AppPath`_
- If any of the above are relative paths then they are made absolute against the
- If any of the above are relative paths then they are made absolute against
the directory of the _`AppPath`_
- _`CustomPath`_: This is the base directory for custom templates and other options.
It is determined by using the first set thing in the following hierarchy:
Expand Down
2 changes: 1 addition & 1 deletion docs/content/doc/advanced/customizing-gitea.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ To make a custom theme available to all users:

Community themes are listed in [gitea/awesome-gitea#themes](https://gitea.com/gitea/awesome-gitea#themes).

The `arc-green` theme source can be found [here](https://github.com/go-gitea/gitea/blob/main/web_src/less/themes/theme-arc-green.less).
The `arc-green` theme source can be found [here](https://github.com/go-gitea/gitea/blob/main/web_src/css/themes/theme-arc-green.css).

If your custom theme is considered a dark theme, set the global css variable `--is-dark-theme` to `true`.
This allows Gitea to adjust the Monaco code editor's theme accordingly.
Expand Down
4 changes: 2 additions & 2 deletions docs/content/doc/developers/guidelines-frontend.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ menu:

## Background

Gitea uses [Less CSS](https://lesscss.org), [Fomantic-UI](https://fomantic-ui.com/introduction/getting-started.html) (based on [jQuery](https://api.jquery.com)) and [Vue3](https://vuejs.org/) for its frontend.
Gitea uses [Fomantic-UI](https://fomantic-ui.com/introduction/getting-started.html) (based on [jQuery](https://api.jquery.com)) and [Vue3](https://vuejs.org/) for its frontend.

The HTML pages are rendered by [Go HTML Template](https://pkg.go.dev/html/template).

The source files can be found in the following directories:

* **Less styles:** `web_src/less/`
* **CSS styles:** `web_src/css/`
* **JavaScript files:** `web_src/js/`
* **Vue components:** `web_src/js/components/`
* **Go HTML templates:** `templates/`
Expand Down
2 changes: 2 additions & 0 deletions docs/content/doc/features/localization.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ menu:
---

# 本地化

Gitea的本地化是通过我们的[Crowdin项目](https://crowdin.com/project/gitea)进行的。

对于对**英语翻译**的更改,可以发出pull-request,来更改[英语语言环境](https://github.com/go-gitea/gitea/blob/master/options/locale/locale_en-US.ini)中合适的关键字。

有关对**非英语**翻译的更改,请参阅上面的 Crowdin 项目。

## 支持的语言

上述 Crowdin 项目中列出的任何语言一旦翻译了 25% 或更多都将得到支持。

翻译被接受后,它将在下一次 Crowdin 同步后反映在主存储库中,这通常是在任何 PR 合并之后。
Expand Down
2 changes: 1 addition & 1 deletion docs/content/doc/usage/push-options.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ were added.
Example of changing a repository's visibility to public:

```shell
git push -o repo.private=false -u origin master
git push -o repo.private=false -u origin main
```
2 changes: 1 addition & 1 deletion docs/content/doc/usage/push-options.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ Gitea 從 `1.13` 版開始支援某些 [push options](https://git-scm.com/docs/g
以下範例修改儲存庫的可見性為公開:

```shell
git push -o repo.private=false -u origin master
git push -o repo.private=false -u origin main
```
40 changes: 40 additions & 0 deletions docs/content/doc/usage/push-to-create.en-us.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
date: "2020-07-06T16:00:00+02:00"
title: "Usage: Push To Create"
slug: "push-to-create"
weight: 15
toc: false
draft: false
menu:
sidebar:
parent: "usage"
name: "Push To Create"
weight: 15
identifier: "push-to-create"
---

# Push To Create

Push to create is a feature that allows you to push to a repository that does not exist yet in Gitea. This is useful for automation and for allowing users to create repositories without having to go through the web interface. This feature is disabled by default.

## Enabling Push To Create

In the `app.ini` file, set `ENABLE_PUSH_CREATE_USER` to `true` and `ENABLE_PUSH_CREATE_ORG` to `true` if you want to allow users to create repositories in their own user account and in organizations they are a member of respectively. Restart Gitea for the changes to take effect. You can read more about these two options in the [Configuration Cheat Sheet]({{< relref "doc/advanced/config-cheat-sheet.en-us.md#repository-repository" >}}).

## Using Push To Create

Assuming you have a git repository in the current directory, you can push to a repository that does not exist yet in Gitea by running the following command:

```shell
# Add the remote you want to push to
git remote add origin git@{domain}:{username}/{repo name that does not exist yet}.git

# push to the remote
git push -u origin main
```

This assumes you are using an SSH remote, but you can also use HTTPS remotes as well.

## Push options (bonus)

Push-to-create will default to the visibility defined by `DEFAULT_PUSH_CREATE_PRIVATE` in `app.ini`. To explicitly set the visibility, you can use a [push option]({{< relref "doc/usage/push-options.en-us.md" >}}).
4 changes: 2 additions & 2 deletions models/issues/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,10 @@ func GetPullRequestByIssueID(ctx context.Context, issueID int64) (*PullRequest,

// GetAllUnmergedAgitPullRequestByPoster get all unmerged agit flow pull request
// By poster id.
func GetAllUnmergedAgitPullRequestByPoster(uid int64) ([]*PullRequest, error) {
func GetAllUnmergedAgitPullRequestByPoster(ctx context.Context, uid int64) ([]*PullRequest, error) {
pulls := make([]*PullRequest, 0, 10)

err := db.GetEngine(db.DefaultContext).
err := db.GetEngine(ctx).
Where("has_merged=? AND flow = ? AND issue.is_closed=? AND issue.poster_id=?",
false, PullRequestFlowAGit, false, uid).
Join("INNER", "issue", "issue.id=pull_request.issue_id").
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
org_id: 0
name: label1
color: '#abcdef'
exclusive: false
num_issues: 2
num_closed_issues: 0

Expand All @@ -14,7 +13,6 @@
org_id: 0
name: label2
color: '#000000'
exclusive: false
num_issues: 1
num_closed_issues: 1
-
Expand All @@ -23,7 +21,6 @@
org_id: 3
name: orglabel3
color: '#abcdef'
exclusive: false
num_issues: 0
num_closed_issues: 0

Expand All @@ -33,7 +30,6 @@
org_id: 3
name: orglabel4
color: '#000000'
exclusive: false
num_issues: 1
num_closed_issues: 0

Expand All @@ -43,6 +39,5 @@
org_id: 0
name: pull-test-label
color: '#000000'
exclusive: false
num_issues: 0
num_closed_issues: 0
4 changes: 2 additions & 2 deletions models/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,13 +742,13 @@ func VerifyUserActiveCode(code string) (user *User) {
}

// ChangeUserName changes all corresponding setting from old user name to new one.
func ChangeUserName(u *User, newUserName string) (err error) {
func ChangeUserName(ctx context.Context, u *User, newUserName string) (err error) {
oldUserName := u.Name
if err = IsUsableUsername(newUserName); err != nil {
return err
}

ctx, committer, err := db.TxContext(db.DefaultContext)
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
Expand Down
41 changes: 41 additions & 0 deletions modules/actions/github.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package actions

import (
webhook_module "code.gitea.io/gitea/modules/webhook"

"github.com/nektos/act/pkg/jobparser"
)

const (
githubEventPullRequest = "pull_request"
githubEventPullRequestTarget = "pull_request_target"
githubEventPullRequestReviewComment = "pull_request_review_comment"
githubEventPullRequestReview = "pull_request_review"
githubEventRegistryPackage = "registry_package"
githubEventCreate = "create"
githubEventDelete = "delete"
githubEventFork = "fork"
githubEventPush = "push"
githubEventIssues = "issues"
githubEventIssueComment = "issue_comment"
githubEventRelease = "release"
githubEventPullRequestComment = "pull_request_comment"
)

func convertFromGithubEvent(evt *jobparser.Event) string {
switch evt.Name {
case githubEventPullRequest, githubEventPullRequestTarget, githubEventPullRequestReview,
githubEventPullRequestReviewComment:
return string(webhook_module.HookEventPullRequest)
case githubEventRegistryPackage:
return string(webhook_module.HookEventPackage)
case githubEventCreate, githubEventDelete, githubEventFork, githubEventPush,
githubEventIssues, githubEventIssueComment, githubEventRelease, githubEventPullRequestComment:
fallthrough
default:
return evt.Name
}
}
Loading

0 comments on commit 1e7af8d

Please sign in to comment.