-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Fix 500 when repo has invalid .editorconfig #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package repo | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/go-gitea/gitea/models" | ||
"github.com/go-gitea/gitea/modules/context" | ||
"github.com/gogits/git-module" | ||
) | ||
|
||
func setEditorconfigIfExists(ctx *context.Context) { | ||
ec, err := ctx.Repo.GetEditorconfig() | ||
|
||
if err != nil && !git.IsErrNotExist(err) { | ||
description := fmt.Sprintf("Error while getting .editorconfig file: %v", err) | ||
if err := models.CreateRepositoryNotice(description); err != nil { | ||
ctx.Handle(500, "ErrCreatingReporitoryNotice", err) | ||
} | ||
return | ||
} | ||
|
||
ctx.Data["Editorconfig"] = ec | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -368,12 +368,10 @@ func ViewPullFiles(ctx *context.Context) { | |
return | ||
} | ||
|
||
ec, err := ctx.Repo.GetEditorconfig() | ||
if err != nil && !git.IsErrNotExist(err) { | ||
ctx.Handle(500, "ErrGettingEditorconfig", err) | ||
setEditorconfigIfExists(ctx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be in the router instead of in the route? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This as well? |
||
if ctx.Written() { | ||
return | ||
} | ||
ctx.Data["Editorconfig"] = ec | ||
|
||
headTarget := path.Join(pull.HeadUserName, pull.HeadRepo.Name) | ||
ctx.Data["IsSplitStyle"] = ctx.Query("style") == "split" | ||
|
@@ -627,12 +625,10 @@ func CompareAndPullRequest(ctx *context.Context) { | |
} | ||
} | ||
|
||
ec, err := ctx.Repo.GetEditorconfig() | ||
if err != nil && !git.IsErrNotExist(err) { | ||
ctx.Handle(500, "ErrGettingEditorconfig", err) | ||
setEditorconfigIfExists(ctx) | ||
if ctx.Written() { | ||
return | ||
} | ||
ctx.Data["Editorconfig"] = ec | ||
|
||
ctx.HTML(200, COMPARE_PULL) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,12 +245,10 @@ func Home(ctx *context.Context) { | |
return | ||
} | ||
|
||
ec, err := ctx.Repo.GetEditorconfig() | ||
if err != nil && !git.IsErrNotExist(err) { | ||
ctx.Handle(500, "Repo.GetEditorconfig", err) | ||
setEditorconfigIfExists(ctx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this |
||
if ctx.Written() { | ||
return | ||
} | ||
ctx.Data["Editorconfig"] = ec | ||
|
||
var treeNames []string | ||
paths := make([]string, 0, 5) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here 🙂