-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Allow branch names longer than 7 characters #3750
Conversation
@unknwon please let me know what I need to change for this to be merged. |
The regex was matching any string that was between 7 and 40 characters and treating them as SHAs. For branch names that were 7 characters or longer this causes strange behavior and makes PRs impossible. This update makes it so that only 40 character strings are treated as SHAs.
89aecc3
to
b5756f6
Compare
@unknwon ping, this would be really nice to get corrected. |
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.
Hi @samuelson
I have pull your branch for testing. It seems you have modified too many lines as needed and the SHA1 regexp is not correct.
Thanks.
|
||
m.Get("/compare/:before([a-z0-9]{7,40})\\.\\.\\.:after([a-z0-9]{7,40})", repo.CompareDiff) | ||
m.Get("/compare/:before([a-z0-9]{40})\\.\\.\\.:after([a-z0-9]{40})", repo.CompareDiff) |
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.
I agree. It's the root of your problem.
m.Get("/forks", repo.Forks) | ||
}, context.RepoRef()) | ||
m.Get("/commit/:sha([a-z0-9]{7,40})\\.:ext(patch|diff)", repo.RawDiff) | ||
m.Get("/commit/:sha([a-z0-9]{40})\\.:ext(patch|diff)", repo.RawDiff) |
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.
This modification don't fix your issue. But the regexp is not correct : valid SHA1 only contains a b c d e f 0 1 2 3 4 5 6 7 8 9 characters. Could you replace :sha([a-z0-9]{7,40})
with :sha([a-f0-9]{7,40})
please.
@@ -585,12 +585,12 @@ func runWeb(ctx *cli.Context) error { | |||
m.Get("/src/*", repo.Home) | |||
m.Get("/raw/*", repo.SingleDownload) | |||
m.Get("/commits/*", repo.RefCommits) | |||
m.Get("/commit/:sha([a-z0-9]{7,40})$", repo.Diff) | |||
m.Get("/commit/:sha([a-z0-9]{40})$", repo.Diff) |
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.
This modification don't fix your issue. In fact this route is not used when you call URL like http://domain.local/zero-x-baadf00d/test/compare/production...production
But the regexp is not correct : valid SHA1 only contains a b c d e f 0 1 2 3 4 5 6 7 8 9 characters. Could you replace :sha([a-z0-9]{7,40})
with :sha([a-f0-9]{7,40})
please.
Ping @samuelson |
@0xBAADF00D sorry for the delay, it turns out I had notifications disabled. I updated with the changes you suggested. |
@samuelson please consider sending this PR to https://github.com/go-gitea/gitea |
@strk looks like it's already fixed: https://github.com/go-gitea/gitea/blob/master/cmd/web.go#L592 |
This is the same, go ahead an merge that one: #3851 |
Resolves #3743
This fixed the issue for me, but I don't know if it will have some other unintended consequences.