Skip to content

Commit

Permalink
Merge pull request #4665 from unisonweb/cp/hash-mismatch-message
Browse files Browse the repository at this point in the history
Add message for share hash mismatch
  • Loading branch information
aryairani authored Feb 2, 2024
2 parents ab7d33e + 56d1962 commit 4eb0147
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions unison-cli/src/Unison/CommandLine/OutputMessages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ import Unison.Var qualified as Var
import Unison.WatchKind qualified as WK
import Witch (unsafeFrom)

reportBugURL :: Pretty
reportBugURL = "https://github.com/unisonweb/unison/issues/new"

type Pretty = P.Pretty P.ColorText

shortenDirectory :: FilePath -> IO FilePath
Expand Down Expand Up @@ -1953,15 +1956,15 @@ notifyUser dir = \case
prettyProjectAndBranchName projectAndBranch <> "does not exist on" <> prettyURI host
RemoteProjectBranchDoesntExist'Push host projectAndBranch ->
let push = P.group . P.backticked . IP.patternName $ IP.push
in pure . P.wrap $
"The previous push target named"
<> prettyProjectAndBranchName projectAndBranch
<> "has been deleted from"
<> P.group (prettyURI host <> ".")
<> "I've deleted the invalid push target."
<> "Run the"
<> push
<> "command again to push to a new target."
in pure . P.wrap $
"The previous push target named"
<> prettyProjectAndBranchName projectAndBranch
<> "has been deleted from"
<> P.group (prettyURI host <> ".")
<> "I've deleted the invalid push target."
<> "Run the"
<> push
<> "command again to push to a new target."
RemoteProjectBranchHeadMismatch host projectAndBranch ->
pure . P.wrap $
prettyProjectAndBranchName projectAndBranch
Expand Down Expand Up @@ -2316,7 +2319,8 @@ prettyUpdatePathError repoInfo = \case
prettyUploadEntitiesError :: Share.UploadEntitiesError -> Pretty
prettyUploadEntitiesError = \case
Share.UploadEntitiesError'EntityValidationFailure validationFailureErr -> prettyValidationFailure validationFailureErr
Share.UploadEntitiesError'HashMismatchForEntity _hashMismatch -> error "TODO: hash mismatch error message"
Share.UploadEntitiesError'HashMismatchForEntity (Share.HashMismatchForEntity {supplied, computed}) ->
hashMismatchFromShare supplied computed
Share.UploadEntitiesError'InvalidRepoInfo err repoInfo -> invalidRepoInfo err repoInfo
Share.UploadEntitiesError'NeedDependencies dependencies -> needDependencies dependencies
Share.UploadEntitiesError'NoWritePermission repoInfo -> noWritePermissionForRepo repoInfo
Expand Down Expand Up @@ -2446,6 +2450,18 @@ invalidRepoInfo err repoInfo =
P.text err
]

hashMismatchFromShare :: Hash32 -> Hash32 -> Pretty
hashMismatchFromShare supplied computed =
P.lines
[ P.wrap "Uh oh, Share double-checked the hash of something you're uploading and it didn't match.",
P.wrap "Don't worry, you didn't do anything wrong, this is a bug in UCM, please report it and we'll do our best to sort it out 🤞",
reportBugURL,
"",
"Please include the following information in your report:",
P.wrap $ "The hash provided by your UCM is: " <> prettyHash32 supplied,
P.wrap $ "The hash computed by Share is: " <> prettyHash32 computed
]

pushPublicNote :: InputPattern -> Text -> [Text] -> Pretty
pushPublicNote cmd uname ys =
let msg =
Expand Down

0 comments on commit 4eb0147

Please sign in to comment.