Skip to content

Commit

Permalink
Merge pull request #4571 from unisonweb/mention-upgrade-scratch-file-…
Browse files Browse the repository at this point in the history
…name

feat: mention the name of the file we put failed upgrades in
  • Loading branch information
aryairani authored Jan 8, 2024
2 parents a643a8e + b2737a6 commit 3b9b813
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
10 changes: 5 additions & 5 deletions unison-cli/src/Unison/Codebase/Editor/HandleInput/Upgrade.hs
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ handleUpgrade oldDepName newDepName = do
maybePath <-
if isTranscript
then pure Nothing
else do
else fmap Just do
maybeLatestFile <- Cli.getLatestFile
case maybeLatestFile of
Nothing -> pure (Just "scratch.u")
Just (file, _) -> pure (Just file)
pure case maybeLatestFile of
Nothing -> "scratch.u"
Just (file, _) -> file
Cli.respond (Output.DisplayDefinitionsString maybePath prettyUnisonFile)
Cli.respond (Output.UpgradeFailure oldDepName newDepName)
Cli.respond (Output.UpgradeFailure (fromMaybe "scratch.u" maybePath) oldDepName newDepName)
Cli.returnEarlyWithoutOutput

branchUpdates <-
Expand Down
2 changes: 1 addition & 1 deletion unison-cli/src/Unison/Codebase/Editor/Output.hs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ data Output
| UpdateTypecheckingFailure
| UpdateTypecheckingSuccess
| UpdateIncompleteConstructorSet UpdateOrUpgrade Name (Map ConstructorId Name) (Maybe Int)
| UpgradeFailure !NameSegment !NameSegment
| UpgradeFailure !FilePath !NameSegment !NameSegment
| UpgradeSuccess !NameSegment !NameSegment

data UpdateOrUpgrade = UOUUpdate | UOUUpgrade
Expand Down
4 changes: 3 additions & 1 deletion unison-cli/src/Unison/CommandLine/OutputMessages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2183,12 +2183,14 @@ notifyUser dir = \case
<> operationName
<> "again."
]
UpgradeFailure old new ->
UpgradeFailure path old new ->
pure . P.wrap $
"I couldn't automatically upgrade"
<> P.text (NameSegment.toText old)
<> "to"
<> P.group (P.text (NameSegment.toText new) <> ".")
<> "However, I've added the definitions that need attention to the top of"
<> P.group (prettyFilePath path <> ".")
UpgradeSuccess old new ->
pure . P.wrap $
"I upgraded"
Expand Down
4 changes: 3 additions & 1 deletion unison-src/transcripts/fix4482.output.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ myproj/main> upgrade foo0 foo1
use lib.foo0.lib.bonk1 bar
##Nat.+ bar bar
I couldn't automatically upgrade foo0 to foo1.
I couldn't automatically upgrade foo0 to foo1. However, I've
added the definitions that need attention to the top of
scratch.u.
```
4 changes: 3 additions & 1 deletion unison-src/transcripts/upgrade-sad-path.output.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ proj/main> upgrade old new
use Nat +
foo + 10
I couldn't automatically upgrade old to new.
I couldn't automatically upgrade old to new. However, I've
added the definitions that need attention to the top of
scratch.u.
```

0 comments on commit 3b9b813

Please sign in to comment.