summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo.go4
-rw-r--r--routers/repo/repo.go4
-rw-r--r--routers/repo/setting.go14
3 files changed, 14 insertions, 8 deletions
diff --git a/routers/api/v1/repo.go b/routers/api/v1/repo.go
index 9126ba3769..6e883a2084 100644
--- a/routers/api/v1/repo.go
+++ b/routers/api/v1/repo.go
@@ -151,7 +151,7 @@ func createRepo(ctx *middleware.Context, owner *models.User, opt api.CreateRepoO
} else {
log.Error(4, "CreateRepository: %v", err)
if repo != nil {
- if err = models.DeleteRepository(ctx.User.Id, repo.ID, ctx.User.Name); err != nil {
+ if err = models.DeleteRepository(ctx.User.Id, repo.ID); err != nil {
log.Error(4, "DeleteRepository: %v", err)
}
}
@@ -256,7 +256,7 @@ func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) {
repo, err := models.MigrateRepository(ctxUser, form.RepoName, form.Description, form.Private, form.Mirror, remoteAddr)
if err != nil {
if repo != nil {
- if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID, ctxUser.Name); errDelete != nil {
+ if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete)
}
}
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index 1e1c24b865..329bc93311 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -126,7 +126,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
}
if repo != nil {
- if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID, ctxUser.Name); errDelete != nil {
+ if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete)
}
}
@@ -192,7 +192,7 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
}
if repo != nil {
- if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID, ctxUser.Name); errDelete != nil {
+ if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete)
}
}
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index d01b12645e..1d88a128ec 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -53,10 +53,12 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
return
}
+ isNameChanged := false
oldRepoName := repo.Name
newRepoName := form.RepoName
// Check if repository name has been changed.
if repo.LowerName != strings.ToLower(newRepoName) {
+ isNameChanged = true
if err := models.ChangeRepositoryName(ctx.Repo.Owner, repo.Name, newRepoName); err != nil {
ctx.Data["Err_RepoName"] = true
switch {
@@ -71,6 +73,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
}
return
}
+
log.Trace("Repository name changed: %s/%s -> %s", ctx.Repo.Owner.Name, repo.Name, newRepoName)
}
// In case it's just a case change.
@@ -87,12 +90,15 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
if err := models.UpdateRepository(repo, visibilityChanged); err != nil {
ctx.Handle(500, "UpdateRepository", err)
return
- } else if err = models.RenameRepoAction(ctx.User, oldRepoName, repo); err != nil {
- ctx.Handle(500, "RenameRepoAction", err)
- return
}
log.Trace("Repository updated: %s/%s", ctx.Repo.Owner.Name, repo.Name)
+ if isNameChanged {
+ if err := models.RenameRepoAction(ctx.User, oldRepoName, repo); err != nil {
+ log.Error(4, "RenameRepoAction: %v", err)
+ }
+ }
+
if repo.IsMirror {
if form.Interval > 0 {
ctx.Repo.Mirror.Interval = form.Interval
@@ -152,7 +158,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
}
}
- if err := models.DeleteRepository(ctx.Repo.Owner.Id, repo.ID, ctx.Repo.Owner.Name); err != nil {
+ if err := models.DeleteRepository(ctx.Repo.Owner.Id, repo.ID); err != nil {
ctx.Handle(500, "DeleteRepository", err)
return
}