-
Notifications
You must be signed in to change notification settings - Fork 271
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
Provide mechanism for hashing BranchFormatFull #4261
Conversation
@@ -1,6 +1,41 @@ | |||
{-# LANGUAGE RecordWildCards #-} | |||
|
|||
module U.Codebase.Sqlite.Serialization where | |||
module U.Codebase.Sqlite.Serialization | |||
( decomposeBranchFormat, |
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.
Added an export list for my own sanity of scanning what the module contains.
I generalized some combinators in this module as I was iterating on it, ended up that the only thing I needed was to pull out getLocalBranch
to a top-level-definition and export that. I could re-specialize the parsers, but the generalized versions may come in handy in the future.
@@ -2,6 +2,10 @@ module U.Codebase.HashTags where | |||
|
|||
import Unison.Hash (Hash) | |||
|
|||
-- | Represents a hash of a type or term component | |||
newtype ComponentHash = ComponentHash {unComponentHash :: Hash} |
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'm surprised we didn't have a tag for this already, there are a lot of spots we should likely be using it. I added something like this into Enlil for my pg name-lookup stuff, but it should really just be part of unison core.
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.
Nice!
Overview
Pre-req for https://github.com/unisoncomputing/enlil/pull/314;
Generalizes how we deserialize BranchFormat's so I can deserialize entities from the Temp/Sync entity formats BEFORE saving them into the codebase (i.e. before we have object or db IDs)
This will allow Share to correctly validate hashes on branches before storing them into a user's codebase.
Implementation notes
hashBranchFormatFull
to HashHandle which produces a hash for a LocalBranch if provided hash references in a local ID mappinghashBranchFormatToH2Branch :: Memory.BranchFull.HashBranch -> HashingV2.Branch
internally to facilitate hashing branch formats.ComponentHash
hash tag for hashes used in references/referentsInteresting/controversial decisions
Include anything that you thought twice about, debated, chose arbitrarily, etc.
What could have been done differently, but wasn't? And why?
Test coverage
Tested locally as part of https://github.com/unisoncomputing/enlil/pull/314;