Skip to content
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

Fix 500 when repo has invalid .editorconfig #59

Merged
merged 1 commit into from
Nov 5, 2016
Merged

Fix 500 when repo has invalid .editorconfig #59

merged 1 commit into from
Nov 5, 2016

Conversation

andreynering
Copy link
Contributor

Creating a notice instead

Fixes gogs/gogs#3643

@codecov-io
Copy link

codecov-io commented Nov 3, 2016

Current coverage is 2.18% (diff: 100%)

Merging #59 into master will not change coverage

@@            master       #59   diff @@
========================================
  Files           31        31          
  Lines         7508      7508          
  Methods          0         0          
  Messages         0         0          
  Branches         0         0          
========================================
  Hits           164       164          
  Misses        7327      7327          
  Partials        17        17          

Powered by Codecov. Last update ab12596...984fa8d

Copy link
Member

@bkcsoft bkcsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use setEditorconfigIfExists as a middleware instead of a function?

ec, err := ctx.Repo.GetEditorconfig()
if err != nil && !git.IsErrNotExist(err) {
ctx.Handle(500, "ErrGettingEditorconfig", err)
setEditorconfigIfExists(ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be in the router instead of in the route?

ec, err := ctx.Repo.GetEditorconfig()
if err != nil && !git.IsErrNotExist(err) {
ctx.Handle(500, "ErrGettingEditorconfig", err)
setEditorconfigIfExists(ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This as well?

ec, err := ctx.Repo.GetEditorconfig()
if err != nil && !git.IsErrNotExist(err) {
ctx.Handle(500, "Repo.GetEditorconfig", err)
setEditorconfigIfExists(ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this

ec, err := ctx.Repo.GetEditorconfig()
if err != nil && !git.IsErrNotExist(err) {
ctx.Handle(500, "ErrGettingEditorconfig", err)
setEditorconfigIfExists(ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here 🙂

@xinity xinity added the type/bug label Nov 4, 2016
@xinity xinity added this to the 1.0.0 milestone Nov 4, 2016
@strk
Copy link
Member

strk commented Nov 4, 2016

Any chance you could add a test for this ?
I've tried this locally and confirm the bug and the fix, but I hadn't found where the notice about broken .editorconfig was sent. Where should I look ?

Other than that, LGTM

@andreynering
Copy link
Contributor Author

@strk

See the original issue gogs/gogs#3643

To add a test, we should first have a mock of the git interface, or a real git repo, since this touch git. It's something for the future.

Also, how and why did you add two commits to this PR?

@strk
Copy link
Member

strk commented Nov 4, 2016

I've added two commits by clicking "Update branch" button in github interface. I belive another button will let me rebase/squash before merge. Will try right now, as this LGTM (ok for postponing test)

@strk
Copy link
Member

strk commented Nov 4, 2016

Uhm, it takes a second LGTM, mine was already counted

@tboerger
Copy link
Member

tboerger commented Nov 4, 2016

Needs a rebase.

@strk
Copy link
Member

strk commented Nov 4, 2016

Rebase can be done via github button, as long as LGTM passes

@tboerger
Copy link
Member

tboerger commented Nov 5, 2016

Rebase can be done via github button, as long as LGTM passes

Nope, there is no button to update, so maybe there are merge conflicts.

@strk
Copy link
Member

strk commented Nov 5, 2016

Yup, looks like being the case, @andreynering can you manually rebase and resolve conflicts (then I guess it'll need another LGTM round ?)

@strk
Copy link
Member

strk commented Nov 5, 2016

Merging manually shows no conflicts, should I try pushing the merge via commandline ?

@tboerger
Copy link
Member

tboerger commented Nov 5, 2016

The branch is out of sync, that's why this can only be done by admins, but we should avoid that.

@strk
Copy link
Member

strk commented Nov 5, 2016

I remember having seen an "Update branch" button in other PRs, when they were out of sync, did any configuration change about that ? (or maybe the branch owner had the branch protected..)

@strk strk merged commit 789dacd into go-gitea:master Nov 5, 2016
@tboerger tboerger added the lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. label Nov 29, 2016
lunny pushed a commit to lunny/gitea that referenced this pull request Feb 7, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid data in .editorconfig will result in 500 error page
6 participants