From 3e05661d8d52315d6dbb601950df2354428ac119 Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Mon, 10 Jun 2019 02:02:42 +0100 Subject: [PATCH 1/7] archived repos can be starred and watched (#7163) --- routers/routes/routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 4c736f63ed40..f7ccfc43d24b 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -674,7 +674,7 @@ func RegisterRoutes(m *macaron.Macaron) { }) }, reqSignIn, context.RepoAssignment(), reqRepoAdmin, context.UnitTypes(), context.RepoRef()) - m.Get("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), context.UnitTypes(), context.RepoMustNotBeArchived(), repo.Action) + m.Get("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), context.UnitTypes(), repo.Action) m.Group("/:username/:reponame", func() { m.Group("/issues", func() { From b1be6fd31f6f9f1512de16cd93d30775319b3c75 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Mon, 10 Jun 2019 01:06:14 +0000 Subject: [PATCH 2/7] [skip ci] Updated translations via Crowdin --- options/locale/locale_de-DE.ini | 4 ++++ options/locale/locale_zh-CN.ini | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_de-DE.ini b/options/locale/locale_de-DE.ini index 7a0b61d2eef9..7176b23f5604 100644 --- a/options/locale/locale_de-DE.ini +++ b/options/locale/locale_de-DE.ini @@ -618,6 +618,7 @@ migrate.permission_denied=Du hast keine Berechtigung zum Importieren lokaler Rep migrate.invalid_local_path=Der lokale Pfad ist ungültig, existiert nicht oder ist kein Ordner. migrate.failed=Fehler bei der Migration: %v migrate.lfs_mirror_unsupported=Spiegeln von LFS-Objekten wird nicht unterstützt - nutze stattdessen 'git lfs fetch --all' und 'git lfs push --all'. +migrate.migrate_items_options=Wenn du von GitHub migrierst und einen Benutzernamen eingegeben hast, werden die Migrationsoptionen angezeigt. mirror_from=Mirror von forked_from=geforkt von @@ -1304,11 +1305,14 @@ settings.archive.button=Repo archivieren settings.archive.header=Dieses Repo archivieren settings.archive.text=Durch die Archivierung des Repos wird es vollständig schreibgeschützt. Es wird auf dem Dashboard versteckt, nimmt keine Commits an und es können keine Issues oder Pull-Requests erstellt werden. settings.archive.success=Das Repo wurde erfolgreich archiviert. +settings.archive.error=Beim Versuch, das Repository zu archivieren, ist ein Fehler aufgetreten. Weitere Details finden sich im Log. settings.archive.error_ismirror=Du kannst keinen Repo-Mirror archivieren. settings.archive.branchsettings_unavailable=Branch-Einstellungen sind nicht verfügbar wenn das Repo archiviert ist. settings.unarchive.button=Archivieren rückgängig machen settings.unarchive.header=Archivieren dieses Repos rückgängig machen +settings.unarchive.text=Durch das Aufheben der Archivierung kann das Repo wieder Commits und Pushes sowie neue Issues und Pull-Requests empfangen. settings.unarchive.success=Die Archivierung des Repos wurde erfolgreich wieder rückgängig gemacht. +settings.unarchive.error=Beim Versuch, die Archivierung des Repos aufzuheben, ist ein Fehler aufgetreten. Weitere Details finden sich im Log. settings.update_avatar_success=Der Repository-Avatar wurde aktualisiert. diff.browse_source=Quellcode durchsuchen diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index da23f30fb6aa..6b495bee8738 100644 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -86,12 +86,18 @@ host=数据库主机 user=用户名 password=数据库用户密码 db_name=数据库名称 +db_helper=MySQL 用户注意:请使用InnoDB 存储引擎,如果您使用“utf8mb4”,您的 InnoDB 版本必须大于5.6。 ssl_mode=SSL +charset=字符集 path=数据库文件路径 sqlite_helper=SQLite3 数据库的文件路径。
如果以服务的方式运行 Gitea,请输入绝对路径。 err_empty_db_path=SQLite 数据库文件路径不能为空。 no_admin_and_disable_registration=您不能够在未创建管理员用户的情况下禁止注册。 err_empty_admin_password=管理员密码不能为空。 +err_empty_admin_email=管理员电子邮件不能为空。 +err_admin_name_is_reserved=管理员用户名无效,用户名是保留的 +err_admin_name_pattern_not_allowed=管理员用户名无效,用户名不符合要求 +err_admin_name_is_invalid=管理员用户名无效 general_title=一般设置 app_name=站点名称 @@ -382,6 +388,7 @@ choose_new_avatar=选择新的头像 update_avatar=更新头像 delete_current_avatar=删除当前头像 uploaded_avatar_not_a_image=上传的文件不是一张图片。 +uploaded_avatar_is_too_big=上传的文件超过了最大大小。 update_avatar_success=您的头像已更新。 change_password=更新密码 @@ -480,6 +487,7 @@ manage_oauth2_applications=管理 OAuth2 应用程序 edit_oauth2_application=编辑 OAuth2 应用程序 oauth2_applications_desc=OAuth2 应用允许第三方应用程序在此 Gitea 实例中安全验证用户。 remove_oauth2_application=删除 OAuth2 应用程序 +remove_oauth2_application_desc=删除 OAuth2 应用将撤销所有签名的访问令牌。继续吗? remove_oauth2_application_success=该应用已被删除。 create_oauth2_application=创建新的 OAuth2 应用程序 create_oauth2_application_button=创建应用 @@ -611,6 +619,7 @@ migrate.permission_denied=您没有获得导入本地仓库的权限。 migrate.invalid_local_path=无效的本地路径,不存在或不是一个目录! migrate.failed=迁移失败:%v migrate.lfs_mirror_unsupported=不支持镜像 LFS 对象 - 使用 'git lfs fetch --all' 和 'git lfs push --all' 替代。 +migrate.migrate_items_options=当从 github 迁移并且输入了用户名时,迁移选项将会显示。 mirror_from=镜像自地址 forked_from=派生自 @@ -923,7 +932,7 @@ issues.dependency.add_error_cannot_create_circular=您不能创建依赖, 使得 issues.dependency.add_error_dep_not_same_repo=这两个工单必须在同一仓库。 issues.review.self.approval=您不能批准您自己的合并请求。 issues.review.self.rejection=您不能请求对您自己的合并请求进行更改。 -issues.review.approve=已批准这些更改 %s +issues.review.approve=已于 %s 批准这些更改 issues.review.comment=评审于 %s issues.review.content.empty=您需要留下一个注释,表明需要的更改。 issues.review.reject=请求变更 %s @@ -1297,15 +1306,20 @@ settings.archive.button=归档仓库 settings.archive.header=归档此仓库 settings.archive.text=归档后仓库将只有只读权限,并在仪表盘中被隐藏。你将不能再对其建立提交、创建工单或建立合并请求。 settings.archive.success=仓库已成功归档。 +settings.archive.error=仓库在归档时出现异常。请通过日志获取详细信息。 settings.archive.error_ismirror=请不要对镜像仓库归档,谢谢! settings.archive.branchsettings_unavailable=已归档仓库无法进行分支设置。 settings.unarchive.button=撤销仓库归档 settings.unarchive.header=撤销此仓库归档 +settings.unarchive.text=取消存档将恢复仓库接收提交,推送,新工单和合并请求。 settings.unarchive.success=仓库已成功取消归档。 +settings.unarchive.error=仓库在撤销归档时出现异常。请通过日志获取详细信息。 +settings.update_avatar_success=仓库头像已经更新。 diff.browse_source=浏览代码 diff.parent=父节点 diff.commit=当前提交 +diff.git-notes=Notes diff.data_not_available=比较内容不可用 diff.show_diff_stats=显示文件统计 diff.show_split_view=分列视图 @@ -1507,6 +1521,8 @@ dashboard.delete_repo_archives=删除所有仓库存档 dashboard.delete_repo_archives_success=所有仓库存档清除成功! dashboard.delete_missing_repos=删除所有丢失 Git 文件的仓库 dashboard.delete_missing_repos_success=所有丢失对应 Git 文件的仓库已被删除。 +dashboard.delete_generated_repository_avatars=删除生成的仓库头像 +dashboard.delete_generated_repository_avatars_success=生成的仓库头像已删除。 dashboard.git_gc_repos=对仓库进行垃圾回收 dashboard.git_gc_repos_success=所有仓库已完成执行垃圾回收。 dashboard.resync_all_sshkeys=重新生成 '.ssh/authorized_keys' 文件。(仅对非内置SSH服务有效) From d93e6232e829a1ade1f9540a701061967aa7d61d Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 10 Jun 2019 19:35:13 +0800 Subject: [PATCH 3/7] Move PushUpdate dependency from models to repofiles (#6763) * remove push_update * move models.PushUpdate to repofiles.PushUpdate --- models/update.go | 4 --- modules/repofiles/delete.go | 5 ++- modules/repofiles/update.go | 18 +++++++++-- modules/repofiles/upload.go | 4 +-- routers/private/hook.go | 11 ++++++- routers/private/push_update.go | 56 ++++++++++++++++++++++++++++++++++ routers/repo/branch.go | 21 +++++++------ 7 files changed, 98 insertions(+), 21 deletions(-) create mode 100644 routers/private/push_update.go diff --git a/models/update.go b/models/update.go index 1492d6c0d351..0883cb0e0116 100644 --- a/models/update.go +++ b/models/update.go @@ -263,10 +263,6 @@ func pushUpdate(opts PushUpdateOptions) (repo *Repository, err error) { commits = ListToPushCommits(l) } - if opts.RefFullName == git.BranchPrefix+repo.DefaultBranch { - UpdateRepoIndexer(repo) - } - if err := CommitRepoAction(CommitRepoActionOptions{ PusherName: opts.PusherName, RepoOwnerID: owner.ID, diff --git a/modules/repofiles/delete.go b/modules/repofiles/delete.go index ccf90f43b307..09a4dbb44c9b 100644 --- a/modules/repofiles/delete.go +++ b/modules/repofiles/delete.go @@ -183,7 +183,8 @@ func DeleteRepoFile(repo *models.Repository, doer *models.User, opts *DeleteRepo if err = repo.GetOwner(); err != nil { return nil, fmt.Errorf("GetOwner: %v", err) } - err = models.PushUpdate( + err = PushUpdate( + repo, opts.NewBranch, models.PushUpdateOptions{ PusherID: doer.ID, @@ -199,8 +200,6 @@ func DeleteRepoFile(repo *models.Repository, doer *models.User, opts *DeleteRepo return nil, fmt.Errorf("PushUpdate: %v", err) } - // FIXME: Should we UpdateRepoIndexer(repo) here? - file, err := GetFileResponseFromCommit(repo, commit, opts.NewBranch, treePath) if err != nil { return nil, err diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go index 66e3f2babced..569c89ac51d5 100644 --- a/modules/repofiles/update.go +++ b/modules/repofiles/update.go @@ -394,7 +394,8 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up if err = repo.GetOwner(); err != nil { return nil, fmt.Errorf("GetOwner: %v", err) } - err = models.PushUpdate( + err = PushUpdate( + repo, opts.NewBranch, models.PushUpdateOptions{ PusherID: doer.ID, @@ -409,7 +410,6 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up if err != nil { return nil, fmt.Errorf("PushUpdate: %v", err) } - models.UpdateRepoIndexer(repo) commit, err = t.GetCommit(commitHash) if err != nil { @@ -422,3 +422,17 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up } return file, nil } + +// PushUpdate must be called for any push actions in order to +// generates necessary push action history feeds and other operations +func PushUpdate(repo *models.Repository, branch string, opts models.PushUpdateOptions) error { + err := models.PushUpdate(branch, opts) + if err != nil { + return fmt.Errorf("PushUpdate: %v", err) + } + + if opts.RefFullName == git.BranchPrefix+repo.DefaultBranch { + models.UpdateRepoIndexer(repo) + } + return nil +} diff --git a/modules/repofiles/upload.go b/modules/repofiles/upload.go index ed6a9438c70f..5f428c3139a4 100644 --- a/modules/repofiles/upload.go +++ b/modules/repofiles/upload.go @@ -188,7 +188,8 @@ func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRep if err = repo.GetOwner(); err != nil { return fmt.Errorf("GetOwner: %v", err) } - err = models.PushUpdate( + err = PushUpdate( + repo, opts.NewBranch, models.PushUpdateOptions{ PusherID: doer.ID, @@ -203,7 +204,6 @@ func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRep if err != nil { return fmt.Errorf("PushUpdate: %v", err) } - // FIXME: Should we models.UpdateRepoIndexer(repo) here? return models.DeleteUploads(uploads...) } diff --git a/routers/private/hook.go b/routers/private/hook.go index 700c8bf33279..a5985f161e71 100644 --- a/routers/private/hook.go +++ b/routers/private/hook.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/private" + "code.gitea.io/gitea/modules/repofiles" "code.gitea.io/gitea/modules/util" macaron "gopkg.in/macaron.v1" @@ -117,7 +118,15 @@ func HookPostReceive(ctx *macaron.Context) { // or other less-standard refs spaces are ignored since there // may be a very large number of them). if strings.HasPrefix(refFullName, git.BranchPrefix) || strings.HasPrefix(refFullName, git.TagPrefix) { - if err := models.PushUpdate(branch, models.PushUpdateOptions{ + repo, err := models.GetRepositoryByOwnerAndName(ownerName, repoName) + if err != nil { + log.Error("Failed to get repository: %s/%s Error: %v", ownerName, repoName, err) + ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ + "err": fmt.Sprintf("Failed to get repository: %s/%s Error: %v", ownerName, repoName, err), + }) + return + } + if err := repofiles.PushUpdate(repo, branch, models.PushUpdateOptions{ RefFullName: refFullName, OldCommitID: oldCommitID, NewCommitID: newCommitID, diff --git a/routers/private/push_update.go b/routers/private/push_update.go new file mode 100644 index 000000000000..733490ce1cd7 --- /dev/null +++ b/routers/private/push_update.go @@ -0,0 +1,56 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package private + +import ( + "encoding/json" + "strings" + + "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/repofiles" + + macaron "gopkg.in/macaron.v1" +) + +// PushUpdate update public key updates +func PushUpdate(ctx *macaron.Context) { + var opt models.PushUpdateOptions + if err := json.NewDecoder(ctx.Req.Request.Body).Decode(&opt); err != nil { + ctx.JSON(500, map[string]interface{}{ + "err": err.Error(), + }) + return + } + + branch := strings.TrimPrefix(opt.RefFullName, git.BranchPrefix) + if len(branch) == 0 || opt.PusherID <= 0 { + ctx.Error(404) + log.Trace("PushUpdate: branch or secret is empty, or pusher ID is not valid") + return + } + + repo, err := models.GetRepositoryByOwnerAndName(opt.RepoUserName, opt.RepoName) + if err != nil { + ctx.JSON(500, map[string]interface{}{ + "err": err.Error(), + }) + return + } + + err = repofiles.PushUpdate(repo, branch, opt) + if err != nil { + if models.IsErrUserNotExist(err) { + ctx.Error(404) + } else { + ctx.JSON(500, map[string]interface{}{ + "err": err.Error(), + }) + } + return + } + ctx.Status(202) +} diff --git a/routers/repo/branch.go b/routers/repo/branch.go index ae87aa5b3a09..05d64fb4c8d0 100644 --- a/routers/repo/branch.go +++ b/routers/repo/branch.go @@ -131,15 +131,18 @@ func deleteBranch(ctx *context.Context, branchName string) error { } // Don't return error below this - if err := models.PushUpdate(branchName, models.PushUpdateOptions{ - RefFullName: git.BranchPrefix + branchName, - OldCommitID: commit.ID.String(), - NewCommitID: git.EmptySHA, - PusherID: ctx.User.ID, - PusherName: ctx.User.Name, - RepoUserName: ctx.Repo.Owner.Name, - RepoName: ctx.Repo.Repository.Name, - }); err != nil { + if err := repofiles.PushUpdate( + ctx.Repo.Repository, + branchName, + models.PushUpdateOptions{ + RefFullName: git.BranchPrefix + branchName, + OldCommitID: commit.ID.String(), + NewCommitID: git.EmptySHA, + PusherID: ctx.User.ID, + PusherName: ctx.User.Name, + RepoUserName: ctx.Repo.Owner.Name, + RepoName: ctx.Repo.Repository.Name, + }); err != nil { log.Error("Update: %v", err) } From 7162fbf3d6adf0a1f5b7ce95df5603d995b35d85 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 10 Jun 2019 22:16:02 +0800 Subject: [PATCH 4/7] if milestone id is zero don't get it from database (#7169) --- routers/repo/issue.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index f6030c9823ad..cd384da0d669 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -426,12 +426,14 @@ func NewIssue(ctx *context.Context) { ctx.Data["BodyQuery"] = body milestoneID := ctx.QueryInt64("milestone") - milestone, err := models.GetMilestoneByID(milestoneID) - if err != nil { - log.Error("GetMilestoneByID: %d: %v", milestoneID, err) - } else { - ctx.Data["milestone_id"] = milestoneID - ctx.Data["Milestone"] = milestone + if milestoneID > 0 { + milestone, err := models.GetMilestoneByID(milestoneID) + if err != nil { + log.Error("GetMilestoneByID: %d: %v", milestoneID, err) + } else { + ctx.Data["milestone_id"] = milestoneID + ctx.Data["Milestone"] = milestone + } } setTemplateIfExists(ctx, issueTemplateKey, IssueTemplateCandidates) From 835b53fc259c82f38945a3e107a4eb51478967d5 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 10 Jun 2019 23:20:49 +0800 Subject: [PATCH 5/7] make modules/structs as a spereate go mod (#7127) --- modules/structs/attachment.go | 1 + modules/structs/go.mod | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 modules/structs/go.mod diff --git a/modules/structs/attachment.go b/modules/structs/attachment.go index 954956f32874..7becd9433542 100644 --- a/modules/structs/attachment.go +++ b/modules/structs/attachment.go @@ -3,6 +3,7 @@ // license that can be found in the LICENSE file. package structs // import "code.gitea.io/gitea/modules/structs" + import ( "time" ) diff --git a/modules/structs/go.mod b/modules/structs/go.mod new file mode 100644 index 000000000000..96826f2f07f5 --- /dev/null +++ b/modules/structs/go.mod @@ -0,0 +1,3 @@ +module code.gitea.io/gitea/modules/structs + +go 1.12 From b3b468444b1dcc6c4353df232b6a74b2017e83db Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 11 Jun 2019 03:55:58 +0800 Subject: [PATCH 6/7] Revert "make modules/structs as a spereate go mod (#7127)" (#7175) This reverts commit 835b53fc259c82f38945a3e107a4eb51478967d5. --- modules/structs/attachment.go | 1 - modules/structs/go.mod | 3 --- 2 files changed, 4 deletions(-) delete mode 100644 modules/structs/go.mod diff --git a/modules/structs/attachment.go b/modules/structs/attachment.go index 7becd9433542..954956f32874 100644 --- a/modules/structs/attachment.go +++ b/modules/structs/attachment.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. package structs // import "code.gitea.io/gitea/modules/structs" - import ( "time" ) diff --git a/modules/structs/go.mod b/modules/structs/go.mod deleted file mode 100644 index 96826f2f07f5..000000000000 --- a/modules/structs/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module code.gitea.io/gitea/modules/structs - -go 1.12 From 74690f64514424ac643a8007828de1a785705793 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 11 Jun 2019 09:13:24 +0800 Subject: [PATCH 7/7] fix pusher name via ssh push (#7167) --- cmd/serv.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/serv.go b/cmd/serv.go index 0b0a4e8efba7..c0cb3cd50fd3 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -209,7 +209,7 @@ func runServ(c *cli.Context) error { os.Setenv(models.EnvRepoIsWiki, strconv.FormatBool(results.IsWiki)) os.Setenv(models.EnvRepoName, results.RepoName) os.Setenv(models.EnvRepoUsername, results.OwnerName) - os.Setenv(models.EnvPusherName, username) + os.Setenv(models.EnvPusherName, results.UserName) os.Setenv(models.EnvPusherID, strconv.FormatInt(results.UserID, 10)) os.Setenv(models.ProtectedBranchRepoID, strconv.FormatInt(results.RepoID, 10))