diff --git a/models/repo.go b/models/repo.go
index d90cdeb77f..666b9ecde6 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
@@ -1437,14 +1459,6 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err
}
}
}
- 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.
return fmt.Errorf("recalculateAccesses: %v", err)
@@ -1527,11 +1541,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
}
@@ -2053,18 +2062,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) {
@@ -2074,7 +2071,6 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
}
}
- DeleteRepoFromIndexer(repo)
return nil
}
@@ -2530,22 +2526,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,
@@ -2562,7 +2558,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
}
@@ -2570,9 +2566,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)
@@ -2595,24 +2591,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)
}
@@ -2621,20 +2599,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/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
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