diff options
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/issue.go | 26 | ||||
-rw-r--r-- | routers/repo/pull.go | 5 | ||||
-rw-r--r-- | routers/repo/repo.go | 10 |
3 files changed, 21 insertions, 20 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index e821c130..e242dd0e 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -759,18 +759,6 @@ func NewComment(ctx *middleware.Context, form auth.CreateCommentForm) { return } - // Check if issue owner/poster changes the status of issue. - if (ctx.Repo.IsOwner() || (ctx.IsSigned && issue.IsPoster(ctx.User.Id))) && - (form.Status == "reopen" || form.Status == "close") && - !(issue.IsPull && issue.HasMerged) { - issue.Repo = ctx.Repo.Repository - if err = issue.ChangeStatus(ctx.User, form.Status == "close"); err != nil { - ctx.Handle(500, "ChangeStatus", err) - return - } - log.Trace("%s Issue[%d] status changed: %v", ctx.Req.RequestURI, issue.ID, !issue.IsClosed) - } - // Fix #321: Allow empty comments, as long as we have attachments. if len(form.Content) == 0 && len(attachments) == 0 { ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index)) @@ -820,8 +808,20 @@ func NewComment(ctx *middleware.Context, form auth.CreateCommentForm) { return } } - log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID) + + // Check if issue owner/poster changes the status of issue. + if (ctx.Repo.IsOwner() || (ctx.IsSigned && issue.IsPoster(ctx.User.Id))) && + (form.Status == "reopen" || form.Status == "close") && + !(issue.IsPull && issue.HasMerged) { + issue.Repo = ctx.Repo.Repository + if err = issue.ChangeStatus(ctx.User, form.Status == "close"); err != nil { + ctx.Handle(500, "ChangeStatus", err) + return + } + log.Trace("Issue[%d] status changed: %v", issue.ID, !issue.IsClosed) + } + ctx.Redirect(fmt.Sprintf("%s/issues/%d#%s", ctx.Repo.RepoLink, issue.Index, comment.HashTag())) } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 19f9f5b8..c1eec7cc 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -38,9 +38,8 @@ func getForkRepository(ctx *middleware.Context) *models.Repository { return nil } - // Cannot fork bare repo. - if forkRepo.IsBare { - ctx.Handle(404, "", nil) + if !forkRepo.CanBeForked() { + ctx.Handle(404, "getForkRepository", nil) return nil } diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 329bc933..8a0c5f97 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -28,11 +28,12 @@ const ( ) func checkContextUser(ctx *middleware.Context, uid int64) *models.User { - if err := ctx.User.GetOrganizations(); err != nil { - ctx.Handle(500, "GetOrganizations", err) + orgs, err := models.GetOwnedOrgsByUserIDDesc(ctx.User.Id, "updated") + if err != nil { + ctx.Handle(500, "GetOwnedOrgsByUserIDDesc", err) return nil } - ctx.Data["Orgs"] = ctx.User.Orgs + ctx.Data["Orgs"] = orgs // Not equal means current user is an organization. if uid == ctx.User.Id || uid == 0 { @@ -198,7 +199,8 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) { } if strings.Contains(err.Error(), "Authentication failed") || - strings.Contains(err.Error(), " not found") { + strings.Contains(err.Error(), " not found") || + strings.Contains(err.Error(), "could not read Username") { ctx.Data["Err_Auth"] = true ctx.RenderWithErr(ctx.Tr("form.auth_failed", strings.Replace(err.Error(), ":"+form.AuthPassword+"@", ":<password>@", 1)), MIGRATE, &form) return |