Skip to content

Commit

Permalink
Merge branch 'master' into mail-issue-close
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored Jun 11, 2019
2 parents 59d4674 + 74690f6 commit def90c9
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 30 deletions.
2 changes: 1 addition & 1 deletion cmd/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
4 changes: 0 additions & 4 deletions models/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions modules/repofiles/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
18 changes: 16 additions & 2 deletions modules/repofiles/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions modules/repofiles/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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...)
}
4 changes: 4 additions & 0 deletions options/locale/locale_de-DE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion options/locale/locale_zh-CN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 数据库的文件路径。<br>如果以服务的方式运行 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=站点名称
Expand Down Expand Up @@ -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=更新密码
Expand Down Expand Up @@ -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=创建应用
Expand Down Expand Up @@ -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=派生自
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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=分列视图
Expand Down Expand Up @@ -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服务有效)
Expand Down
11 changes: 10 additions & 1 deletion routers/private/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
56 changes: 56 additions & 0 deletions routers/private/push_update.go
Original file line number Diff line number Diff line change
@@ -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)
}
21 changes: 12 additions & 9 deletions routers/repo/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
14 changes: 8 additions & 6 deletions routers/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion routers/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit def90c9

Please sign in to comment.