From 8b078236801f5f37e83ba2f21c11679805e4ae9f Mon Sep 17 00:00:00 2001
From: guillep2k <18600385+guillep2k@users.noreply.github.com>
Date: Fri, 25 Oct 2019 21:43:38 -0300
Subject: [PATCH 1/4] Improve visibility of "Pending" indicator (#8685)
* Improve visibility of "Pending" indicator
* Use background-color instead of just background
* Tone down the yellow
---
public/css/index.css | 1 +
public/less/_repository.less | 5 +++++
templates/repo/diff/comments.tmpl | 2 +-
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/public/css/index.css b/public/css/index.css
index e404c1fec6..2815accab9 100644
--- a/public/css/index.css
+++ b/public/css/index.css
@@ -567,6 +567,7 @@ i.icon.centerlock{top:1.5em}
.repository.view.issue .comment-list .timeline-line:before{display:block;content:"";position:absolute;margin-top:12px;margin-bottom:14px;top:0;bottom:0;left:82px;width:2px;background-color:#f3f3f3;z-index:-1}
.repository.view.issue .comment-list .comment .avatar{width:3em}
.repository.view.issue .comment-list .comment .tag{color:#767676;margin-top:3px;padding:2px 5px;font-size:12px;border:1px solid rgba(0,0,0,.1);border-radius:3px}
+.repository.view.issue .comment-list .comment .tag.pending{color:#000;background-color:#fffbb2;margin-left:5px}
.repository.view.issue .comment-list .comment .actions .item{float:left}
.repository.view.issue .comment-list .comment .actions .item.tag{margin-right:5px}
.repository.view.issue .comment-list .comment .actions .item.action{margin-top:6px;margin-left:10px}
diff --git a/public/less/_repository.less b/public/less/_repository.less
index 48a1214c07..d6bc84ee56 100644
--- a/public/less/_repository.less
+++ b/public/less/_repository.less
@@ -738,6 +738,11 @@
font-size: 12px;
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 3px;
+ &.pending {
+ color: black;
+ background-color: #fffbb2;
+ margin-left: 5px;
+ }
}
.actions {
diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl
index 1288886a61..85c84c6bac 100644
--- a/templates/repo/diff/comments.tmpl
+++ b/templates/repo/diff/comments.tmpl
@@ -11,7 +11,7 @@
{{if and .Review}}
{{if eq .Review.Type 0}}
-
+
{{$.root.i18n.Tr "repo.issues.review.pending"}}
{{else}}
From d2d5910894cfe513f8aa331b30c991db6fbe8e6d Mon Sep 17 00:00:00 2001
From: GiteaBot
Date: Sat, 26 Oct 2019 00:45:54 +0000
Subject: [PATCH 2/4] [skip ci] Updated translations via Crowdin
---
options/locale/locale_es-ES.ini | 3 +++
options/locale/locale_pt-BR.ini | 1 +
2 files changed, 4 insertions(+)
diff --git a/options/locale/locale_es-ES.ini b/options/locale/locale_es-ES.ini
index 1488cf9ba2..a33b78f71b 100644
--- a/options/locale/locale_es-ES.ini
+++ b/options/locale/locale_es-ES.ini
@@ -259,6 +259,7 @@ openid_signin_desc=Introduzca su URI OpenID. Por ejemplo: https://anne.me, bob.o
disable_forgot_password_mail=La recuperación de cuentas está desactivada. Por favor, contacte con el administrador del sitio.
email_domain_blacklisted=No puede registrarse con su correo electrónico.
authorize_application=Autorizar aplicación
+authorize_redirect_notice=Será redirigido a %s si autoriza esta aplicación.
authorize_application_created_by=Esta aplicación fue creada por %s.
authorize_application_description=Si concede el acceso, podrá acceder y escribir a toda la información de su cuenta, incluyendo repositorios privado y organizaciones.
authorize_title=¿Autorizar a "%s" a acceder a su cuenta?
@@ -800,6 +801,7 @@ issues.delete_branch_at=`rama eliminada %s %s`
issues.open_tab=%d abiertas
issues.close_tab=%d cerradas
issues.filter_label=Etiqueta
+issues.filter_label_exclude=`Usa alt
+ clic/enter
para excluir etiquetas`
issues.filter_label_no_select=Todas las etiquetas
issues.filter_milestone=Milestone
issues.filter_milestone_no_select=Todos los hitos
@@ -974,6 +976,7 @@ issues.review.review=Revisar
issues.review.reviewers=Revisores
issues.review.show_outdated=Mostrar obsoletos
issues.review.hide_outdated=Ocultar obsoletos
+issues.assignee.error=No todos los asignados fueron añadidos debido a un error inesperado.
pulls.desc=Activar Pull Requests y revisiones de código.
pulls.new=Nuevo Pull Request
diff --git a/options/locale/locale_pt-BR.ini b/options/locale/locale_pt-BR.ini
index 30549ba69d..08e16bd5e2 100644
--- a/options/locale/locale_pt-BR.ini
+++ b/options/locale/locale_pt-BR.ini
@@ -976,6 +976,7 @@ issues.review.review=Revisão
issues.review.reviewers=Revisões
issues.review.show_outdated=Mostrar desatualizado
issues.review.hide_outdated=Ocultar desatualizado
+issues.assignee.error=Nem todos os responsáveis foram adicionados devido a um erro inesperado.
pulls.desc=Habilitar pull requests e revisões de código.
pulls.new=Novo pull request
From 9e85358777ea4bd345f832d08b19915a72cc128b Mon Sep 17 00:00:00 2001
From: Lunny Xiao
Date: Sat, 26 Oct 2019 14:54:11 +0800
Subject: [PATCH 3/4] Move some repositories' operations to a standalone
service package (#8557)
* Move some repositories' operations to a standalone service package
* improve code
* remove unused codes
* add rollback when fork failed
* add repo when return
---
models/repo.go | 91 ++++++++++---------------
modules/notification/indexer/indexer.go | 1 +
modules/notification/webhook/webhook.go | 64 +++++++++++++++++
routers/admin/repos.go | 3 +-
routers/api/v1/repo/fork.go | 5 +-
routers/api/v1/repo/repo.go | 30 +++-----
routers/repo/pull.go | 3 +-
routers/repo/repo.go | 12 +---
routers/repo/setting.go | 3 +-
services/repository/repository.go | 56 +++++++++++++++
10 files changed, 179 insertions(+), 89 deletions(-)
create mode 100644 services/repository/repository.go
diff --git a/models/repo.go b/models/repo.go
index 3b5395ce16..ac3443f895 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -742,6 +742,28 @@ func (repo *Repository) CanUserFork(user *User) (bool, error) {
return false, nil
}
+// CanUserDelete returns true if user could delete the repository
+func (repo *Repository) CanUserDelete(user *User) (bool, error) {
+ if user.IsAdmin || user.ID == repo.OwnerID {
+ return true, nil
+ }
+
+ if err := repo.GetOwner(); err != nil {
+ return false, err
+ }
+
+ if repo.Owner.IsOrganization() {
+ isOwner, err := repo.Owner.IsOwnedBy(user.ID)
+ if err != nil {
+ return false, err
+ } else if isOwner {
+ return true, nil
+ }
+ }
+
+ return false, nil
+}
+
// CanEnablePulls returns true if repository meets the requirements of accepting pulls.
func (repo *Repository) CanEnablePulls() bool {
return !repo.IsMirror && !repo.IsEmpty
@@ -1430,15 +1452,9 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err
t, err := u.getOwnerTeam(e)
if err != nil {
return fmt.Errorf("getOwnerTeam: %v", err)
- } else if err = t.addRepository(e, repo); err != nil {
+ }
+ if err = t.addRepository(e, repo); err != nil {
return fmt.Errorf("addRepository: %v", err)
- } else if err = prepareWebhooks(e, repo, HookEventRepository, &api.RepositoryPayload{
- Action: api.HookRepoCreated,
- Repository: repo.innerAPIFormat(e, AccessModeOwner, false),
- Organization: u.APIFormat(),
- Sender: doer.APIFormat(),
- }); err != nil {
- return fmt.Errorf("prepareWebhooks: %v", err)
}
} else if err = repo.recalculateAccesses(e); err != nil {
// Organization automatically called this in addRepository method.
@@ -1522,11 +1538,6 @@ func CreateRepository(doer, u *User, opts CreateRepoOptions) (_ *Repository, err
return nil, err
}
- // Add to hook queue for created repo after session commit.
- if u.IsOrganization() {
- go HookQueue.Add(repo.ID)
- }
-
return repo, err
}
@@ -2044,18 +2055,6 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
return fmt.Errorf("Commit: %v", err)
}
- if org.IsOrganization() {
- if err = PrepareWebhooks(repo, HookEventRepository, &api.RepositoryPayload{
- Action: api.HookRepoDeleted,
- Repository: repo.APIFormat(AccessModeOwner),
- Organization: org.APIFormat(),
- Sender: doer.APIFormat(),
- }); err != nil {
- return err
- }
- go HookQueue.Add(repo.ID)
- }
-
if len(repo.Avatar) > 0 {
avatarPath := repo.CustomAvatarPath()
if com.IsExist(avatarPath) {
@@ -2065,7 +2064,6 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
}
}
- DeleteRepoFromIndexer(repo)
return nil
}
@@ -2521,22 +2519,22 @@ func HasForkedRepo(ownerID, repoID int64) (*Repository, bool) {
}
// ForkRepository forks a repository
-func ForkRepository(doer, u *User, oldRepo *Repository, name, desc string) (_ *Repository, err error) {
- forkedRepo, err := oldRepo.GetUserFork(u.ID)
+func ForkRepository(doer, owner *User, oldRepo *Repository, name, desc string) (_ *Repository, err error) {
+ forkedRepo, err := oldRepo.GetUserFork(owner.ID)
if err != nil {
return nil, err
}
if forkedRepo != nil {
return nil, ErrForkAlreadyExist{
- Uname: u.Name,
+ Uname: owner.Name,
RepoName: oldRepo.FullName(),
ForkName: forkedRepo.FullName(),
}
}
repo := &Repository{
- OwnerID: u.ID,
- Owner: u,
+ OwnerID: owner.ID,
+ Owner: owner,
Name: name,
LowerName: strings.ToLower(name),
Description: desc,
@@ -2553,7 +2551,7 @@ func ForkRepository(doer, u *User, oldRepo *Repository, name, desc string) (_ *R
return nil, err
}
- if err = createRepository(sess, doer, u, repo); err != nil {
+ if err = createRepository(sess, doer, owner, repo); err != nil {
return nil, err
}
@@ -2561,9 +2559,9 @@ func ForkRepository(doer, u *User, oldRepo *Repository, name, desc string) (_ *R
return nil, err
}
- repoPath := RepoPath(u.Name, repo.Name)
+ repoPath := RepoPath(owner.Name, repo.Name)
_, stderr, err := process.GetManager().ExecTimeout(10*time.Minute,
- fmt.Sprintf("ForkRepository(git clone): %s/%s", u.Name, repo.Name),
+ fmt.Sprintf("ForkRepository(git clone): %s/%s", owner.Name, repo.Name),
git.GitExecutable, "clone", "--bare", oldRepo.repoPath(sess), repoPath)
if err != nil {
return nil, fmt.Errorf("git clone: %v", stderr)
@@ -2586,24 +2584,6 @@ func ForkRepository(doer, u *User, oldRepo *Repository, name, desc string) (_ *R
return nil, err
}
- oldMode, _ := AccessLevel(doer, oldRepo)
- mode, _ := AccessLevel(doer, repo)
-
- if err = PrepareWebhooks(oldRepo, HookEventFork, &api.ForkPayload{
- Forkee: oldRepo.APIFormat(oldMode),
- Repo: repo.APIFormat(mode),
- Sender: doer.APIFormat(),
- }); err != nil {
- log.Error("PrepareWebhooks [repo_id: %d]: %v", oldRepo.ID, err)
- } else {
- go HookQueue.Add(oldRepo.ID)
- }
-
- // Add to hook queue for created repo after session commit.
- if u.IsOrganization() {
- go HookQueue.Add(repo.ID)
- }
-
if err = repo.UpdateSize(); err != nil {
log.Error("Failed to update size for repository: %v", err)
}
@@ -2612,20 +2592,19 @@ func ForkRepository(doer, u *User, oldRepo *Repository, name, desc string) (_ *R
sess2 := x.NewSession()
defer sess2.Close()
if err = sess2.Begin(); err != nil {
- return nil, err
+ return repo, err
}
var lfsObjects []*LFSMetaObject
-
if err = sess2.Where("repository_id=?", oldRepo.ID).Find(&lfsObjects); err != nil {
- return nil, err
+ return repo, err
}
for _, v := range lfsObjects {
v.ID = 0
v.RepositoryID = repo.ID
if _, err = sess2.Insert(v); err != nil {
- return nil, err
+ return repo, err
}
}
diff --git a/modules/notification/indexer/indexer.go b/modules/notification/indexer/indexer.go
index 66614b2c20..453eb0c295 100644
--- a/modules/notification/indexer/indexer.go
+++ b/modules/notification/indexer/indexer.go
@@ -98,6 +98,7 @@ func (r *indexerNotifier) NotifyDeleteComment(doer *models.User, comment *models
func (r *indexerNotifier) NotifyDeleteRepository(doer *models.User, repo *models.Repository) {
issue_indexer.DeleteRepoIssueIndexer(repo)
+ models.DeleteRepoFromIndexer(repo)
}
func (r *indexerNotifier) NotifyIssueChangeContent(doer *models.User, issue *models.Issue, oldContent string) {
diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go
index 33adfaa739..13f2f4486a 100644
--- a/modules/notification/webhook/webhook.go
+++ b/modules/notification/webhook/webhook.go
@@ -65,3 +65,67 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model
go models.HookQueue.Add(issue.RepoID)
}
}
+
+func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo *models.Repository) {
+ oldMode, _ := models.AccessLevel(doer, oldRepo)
+ mode, _ := models.AccessLevel(doer, repo)
+
+ // forked webhook
+ if err := models.PrepareWebhooks(oldRepo, models.HookEventFork, &api.ForkPayload{
+ Forkee: oldRepo.APIFormat(oldMode),
+ Repo: repo.APIFormat(mode),
+ Sender: doer.APIFormat(),
+ }); err != nil {
+ log.Error("PrepareWebhooks [repo_id: %d]: %v", oldRepo.ID, err)
+ } else {
+ go models.HookQueue.Add(oldRepo.ID)
+ }
+
+ u := repo.MustOwner()
+
+ // Add to hook queue for created repo after session commit.
+ if u.IsOrganization() {
+ if err := models.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
+ Action: api.HookRepoCreated,
+ Repository: repo.APIFormat(models.AccessModeOwner),
+ Organization: u.APIFormat(),
+ Sender: doer.APIFormat(),
+ }); err != nil {
+ log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
+ } else {
+ go models.HookQueue.Add(repo.ID)
+ }
+ }
+}
+
+func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
+ // Add to hook queue for created repo after session commit.
+ if u.IsOrganization() {
+ if err := models.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
+ Action: api.HookRepoCreated,
+ Repository: repo.APIFormat(models.AccessModeOwner),
+ Organization: u.APIFormat(),
+ Sender: doer.APIFormat(),
+ }); err != nil {
+ log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
+ } else {
+ go models.HookQueue.Add(repo.ID)
+ }
+ }
+}
+
+func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models.Repository) {
+ u := repo.MustOwner()
+
+ if u.IsOrganization() {
+ if err := models.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
+ Action: api.HookRepoDeleted,
+ Repository: repo.APIFormat(models.AccessModeOwner),
+ Organization: u.APIFormat(),
+ Sender: doer.APIFormat(),
+ }); err != nil {
+ log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
+ }
+ go models.HookQueue.Add(repo.ID)
+ }
+}
diff --git a/routers/admin/repos.go b/routers/admin/repos.go
index d345c8e76a..73aa66807b 100644
--- a/routers/admin/repos.go
+++ b/routers/admin/repos.go
@@ -11,6 +11,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/routers"
+ repo_service "code.gitea.io/gitea/services/repository"
)
const (
@@ -38,7 +39,7 @@ func DeleteRepo(ctx *context.Context) {
return
}
- if err := models.DeleteRepository(ctx.User, repo.MustOwner().ID, repo.ID); err != nil {
+ if err := repo_service.DeleteRepository(ctx.User, repo); err != nil {
ctx.ServerError("DeleteRepository", err)
return
}
diff --git a/routers/api/v1/repo/fork.go b/routers/api/v1/repo/fork.go
index 7231daab29..31f2389478 100644
--- a/routers/api/v1/repo/fork.go
+++ b/routers/api/v1/repo/fork.go
@@ -8,6 +8,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
api "code.gitea.io/gitea/modules/structs"
+ repo_service "code.gitea.io/gitea/services/repository"
)
// ListForks list a repository's forks
@@ -97,10 +98,12 @@ func CreateFork(ctx *context.APIContext, form api.CreateForkOption) {
}
forker = org
}
- fork, err := models.ForkRepository(ctx.User, forker, repo, repo.Name, repo.Description)
+
+ fork, err := repo_service.ForkRepository(ctx.User, forker, repo, repo.Name, repo.Description)
if err != nil {
ctx.Error(500, "ForkRepository", err)
return
}
+
ctx.JSON(202, fork.APIFormat(models.AccessModeOwner))
}
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index a4417107ee..422bb0ac3a 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -24,6 +24,7 @@ import (
"code.gitea.io/gitea/modules/validation"
"code.gitea.io/gitea/routers/api/v1/convert"
mirror_service "code.gitea.io/gitea/services/mirror"
+ repo_service "code.gitea.io/gitea/services/repository"
)
var searchOrderByMap = map[string]map[string]models.SearchOrderBy{
@@ -207,7 +208,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
if opt.AutoInit && opt.Readme == "" {
opt.Readme = "Default"
}
- repo, err := models.CreateRepository(ctx.User, owner, models.CreateRepoOptions{
+ repo, err := repo_service.CreateRepository(ctx.User, owner, models.CreateRepoOptions{
Name: opt.Name,
Description: opt.Description,
IssueLabels: opt.IssueLabels,
@@ -224,18 +225,11 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
models.IsErrNamePatternNotAllowed(err) {
ctx.Error(422, "", err)
} else {
- if repo != nil {
- if err = models.DeleteRepository(ctx.User, ctx.User.ID, repo.ID); err != nil {
- log.Error("DeleteRepository: %v", err)
- }
- }
ctx.Error(500, "CreateRepository", err)
}
return
}
- notification.NotifyCreateRepository(ctx.User, owner, repo)
-
ctx.JSON(201, repo.APIFormat(models.AccessModeOwner))
}
@@ -433,7 +427,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
repo, err := migrations.MigrateRepository(ctx.User, ctxUser.Name, opts)
if err == nil {
- notification.NotifyCreateRepository(ctx.User, ctxUser, repo)
+ notification.NotifyMigrateRepository(ctx.User, ctxUser, repo)
log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName)
ctx.JSON(201, repo.APIFormat(models.AccessModeAdmin))
@@ -876,18 +870,16 @@ func Delete(ctx *context.APIContext) {
owner := ctx.Repo.Owner
repo := ctx.Repo.Repository
- if owner.IsOrganization() && !ctx.User.IsAdmin {
- isOwner, err := owner.IsOwnedBy(ctx.User.ID)
- if err != nil {
- ctx.Error(500, "IsOwnedBy", err)
- return
- } else if !isOwner {
- ctx.Error(403, "", "Given user is not owner of organization.")
- return
- }
+ canDelete, err := repo.CanUserDelete(ctx.User)
+ if err != nil {
+ ctx.Error(500, "CanUserDelete", err)
+ return
+ } else if !canDelete {
+ ctx.Error(403, "", "Given user is not owner of organization.")
+ return
}
- if err := models.DeleteRepository(ctx.User, owner.ID, repo.ID); err != nil {
+ if err := repo_service.DeleteRepository(ctx.User, repo); err != nil {
ctx.Error(500, "DeleteRepository", err)
return
}
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 23d97e7b7e..f3a9aca2a4 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -26,6 +26,7 @@ import (
"code.gitea.io/gitea/services/gitdiff"
issue_service "code.gitea.io/gitea/services/issue"
pull_service "code.gitea.io/gitea/services/pull"
+ repo_service "code.gitea.io/gitea/services/repository"
"github.com/unknwon/com"
)
@@ -209,7 +210,7 @@ func ForkPost(ctx *context.Context, form auth.CreateRepoForm) {
}
}
- repo, err := models.ForkRepository(ctx.User, ctxUser, forkRepo, form.RepoName, form.Description)
+ repo, err := repo_service.ForkRepository(ctx.User, ctxUser, forkRepo, form.RepoName, form.Description)
if err != nil {
ctx.Data["Err_RepoName"] = true
switch {
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index bfd0c771b0..cf1845a727 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -17,10 +17,10 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/migrations"
- "code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/task"
"code.gitea.io/gitea/modules/util"
+ repo_service "code.gitea.io/gitea/services/repository"
"github.com/unknwon/com"
)
@@ -170,7 +170,7 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) {
return
}
- repo, err := models.CreateRepository(ctx.User, ctxUser, models.CreateRepoOptions{
+ repo, err := repo_service.CreateRepository(ctx.User, ctxUser, models.CreateRepoOptions{
Name: form.RepoName,
Description: form.Description,
Gitignores: form.Gitignores,
@@ -181,19 +181,11 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) {
AutoInit: form.AutoInit,
})
if err == nil {
- notification.NotifyCreateRepository(ctx.User, ctxUser, repo)
-
log.Trace("Repository created [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name)
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
return
}
- if repo != nil {
- if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil {
- log.Error("DeleteRepository: %v", errDelete)
- }
- }
-
handleCreateError(ctx, ctxUser, err, "CreatePost", tplCreate, &form)
}
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index c74b273420..663394fe3d 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -26,6 +26,7 @@ import (
"code.gitea.io/gitea/routers/utils"
"code.gitea.io/gitea/services/mailer"
mirror_service "code.gitea.io/gitea/services/mirror"
+ repo_service "code.gitea.io/gitea/services/repository"
"github.com/unknwon/com"
"mvdan.cc/xurls/v2"
@@ -407,7 +408,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
return
}
- if err := models.DeleteRepository(ctx.User, ctx.Repo.Owner.ID, repo.ID); err != nil {
+ if err := repo_service.DeleteRepository(ctx.User, ctx.Repo.Repository); err != nil {
ctx.ServerError("DeleteRepository", err)
return
}
diff --git a/services/repository/repository.go b/services/repository/repository.go
new file mode 100644
index 0000000000..5135435c78
--- /dev/null
+++ b/services/repository/repository.go
@@ -0,0 +1,56 @@
+// Copyright 2019 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 repository
+
+import (
+ "code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/notification"
+)
+
+// CreateRepository creates a repository for the user/organization.
+func CreateRepository(doer, owner *models.User, opts models.CreateRepoOptions) (*models.Repository, error) {
+ repo, err := models.CreateRepository(doer, owner, opts)
+ if err != nil {
+ if repo != nil {
+ if errDelete := models.DeleteRepository(doer, owner.ID, repo.ID); errDelete != nil {
+ log.Error("Rollback deleteRepository: %v", errDelete)
+ }
+ }
+ return nil, err
+ }
+
+ notification.NotifyCreateRepository(doer, owner, repo)
+
+ return repo, nil
+}
+
+// ForkRepository forks a repository
+func ForkRepository(doer, u *models.User, oldRepo *models.Repository, name, desc string) (*models.Repository, error) {
+ repo, err := models.ForkRepository(doer, u, oldRepo, name, desc)
+ if err != nil {
+ if repo != nil {
+ if errDelete := models.DeleteRepository(doer, u.ID, repo.ID); errDelete != nil {
+ log.Error("Rollback deleteRepository: %v", errDelete)
+ }
+ }
+ return nil, err
+ }
+
+ notification.NotifyForkRepository(doer, oldRepo, repo)
+
+ return repo, nil
+}
+
+// DeleteRepository deletes a repository for a user or organization.
+func DeleteRepository(doer *models.User, repo *models.Repository) error {
+ if err := models.DeleteRepository(doer, repo.OwnerID, repo.ID); err != nil {
+ return err
+ }
+
+ notification.NotifyDeleteRepository(doer, repo)
+
+ return nil
+}
From 70fa80df114c1b54f77f0f7ccede2cf19775c61f Mon Sep 17 00:00:00 2001
From: GiteaBot
Date: Sat, 26 Oct 2019 06:56:48 +0000
Subject: [PATCH 4/4] [skip ci] Updated translations via Crowdin
---
options/locale/locale_tr-TR.ini | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/options/locale/locale_tr-TR.ini b/options/locale/locale_tr-TR.ini
index 5100f84319..1585693ae2 100644
--- a/options/locale/locale_tr-TR.ini
+++ b/options/locale/locale_tr-TR.ini
@@ -746,8 +746,8 @@ issues.label_templates.fail_to_load_file=Etiket şablon dosyası yüklemesi baş
issues.add_label_at= %[4]s %[3]s
etiketini eklendi
issues.remove_label_at=%s
etiketi silindi %s
issues.add_milestone_at=`%[2]s %[1]s kilometre taşına ekledi`
-issues.change_milestone_at=` %sden%sye yol taşı düzenlendi %s`
-issues.remove_milestone_at=`bu dosya %s yol taşından kaldırıldı %s`
+issues.change_milestone_at=`%[3]s kilometre taşı %[1]s iken %[2]s olarak değiştirildi`
+issues.remove_milestone_at=`%[2]s %[1]s kilometre taşından kaldırıldı`
issues.deleted_milestone=`(silindi)`
issues.self_assign_at=`%s kendini atadı`
issues.add_assignee_at=`%[2]s %[1]s tarafından atandı`