summaryrefslogtreecommitdiffstats
path: root/routers/repo
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-09-01 11:43:53 -0400
committerUnknwon <u@gogs.io>2015-09-01 11:43:53 -0400
commit398569f6f8c9636a7497a250f02e9c6b0a27ea9a (patch)
treee706abe838eb5311c02cf47e5e5b99a9c221090e /routers/repo
parentdde9ace91b3e492386d4b31996ae970f5c9c10bd (diff)
downloadgitea-398569f6f8c9636a7497a250f02e9c6b0a27ea9a.tar.gz
gitea-398569f6f8c9636a7497a250f02e9c6b0a27ea9a.zip
#1021 Forked repo unavailable after deleting original repo
Diffstat (limited to 'routers/repo')
-rw-r--r--routers/repo/repo.go4
-rw-r--r--routers/repo/setting.go14
2 files changed, 12 insertions, 6 deletions
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
}