Skip to content

Commit

Permalink
Merge branch 'main' into highlight-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lafriks authored May 13, 2021
2 parents 8b21e09 + 6d2a333 commit ae5616b
Show file tree
Hide file tree
Showing 72 changed files with 577 additions and 194 deletions.
8 changes: 5 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ steps:
settings:
author_email: "[email protected]"
author_name: GiteaBot
branch: main
commit: true
commit_message: "[skip ci] Updated translations via Crowdin"
remote: "[email protected]:go-gitea/gitea.git"
Expand Down Expand Up @@ -461,6 +462,7 @@ steps:
settings:
author_email: "[email protected]"
author_name: GiteaBot
branch: main
commit: true
commit_message: "[skip ci] Updated licenses and gitignores "
remote: "[email protected]:go-gitea/gitea.git"
Expand Down Expand Up @@ -528,7 +530,7 @@ steps:
image: plugins/s3:1
settings:
acl: public-read
bucket: releases
bucket: gitea-artifacts
endpoint: https://storage.gitea.io
path_style: true
source: "dist/release/*"
Expand All @@ -549,7 +551,7 @@ steps:
image: plugins/s3:1
settings:
acl: public-read
bucket: releases
bucket: gitea-artifacts
endpoint: https://storage.gitea.io
path_style: true
source: "dist/release/*"
Expand Down Expand Up @@ -624,7 +626,7 @@ steps:
image: plugins/s3:1
settings:
acl: public-read
bucket: releases
bucket: gitea-artifacts
endpoint: https://storage.gitea.io
path_style: true
source: "dist/release/*"
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ NOTES:
1. **YOU MUST READ THE [CONTRIBUTORS GUIDE](CONTRIBUTING.md) BEFORE STARTING TO WORK ON A PULL REQUEST.**
2. If you have found a vulnerability in the project, please write privately to **[email protected]**. Thanks!

## Translating

Translations are done through Crowdin. If you want to translate to a new language ask one of the managers in the Crowdin project to add a new language there.

You can also just create an issue for adding a language or ask on discord on the #translation channel. If you need context or find some translation issues, you can leave a comment on the string or ask on Discord. For general translation questions there is a section in the docs. Currently a bit empty but we hope fo fill it as questions pop up.

https://docs.gitea.io/en-us/translation-guidelines/

[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea)

## Further information

For more information and instructions about how to install Gitea, please look at our [documentation](https://docs.gitea.io/en-us/).
Expand Down
5 changes: 5 additions & 0 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ Gitea 的首要目标是创建一个极易安装,运行非常快速,安装

Fork -> Patch -> Push -> Pull Request

## 翻译

多语言翻译是基于Crowdin进行的.
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea)

## 作者

* [Maintainers](https://github.com/orgs/go-gitea/people)
Expand Down
77 changes: 11 additions & 66 deletions cmd/restore_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
package cmd

import (
"context"
"strings"
"errors"
"net/http"

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/migrations"
"code.gitea.io/gitea/modules/migrations/base"
"code.gitea.io/gitea/modules/private"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/storage"
pull_service "code.gitea.io/gitea/services/pull"

"github.com/urfave/cli"
)
Expand Down Expand Up @@ -50,70 +47,18 @@ wiki, issues, labels, releases, release_assets, milestones, pull_requests, comme
}

func runRestoreRepository(ctx *cli.Context) error {
if err := initDB(); err != nil {
return err
}

log.Trace("AppPath: %s", setting.AppPath)
log.Trace("AppWorkPath: %s", setting.AppWorkPath)
log.Trace("Custom path: %s", setting.CustomPath)
log.Trace("Log path: %s", setting.LogRootPath)
setting.InitDBConfig()

if err := storage.Init(); err != nil {
return err
}

if err := pull_service.Init(); err != nil {
return err
}

var opts = base.MigrateOptions{
RepoName: ctx.String("repo_name"),
}

if len(ctx.String("units")) == 0 {
opts.Wiki = true
opts.Issues = true
opts.Milestones = true
opts.Labels = true
opts.Releases = true
opts.Comments = true
opts.PullRequests = true
opts.ReleaseAssets = true
} else {
units := strings.Split(ctx.String("units"), ",")
for _, unit := range units {
switch strings.ToLower(unit) {
case "wiki":
opts.Wiki = true
case "issues":
opts.Issues = true
case "milestones":
opts.Milestones = true
case "labels":
opts.Labels = true
case "releases":
opts.Releases = true
case "release_assets":
opts.ReleaseAssets = true
case "comments":
opts.Comments = true
case "pull_requests":
opts.PullRequests = true
}
}
}
setting.NewContext()

if err := migrations.RestoreRepository(
context.Background(),
statusCode, errStr := private.RestoreRepo(
ctx.String("repo_dir"),
ctx.String("owner_name"),
ctx.String("repo_name"),
); err != nil {
log.Fatal("Failed to restore repository: %v", err)
return err
ctx.StringSlice("units"),
)
if statusCode == http.StatusOK {
return nil
}

return nil
log.Fatal("Failed to restore repository: %v", errStr)
return errors.New(errStr)
}
8 changes: 8 additions & 0 deletions cmd/web_letsencrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package cmd

import (
"net/http"
"strconv"
"strings"

"code.gitea.io/gitea/modules/log"
Expand All @@ -22,6 +23,11 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
// TODO: these are placeholders until we add options for each in settings with appropriate warning
enableHTTPChallenge := true
enableTLSALPNChallenge := true
altHTTPPort := 0

if p, err := strconv.Atoi(setting.PortToRedirect); err == nil {
altHTTPPort = p
}

magic := certmagic.NewDefault()
magic.Storage = &certmagic.FileStorage{Path: directory}
Expand All @@ -30,6 +36,8 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
Agreed: setting.LetsEncryptTOS,
DisableHTTPChallenge: !enableHTTPChallenge,
DisableTLSALPNChallenge: !enableTLSALPNChallenge,
ListenHost: listenAddr,
AltHTTPPort: altHTTPPort,
})

magic.Issuers = []certmagic.Issuer{myACME}
Expand Down
15 changes: 14 additions & 1 deletion custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,15 @@ PATH =
;; - approved: only sign when merging an approved pr to a protected branch
;MERGES = pubkey, twofa, basesigned, commitssigned

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[repository.mimetype_mapping]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Custom MIME type mapping for downloadable files
;.apk=application/vnd.android.package-archive

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[project]
Expand All @@ -912,7 +921,6 @@ PATH =
;PROJECT_BOARD_BASIC_KANBAN_TYPE = To Do, In Progress, Done
;PROJECT_BOARD_BUG_TRIAGE_TYPE = Needs Triage, High Priority, Low Priority, Closed


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[cors]
Expand Down Expand Up @@ -1591,6 +1599,11 @@ PATH =
;ENABLED = false
;; Setting this to true will run all enabled cron tasks when Gitea starts.
;RUN_AT_START = false
;;
;; Note: ``SCHEDULE`` accept formats
;; - Full crontab specs, e.g. "* * * * * ?"
;; - Descriptors, e.g. "@midnight", "@every 1h30m"
;; See more: https://pkg.go.dev/github.com/gogs/[email protected]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Basic cron tasks - enabled by default
Expand Down
14 changes: 14 additions & 0 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.

- `LOCAL_COPY_PATH`: **tmp/local-repo**: Path for temporary local repository copies. Defaults to `tmp/local-repo`

## Repository - MIME type mapping (`repository.mimetype_mapping`)

Configuration for set the expected MIME type based on file extensions of downloadable files. Configuration presents in key-value pairs and file extensions starts with leading `.`.

The following configuration set `Content-Type: application/vnd.android.package-archive` header when downloading files with `.apk` file extension.
```ini
.apk=application/vnd.android.package-archive
```

## CORS (`cors`)

- `ENABLED`: **false**: enable cors headers (disabled by default)
Expand Down Expand Up @@ -704,6 +713,11 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
- `RUN_AT_START`: **false**: Run cron tasks at application start-up.
- `NO_SUCCESS_NOTICE`: **false**: Set to true to switch off success notices.

- `SCHEDULE` accept formats
- Full crontab specs, e.g. `* * * * * ?`
- Descriptors, e.g. `@midnight`, `@every 1h30m` ...
- See more: [cron decument](https://pkg.go.dev/github.com/gogs/[email protected])

### Basic cron tasks - enabled by default

#### Cron - Cleanup old repository archives (`cron.archive_cleanup`)
Expand Down
5 changes: 5 additions & 0 deletions docs/content/doc/advanced/config-cheat-sheet.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ test01.xls: application/vnd.ms-excel; charset=binary

- `ENABLED`: 是否在后台运行定期任务。
- `RUN_AT_START`: 是否启动时自动运行。
- `SCHEDULE` 所接受的格式
- 完整 crontab 控制, 例如 `* * * * * ?`
- 描述符, 例如 `@midnight`, `@every 1h30m` ...
- 更多细节参见 [cron api文档](https://pkg.go.dev/github.com/gogs/[email protected])


### Cron - Update Mirrors (`cron.update_mirrors`)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ require (
github.com/unknwon/com v1.0.1
github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae
github.com/unrolled/render v1.1.0
github.com/unrolled/render v1.1.1
github.com/urfave/cli v1.22.5
github.com/willf/bitset v1.1.11 // indirect
github.com/xanzy/go-gitlab v0.48.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1099,8 +1099,8 @@ github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44 h1:7bSo/vjZKVYUoZfxpY
github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ=
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae h1:ihaXiJkaca54IaCSnEXtE/uSZOmPxKZhDfVLrzZLFDs=
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae/go.mod h1:1fdkY6xxl6ExVs2QFv7R0F5IRZHKA8RahhB9fMC9RvM=
github.com/unrolled/render v1.1.0 h1:gvpR9hHxTt6DcGqRYuVVFcfd8rtK+nyEPUJN06KB57Q=
github.com/unrolled/render v1.1.0/go.mod h1:gN9T0NhL4Bfbwu8ann7Ry/TGHYfosul+J0obPf6NBdM=
github.com/unrolled/render v1.1.1 h1:FpzNzkvlJQIlVdVaqeVBGWiCS8gpbmjtrKpDmCn6p64=
github.com/unrolled/render v1.1.1/go.mod h1:gN9T0NhL4Bfbwu8ann7Ry/TGHYfosul+J0obPf6NBdM=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
Expand Down
4 changes: 3 additions & 1 deletion models/avatar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ func TestHashEmail(t *testing.T) {
}

func TestSizedAvatarLink(t *testing.T) {
setting.AppSubURL = "/testsuburl"

disableGravatar()
assert.Equal(t, "/suburl/assets/img/avatar_default.png",
assert.Equal(t, "/testsuburl/assets/img/avatar_default.png",
SizedAvatarLink("[email protected]", 100))

enableGravatar(t)
Expand Down
23 changes: 17 additions & 6 deletions models/gpg_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ MkM/fdpyc2hY7Dl/+qFmN5MG5yGmMpQcX+RNNR222ibNC1D3wg==
=i9b7
-----END PGP PUBLIC KEY BLOCK-----`
keys, err := checkArmoredGPGKeyString(testGPGArmor)
if !assert.NotEmpty(t, keys) {
return
}
ekey := keys[0]
assert.NoError(t, err, "Could not parse a valid GPG armored key", ekey)

Expand Down Expand Up @@ -189,6 +192,10 @@ Unknown GPG key with good email
}

func TestCheckGPGUserEmail(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())

_ = AssertExistsAndLoadBean(t, &User{ID: 1}).(*User)

testEmailWithUpperCaseLetters := `-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
Expand Down Expand Up @@ -222,9 +229,11 @@ Q0KHb+QcycSgbDx0ZAvdIacuKvBBcbxrsmFUI4LR+oIup0G9gUc0roPvr014jYQL

keys, err := AddGPGKey(1, testEmailWithUpperCaseLetters)
assert.NoError(t, err)
key := keys[0]
if assert.Len(t, key.Emails, 1) {
assert.Equal(t, "[email protected]", key.Emails[0].Email)
if assert.NotEmpty(t, keys) {
key := keys[0]
if assert.Len(t, key.Emails, 1) {
assert.Equal(t, "[email protected]", key.Emails[0].Email)
}
}
}

Expand Down Expand Up @@ -374,7 +383,9 @@ epiDVQ==
`
keys, err := checkArmoredGPGKeyString(testIssue6599)
assert.NoError(t, err)
ekey := keys[0]
expire := getExpiryTime(ekey)
assert.Equal(t, time.Unix(1586105389, 0), expire)
if assert.NotEmpty(t, keys) {
ekey := keys[0]
expire := getExpiryTime(ekey)
assert.Equal(t, time.Unix(1586105389, 0), expire)
}
}
5 changes: 5 additions & 0 deletions models/issue_assignees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ func TestUpdateAssignee(t *testing.T) {
}

func TestMakeIDsFromAPIAssigneesToAdd(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())

_ = AssertExistsAndLoadBean(t, &User{ID: 1}).(*User)
_ = AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)

IDs, err := MakeIDsFromAPIAssigneesToAdd("", []string{""})
assert.NoError(t, err)
assert.Equal(t, []int64{}, IDs)
Expand Down
3 changes: 3 additions & 0 deletions models/issue_xref.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ func CommentTypeIsRef(t CommentType) bool {

// RefCommentHTMLURL returns the HTML URL for the comment that created this reference
func (comment *Comment) RefCommentHTMLURL() string {
if comment.RefCommentID == 0 {
return ""
}
if err := comment.LoadRefComment(); err != nil { // Silently dropping errors :unamused:
log.Error("LoadRefComment(%d): %v", comment.RefCommentID, err)
return ""
Expand Down
Loading

0 comments on commit ae5616b

Please sign in to comment.