Skip to content

Commit

Permalink
Properly parse versions with the dirty flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Jul 11, 2022
1 parent 79aa93f commit 881411f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion unison-cli/src/Unison/Codebase/Editor/VersionParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ import qualified Unison.Codebase.Path as Path
--
-- >>> parseMaybe defaultBaseLib "latest-1234"
-- Just (ReadShareRemoteNamespace {server = DefaultCodeserver, repo = "unison", path = public.base.main})
--
-- A version with the 'dirty' flag
-- >>> parseMaybe defaultBaseLib "release/M3-409-gbcdf68db3'"
-- Nothing
defaultBaseLib :: Parsec Void Text ReadShareRemoteNamespace
defaultBaseLib = fmap makeNS $ latest <|> release
where
latest, release, version :: Parsec Void Text Text
latest = "latest-" *> many anySingle *> eof $> "main"
release = fmap ("releases._" <>) $ "release/" *> version <* eof
version = do
Text.pack <$> some (alphaNumChar <|> ('_' <$ oneOf ['.', '_', '-']))
v <- Text.pack <$> some (alphaNumChar <|> ('_' <$ oneOf ['.', '_', '-']))
_dirty <- optional (char '\'')
pure v
makeNS :: Text -> ReadShareRemoteNamespace
makeNS t =
ReadShareRemoteNamespace
Expand Down
3 changes: 3 additions & 0 deletions unison-cli/src/Unison/CommandLine/Welcome.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ data Welcome = Welcome
data DownloadBase
= DownloadBase ReadShareRemoteNamespace
| DontDownloadBase
deriving (Show, Eq)

-- Previously Created is different from Previously Onboarded because a user can
-- 1.) create a new codebase
Expand All @@ -35,6 +36,7 @@ data DownloadBase
data CodebaseInitStatus
= NewlyCreatedCodebase -- Can transition to [Base, Author, Finished]
| PreviouslyCreatedCodebase -- Can transition to [Base, Author, Finished, PreviouslyOnboarded].
deriving (Show, Eq)

data Onboarding
= Init CodebaseInitStatus -- Can transition to [DownloadingBase, Author, Finished, PreviouslyOnboarded]
Expand All @@ -43,6 +45,7 @@ data Onboarding
-- End States
| Finished
| PreviouslyOnboarded
deriving (Show, Eq)

welcome :: CodebaseInitStatus -> DownloadBase -> FilePath -> Text -> Welcome
welcome initStatus downloadBase filePath unisonVersion =
Expand Down
4 changes: 2 additions & 2 deletions unison-cli/unison/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import ArgParse
Command (Init, Launch, PrintVersion, Run, Transcript),
GlobalOptions (GlobalOptions, codebasePathOption, exitOption),
IsHeadless (Headless, WithCLI),
ShouldExit(Exit, DoNotExit),
RunSource (..),
ShouldDownloadBase (..),
ShouldExit (DoNotExit, Exit),
ShouldForkCodebase (..),
ShouldSaveCodebase (..),
UsageRenderer,
Expand Down Expand Up @@ -212,7 +212,7 @@ main = withCP65001 do
getCodebaseOrExit mCodePathOption \(initRes, _, theCodebase) -> do
runtime <- RTI.startRuntime RTI.Persistent Version.gitDescribeWithDate
Server.startServer (Backend.BackendEnv {Backend.useNamesIndex = False}) codebaseServerOpts runtime theCodebase $ \baseUrl -> do
case exitOption of
case exitOption of
DoNotExit -> do
case isHeadless of
Headless -> do
Expand Down

0 comments on commit 881411f

Please sign in to comment.