-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Abstract hash function usage #28138
Abstract hash function usage #28138
Conversation
77b2a5c
to
a31fba9
Compare
a31fba9
to
3e22d34
Compare
"no-op". |
3e22d34
to
38807ae
Compare
Let's keep a true no-op. We can change database in other commits. I've now pushed a change here that doesn't require a change in database. If you see anything that does, please point it out and I will move it out. |
44bd4fc
to
05a23b8
Compare
05a23b8
to
bf9dc4c
Compare
bf9dc4c
to
29250ba
Compare
I've gone over the patch and renamed things as requested and did some further refactoring. Please let me know if I've missed something.. Locally, I've run integration unit tests against mssql container and regular backend unit tests, so hopefully things will pass against other backends. |
Just out of curiosity, is the test build failure because of some desync on the test end or something else? I can build locally with TAGS="gogit sqlite ..." and also TAGS="nogogit sqlite .." while some of the bots are getting compilation errors. I'm confused. |
How do you build locally? What if you introduce some explict errors in the "gogit" files? The CI still says that the errors are related to gogit. |
Wow, what a big refactor. I think https://github.com/go-gitea/gitea/pull/28138/files#r1424969756 is the only one I want to know. |
Refactor SHA1 interfaces and centralize the hash function. This will allow easier introduction of different hash function later on.
c0140fa
to
fd090c8
Compare
|
This issue should be fixed now. There are plenty of other, tangential refactors that can be done with these changes but these can be done at a smaller pace. |
Thanks @wxiaoguang , seems I was doing it wrong and re-basing on top of main while I should be adding new commits and merges (when conflicts arise) instead. |
* giteaofficial/main: Abstract hash function usage (go-gitea#28138) Add endpoint for not implemented Docker auth (go-gitea#28457) docs: Update group membership fields to match application. (go-gitea#28175)
type ObjectFormatID int | ||
|
||
const ( | ||
Sha1 ObjectFormatID = iota |
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.
Why it needs "integer" number?
I think type ObjectFormat string
and Sha1 = "sha1"
work better?
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 think so.
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.
There is another function that does this from string
already, at the bottom of the file.
git.ObjectFormatFromString()
Basically, there is no need for this to be int or string in particular, but I wanted to move at least temporarily away from string to catch errors like passing "SHA1" vs. "sha1".
Finally, maybe my prejudice shows, coming from C and C++ world shows, where enums are ints 😄
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.
Refactor Hash interfaces and centralize hash function. This will allow easier introduction of different hash function later on. This forms the "no-op" part of the SHA256 enablement patch.
Currently only SHA1 repositories are supported by Gitea. This adds support for alternate SHA256 with the additional aim of easier support for additional hash types in the future. Fixes: #13794 Limited by: go-git/go-git#899 Depend on: #28138 <img width="776" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/5448c9a7-608e-4341-a149-5dd0069c9447"> --------- Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: 6543 <[email protected]>
Refactor Hash interfaces and centralize hash function. This will allow easier introduction of different hash function later on. This forms the "no-op" part of the SHA256 enablement patch.
Currently only SHA1 repositories are supported by Gitea. This adds support for alternate SHA256 with the additional aim of easier support for additional hash types in the future. Fixes: go-gitea#13794 Limited by: go-git/go-git#899 Depend on: go-gitea#28138 <img width="776" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/5448c9a7-608e-4341-a149-5dd0069c9447"> --------- Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: 6543 <[email protected]>
Currently only SHA1 repositories are supported by Gitea. This adds support for alternate SHA256 with the additional aim of easier support for additional hash types in the future. Fixes: go-gitea#13794 Limited by: go-git/go-git#899 Depend on: go-gitea#28138 <img width="776" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/5448c9a7-608e-4341-a149-5dd0069c9447"> --------- Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: 6543 <[email protected]>
Refactor Hash interfaces and centralize hash function. This will allow easier introduction of different hash function later on. This forms the "no-op" part of the SHA256 enablement patch.
Currently only SHA1 repositories are supported by Gitea. This adds support for alternate SHA256 with the additional aim of easier support for additional hash types in the future. Fixes: go-gitea#13794 Limited by: go-git/go-git#899 Depend on: go-gitea#28138 <img width="776" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/5448c9a7-608e-4341-a149-5dd0069c9447"> --------- Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: 6543 <[email protected]>
There's a miss in #28138: ![image](https://github.com/go-gitea/gitea/assets/18380374/b1e0c5fc-0e6e-44ab-9f6e-34bc8ffbe1cc) https://github.com/go-gitea/gitea/pull/28138/files#diff-2556e62ad7204a230c91927a3f2115e25a2b688240d0ee1de6d34f0277f37dfeR162 @lunny Not sure about the impact of this, but it will only effect 1.22, and maybe we should fix it ASAP. Co-authored-by: KN4CK3R <[email protected]>
* giteaofficial/main: Fix mail template error (go-gitea#29410) Document our issue locking policy (go-gitea#29433) Fix htmx rendering the login page in frame on session logout (go-gitea#29405) Ignore empty repo for CreateRepository in action notifier (go-gitea#29416) Fix incorrect tree path value for patch editor (go-gitea#29377) Fix logic error from go-gitea#28138 (go-gitea#29417)
_, _ = h.Write([]byte(" ")) | ||
_, _ = h.Write([]byte(strconv.FormatInt(int64(len(content)), 10))) | ||
_, _ = h.Write([]byte{0}) | ||
return h.HashSum() |
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.
Here and below, a regression ..... the "content" is not written into the hasher 😭
-> Fix incorrect object id hash function #30708
Refactor Hash interfaces and centralize hash function. This will allow easier introduction of different hash function later on.
This forms the "no-op" part of the SHA256 enablement patch.