Skip to content

Commit c88a9b8

Browse files
committed
Merge branch 'master' into feature/Pinned_repo
2 parents 73ab596 + 7354efe commit c88a9b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1113
-462
lines changed

docs/content/doc/help/faq.en-us.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ Also see [Support Options]({{< relref "doc/help/seek-help.en-us.md" >}})
4747
* [How can I enable password reset](#how-can-i-enable-password-reset)
4848
* [How can a user's password be changed](#how-can-a-user-s-password-be-changed)
4949
* [Why is my markdown broken](#why-is-my-markdown-broken)
50-
50+
* [Errors during upgrade on MySQL: Error 1118: Row size too large.](#upgrade-errors-with-mysql)
51+
* [Why are emoji broken on MySQL](#why-are-emoji-broken-on-mysql)
5152

5253
## Difference between 1.x and 1.x.x downloads
5354
Version 1.7.x will be used for this example.
@@ -308,3 +309,30 @@ There is no setting for password resets. It is enabled when a [mail service]({{<
308309
In Gitea version `1.11` we moved to [goldmark](https://github.com/yuin/goldmark) for markdown rendering, which is [CommonMark](https://commonmark.org/) compliant.
309310
If you have markdown that worked as you expected prior to version `1.11` and after upgrading it's not working anymore, please look through the CommonMark spec to see whether the problem is due to a bug or non-compliant syntax.
310311
If it is the latter, _usually_ there is a compliant alternative listed in the spec.
312+
313+
## Upgrade errors with MySQL
314+
315+
If you are receiving errors on upgrade of Gitea using MySQL that read:
316+
317+
> `ORM engine initialization failed: migrate: do migrate: Error: 1118: Row size too large...`
318+
319+
Please run `gitea convert` or run `ALTER TABLE table_name ROW_FORMAT=dynamic;` for each table in the database.
320+
321+
The underlying problem is that the space allocated for indices by the default row format
322+
is too small. Gitea requires that the `ROWFORMAT` for its tables is `DYNAMIC`.
323+
324+
If you are receiving an error line containing `Error 1071: Specified key was too long; max key length is 1000 bytes...`
325+
then you are attempting to run Gitea on tables which use the ISAM engine. While this may have worked by chance in previous versions of Gitea, it has never been officially supported and
326+
you must use InnoDB. You should run `ALTER TABLE table_name ENGINE=InnoDB;` for each table in the database.
327+
328+
## Why Are Emoji Broken On MySQL
329+
330+
Unfortunately MySQL's `utf8` charset does not completely allow all possible UTF-8 characters, in particular Emoji.
331+
They created a new charset and collation called `utf8mb4` that allows for emoji to be stored but tables which use
332+
the `utf8` charset, and connections which use the `utf8` charset will not use this.
333+
334+
Please run `gitea convert`, or run `ALTER DATABASE database_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;`
335+
for the database_name and run `ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;`
336+
for each table in the database.
337+
338+
You will also need to change the app.ini database charset to `CHARSET=utf8mb4`.

integrations/repo_migrate_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
package integrations
66

77
import (
8+
"fmt"
89
"net/http"
910
"net/http/httptest"
1011
"testing"
1112

13+
"code.gitea.io/gitea/modules/structs"
1214
"github.com/stretchr/testify/assert"
1315
)
1416

1517
func testRepoMigrate(t testing.TB, session *TestSession, cloneAddr, repoName string) *httptest.ResponseRecorder {
16-
req := NewRequest(t, "GET", "/repo/migrate")
18+
req := NewRequest(t, "GET", fmt.Sprintf("/repo/migrate?service_type=%d", structs.PlainGitService)) // render plain git migration page
1719
resp := session.MakeRequest(t, req, http.StatusOK)
1820
htmlDoc := NewHTMLParser(t, resp.Body)
1921

@@ -28,8 +30,8 @@ func testRepoMigrate(t testing.TB, session *TestSession, cloneAddr, repoName str
2830
"clone_addr": cloneAddr,
2931
"uid": uid,
3032
"repo_name": repoName,
31-
},
32-
)
33+
"service": fmt.Sprintf("%d", structs.PlainGitService),
34+
})
3335
resp = session.MakeRequest(t, req, http.StatusFound)
3436

3537
return resp

models/user.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,11 +1419,21 @@ func getUserEmailsByNames(e Engine, names []string) []string {
14191419
}
14201420

14211421
// GetMaileableUsersByIDs gets users from ids, but only if they can receive mails
1422-
func GetMaileableUsersByIDs(ids []int64) ([]*User, error) {
1422+
func GetMaileableUsersByIDs(ids []int64, isMention bool) ([]*User, error) {
14231423
if len(ids) == 0 {
14241424
return nil, nil
14251425
}
14261426
ous := make([]*User, 0, len(ids))
1427+
1428+
if isMention {
1429+
return ous, x.In("id", ids).
1430+
Where("`type` = ?", UserTypeIndividual).
1431+
And("`prohibit_login` = ?", false).
1432+
And("`is_active` = ?", true).
1433+
And("`email_notifications_preference` IN ( ?, ?)", EmailNotificationsEnabled, EmailNotificationsOnMention).
1434+
Find(&ous)
1435+
}
1436+
14271437
return ous, x.In("id", ids).
14281438
Where("`type` = ?", UserTypeIndividual).
14291439
And("`prohibit_login` = ?", false).

models/user_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,20 @@ func TestGetUserIDsByNames(t *testing.T) {
389389
assert.Error(t, err)
390390
assert.Equal(t, []int64(nil), IDs)
391391
}
392+
393+
func TestGetMaileableUsersByIDs(t *testing.T) {
394+
results, err := GetMaileableUsersByIDs([]int64{1, 4}, false)
395+
assert.NoError(t, err)
396+
assert.Equal(t, 1, len(results))
397+
if len(results) > 1 {
398+
assert.Equal(t, results[0].ID, 1)
399+
}
400+
401+
results, err = GetMaileableUsersByIDs([]int64{1, 4}, true)
402+
assert.NoError(t, err)
403+
assert.Equal(t, 2, len(results))
404+
if len(results) > 2 {
405+
assert.Equal(t, results[0].ID, 1)
406+
assert.Equal(t, results[1].ID, 4)
407+
}
408+
}

modules/migrations/gitlab.go

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (f *GitlabDownloaderFactory) New(ctx context.Context, opts base.MigrateOpti
4747

4848
log.Trace("Create gitlab downloader. BaseURL: %s RepoName: %s", baseURL, repoNameSpace)
4949

50-
return NewGitlabDownloader(ctx, baseURL, repoNameSpace, opts.AuthUsername, opts.AuthPassword, opts.AuthToken), nil
50+
return NewGitlabDownloader(ctx, baseURL, repoNameSpace, opts.AuthUsername, opts.AuthPassword, opts.AuthToken)
5151
}
5252

5353
// GitServiceType returns the type of git service
@@ -73,7 +73,7 @@ type GitlabDownloader struct {
7373
// NewGitlabDownloader creates a gitlab Downloader via gitlab API
7474
// Use either a username/password, personal token entered into the username field, or anonymous/public access
7575
// Note: Public access only allows very basic access
76-
func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) *GitlabDownloader {
76+
func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) (*GitlabDownloader, error) {
7777
var gitlabClient *gitlab.Client
7878
var err error
7979
if token != "" {
@@ -84,27 +84,27 @@ func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, passw
8484

8585
if err != nil {
8686
log.Trace("Error logging into gitlab: %v", err)
87-
return nil
87+
return nil, err
8888
}
8989

9090
// Grab and store project/repo ID here, due to issues using the URL escaped path
9191
gr, _, err := gitlabClient.Projects.GetProject(repoPath, nil, nil, gitlab.WithContext(ctx))
9292
if err != nil {
9393
log.Trace("Error retrieving project: %v", err)
94-
return nil
94+
return nil, err
9595
}
9696

9797
if gr == nil {
9898
log.Trace("Error getting project, project is nil")
99-
return nil
99+
return nil, errors.New("Error getting project, project is nil")
100100
}
101101

102102
return &GitlabDownloader{
103103
ctx: ctx,
104104
client: gitlabClient,
105105
repoID: gr.ID,
106106
repoName: gr.Name,
107-
}
107+
}, nil
108108
}
109109

110110
// SetContext set context
@@ -114,10 +114,6 @@ func (g *GitlabDownloader) SetContext(ctx context.Context) {
114114

115115
// GetRepoInfo returns a repository information
116116
func (g *GitlabDownloader) GetRepoInfo() (*base.Repository, error) {
117-
if g == nil {
118-
return nil, errors.New("error: GitlabDownloader is nil")
119-
}
120-
121117
gr, _, err := g.client.Projects.GetProject(g.repoID, nil, nil, gitlab.WithContext(g.ctx))
122118
if err != nil {
123119
return nil, err
@@ -154,10 +150,6 @@ func (g *GitlabDownloader) GetRepoInfo() (*base.Repository, error) {
154150

155151
// GetTopics return gitlab topics
156152
func (g *GitlabDownloader) GetTopics() ([]string, error) {
157-
if g == nil {
158-
return nil, errors.New("error: GitlabDownloader is nil")
159-
}
160-
161153
gr, _, err := g.client.Projects.GetProject(g.repoID, nil, nil, gitlab.WithContext(g.ctx))
162154
if err != nil {
163155
return nil, err
@@ -167,9 +159,6 @@ func (g *GitlabDownloader) GetTopics() ([]string, error) {
167159

168160
// GetMilestones returns milestones
169161
func (g *GitlabDownloader) GetMilestones() ([]*base.Milestone, error) {
170-
if g == nil {
171-
return nil, errors.New("error: GitlabDownloader is nil")
172-
}
173162
var perPage = 100
174163
var state = "all"
175164
var milestones = make([]*base.Milestone, 0, perPage)
@@ -226,11 +215,21 @@ func (g *GitlabDownloader) GetMilestones() ([]*base.Milestone, error) {
226215
return milestones, nil
227216
}
228217

218+
func (g *GitlabDownloader) normalizeColor(val string) string {
219+
val = strings.TrimLeft(val, "#")
220+
val = strings.ToLower(val)
221+
if len(val) == 3 {
222+
c := []rune(val)
223+
val = fmt.Sprintf("%c%c%c%c%c%c", c[0], c[0], c[1], c[1], c[2], c[2])
224+
}
225+
if len(val) != 6 {
226+
return ""
227+
}
228+
return val
229+
}
230+
229231
// GetLabels returns labels
230232
func (g *GitlabDownloader) GetLabels() ([]*base.Label, error) {
231-
if g == nil {
232-
return nil, errors.New("error: GitlabDownloader is nil")
233-
}
234233
var perPage = 100
235234
var labels = make([]*base.Label, 0, perPage)
236235
for i := 1; ; i++ {
@@ -244,7 +243,7 @@ func (g *GitlabDownloader) GetLabels() ([]*base.Label, error) {
244243
for _, label := range ls {
245244
baseLabel := &base.Label{
246245
Name: label.Name,
247-
Color: strings.TrimLeft(label.Color, "#)"),
246+
Color: g.normalizeColor(label.Color),
248247
Description: label.Description,
249248
}
250249
labels = append(labels, baseLabel)
@@ -466,7 +465,6 @@ func (g *GitlabDownloader) GetComments(issueNumber int64) ([]*base.Comment, erro
466465

467466
// GetPullRequests returns pull requests according page and perPage
468467
func (g *GitlabDownloader) GetPullRequests(page, perPage int) ([]*base.PullRequest, error) {
469-
470468
opt := &gitlab.ListProjectMergeRequestsOptions{
471469
ListOptions: gitlab.ListOptions{
472470
PerPage: perPage,
@@ -576,7 +574,6 @@ func (g *GitlabDownloader) GetPullRequests(page, perPage int) ([]*base.PullReque
576574

577575
// GetReviews returns pull requests review
578576
func (g *GitlabDownloader) GetReviews(pullRequestNumber int64) ([]*base.Review, error) {
579-
580577
state, _, err := g.client.MergeRequestApprovals.GetApprovalState(g.repoID, int(pullRequestNumber), gitlab.WithContext(g.ctx))
581578
if err != nil {
582579
return nil, err

modules/migrations/gitlab_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package migrations
66

77
import (
88
"context"
9+
"fmt"
910
"net/http"
1011
"os"
1112
"testing"
@@ -28,9 +29,9 @@ func TestGitlabDownloadRepo(t *testing.T) {
2829
t.Skipf("Can't access test repo, skipping %s", t.Name())
2930
}
3031

31-
downloader := NewGitlabDownloader(context.Background(), "https://gitlab.com", "gitea/test_repo", "", "", gitlabPersonalAccessToken)
32-
if downloader == nil {
33-
t.Fatal("NewGitlabDownloader is nil")
32+
downloader, err := NewGitlabDownloader(context.Background(), "https://gitlab.com", "gitea/test_repo", "", "", gitlabPersonalAccessToken)
33+
if err != nil {
34+
t.Fatal(fmt.Sprintf("NewGitlabDownloader is nil: %v", err))
3435
}
3536
repo, err := downloader.GetRepoInfo()
3637
assert.NoError(t, err)

modules/structs/repo.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package structs
66

77
import (
8+
"strings"
89
"time"
910
)
1011

@@ -205,17 +206,7 @@ const (
205206
// Name represents the service type's name
206207
// WARNNING: the name have to be equal to that on goth's library
207208
func (gt GitServiceType) Name() string {
208-
switch gt {
209-
case GithubService:
210-
return "github"
211-
case GiteaService:
212-
return "gitea"
213-
case GitlabService:
214-
return "gitlab"
215-
case GogsService:
216-
return "gogs"
217-
}
218-
return ""
209+
return strings.ToLower(gt.Title())
219210
}
220211

221212
// Title represents the service type's proper title

modules/templates/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits {
694694
// DiffTypeToStr returns diff type name
695695
func DiffTypeToStr(diffType int) string {
696696
diffTypes := map[int]string{
697-
1: "add", 2: "modify", 3: "del", 4: "rename",
697+
1: "add", 2: "modify", 3: "del", 4: "rename", 5: "copy",
698698
}
699699
return diffTypes[diffType]
700700
}

options/locale/locale_cs-CZ.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,6 @@ migrate.permission_denied=Není dovoleno importovat místní repozitáře.
726726
migrate.invalid_local_path=Místní cesta je neplatná, buď neexistuje nebo není adresářem.
727727
migrate.failed=Přenesení selhalo: %v
728728
migrate.lfs_mirror_unsupported=Zrcadlení LFS objektů není podporováno - použijte místo toho „git lfs fetch --all“ a „git lfs push --all“.
729-
migrate.migrate_items_options=Pro migraci položek ze služby, která je podporuje, je potřeba autentizace.
730729
migrated_from=Migrováno z <a href="%[1]s">%[2]s</a>
731730
migrated_from_fake=Migrováno z %[1]s
732731
migrate.migrating=Probíhá migrace z <b>%s</b> ...

options/locale/locale_de-DE.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,6 @@ migrate.permission_denied=Du hast keine Berechtigung zum Importieren lokaler Rep
726726
migrate.invalid_local_path=Der lokale Pfad ist ungültig, existiert nicht oder ist kein Ordner.
727727
migrate.failed=Fehler bei der Migration: %v
728728
migrate.lfs_mirror_unsupported=Spiegeln von LFS-Objekten wird nicht unterstützt - nutze stattdessen 'git lfs fetch --all' und 'git lfs push --all'.
729-
migrate.migrate_items_options=Authentifizierung wird benötigt, um Elemente aus einem Dienst zu migrieren, der sie unterstützt.
730729
migrated_from=Migriert von <a href="%[1]s">%[2]s</a>
731730
migrated_from_fake=Migriert von %[1]s
732731
migrate.migrating=Migriere von <b>%s</b> ...

options/locale/locale_en-US.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ migrate_items_milestones = Milestones
730730
migrate_items_labels = Labels
731731
migrate_items_issues = Issues
732732
migrate_items_pullrequests = Pull Requests
733+
migrate_items_merge_requests = Merge Requests
733734
migrate_items_releases = Releases
734735
migrate_repo = Migrate Repository
735736
migrate.clone_address = Migrate / Clone From URL
@@ -739,11 +740,15 @@ migrate.permission_denied = You are not allowed to import local repositories.
739740
migrate.invalid_local_path = "The local path is invalid. It does not exist or is not a directory."
740741
migrate.failed = Migration failed: %v
741742
migrate.lfs_mirror_unsupported = Mirroring LFS objects is not supported - use 'git lfs fetch --all' and 'git lfs push --all' instead.
742-
migrate.migrate_items_options = Authentication is needed to migrate items from a service that supports them.
743+
migrate.migrate_items_options = Access Token is required to migrate additional items
743744
migrated_from = Migrated from <a href="%[1]s">%[2]s</a>
744745
migrated_from_fake = Migrated From %[1]s
746+
migrate.migrate = Migrate From %s
745747
migrate.migrating = Migrating from <b>%s</b> ...
746748
migrate.migrating_failed = Migrating from <b>%s</b> failed.
749+
migrate.github.description = Migrating data from Github.com or Github Enterprise.
750+
migrate.git.description = Migrating or Mirroring git data from Git services
751+
migrate.gitlab.description = Migrating data from GitLab.com or Self-Hosted gitlab server.
747752

748753
mirror_from = mirror of
749754
forked_from = forked from

options/locale/locale_es-ES.ini

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ authorize_title=¿Autorizar a "%s" a acceder a su cuenta?
299299
authorization_failed=Autorización fallida
300300
authorization_failed_desc=La autorización ha fallado porque hemos detectado una solicitud no válida. Por favor, póngase en contacto con el mantenedor de la aplicación que ha intentado autorizar.
301301
sspi_auth_failed=Fallo en la autenticación SSPI
302+
password_pwned=La contraseña que eligió está en una <a target="_blank" rel="noopener noreferrer" href="https://haveibeenpwned.com/Passwords">lista de contraseñas robadas</a> previamente expuestas en violaciones de datos públicos. Por favor, inténtalo de nuevo con una contraseña diferente.
303+
password_pwned_err=No se pudo completar la solicitud a HaveIBeenPwned
302304

303305
[mail]
304306
activate_account=Por favor, active su cuenta
@@ -717,6 +719,7 @@ migrate_items_milestones=Hitos
717719
migrate_items_labels=Etiquetas
718720
migrate_items_issues=Incidencias
719721
migrate_items_pullrequests=Pull Requests
722+
migrate_items_merge_requests=Merge Requests
720723
migrate_items_releases=Lanzamientos
721724
migrate_repo=Migrar Repositorio
722725
migrate.clone_address=Migrar / Clonar desde URL
@@ -726,11 +729,15 @@ migrate.permission_denied=No te está permitido importar repositorios locales.
726729
migrate.invalid_local_path=La ruta local es inválida. No existe o no es un directorio.
727730
migrate.failed=Migración fallida: %v
728731
migrate.lfs_mirror_unsupported=La replicación de objetos LFS no está soportada - use 'git lfs fetch --all' y 'git lfs push --all' en su lugar.
729-
migrate.migrate_items_options=Se requiere autenticación para migrar elementos de un servicio que los soporte.
732+
migrate.migrate_items_options=Un token de acceso es necesario para migrar elementos adicionales
730733
migrated_from=Migrado desde <a href="%[1]s">%[2]s</a>
731734
migrated_from_fake=Migrado desde %[1]s
735+
migrate.migrate=Migrar desde %s
732736
migrate.migrating=Migrando desde <b>%s</b>...
733737
migrate.migrating_failed=La migración desde <b>%s</b> ha fallado.
738+
migrate.github.description=Migrar datos de Github.com o Github Enterprise.
739+
migrate.git.description=Migrar o replicar de datos de git desde los servicios de Git
740+
migrate.gitlab.description=Migrar datos de GitLab.com o servidor gitlab autoalojado.
734741

735742
mirror_from=réplica de
736743
forked_from=forkeado de
@@ -759,6 +766,7 @@ code=Código
759766
code.desc=Acceder código fuente, archivos, commits, y ramas.
760767
branch=Rama
761768
tree=Árbol
769+
clear_ref=`Borrar referencia actual`
762770
filter_branch_and_tag=Filtrar por rama o etiqueta
763771
branches=Ramas
764772
tags=Etiquetas

options/locale/locale_ja-JP.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,6 @@ migrate.permission_denied=ローカルリポジトリをインポートする権
726726
migrate.invalid_local_path=ローカルパスが無効です。 存在しないかディレクトリではありません。
727727
migrate.failed=移行に失敗しました: %v
728728
migrate.lfs_mirror_unsupported=LFSオブジェクトのミラーはサポートされていません。 代わりに 'git lfs fetch --all''git lfs push --all' を使ってください。
729-
migrate.migrate_items_options=サービスがサポートしている項目を移行するには、認証が必要です。
730729
migrated_from=<a href="%[1]s">%[2]s</a>から移行
731730
migrated_from_fake=%[1]sから移行
732731
migrate.migrating=<b>%s</b> から移行しています ...

0 commit comments

Comments
 (0)