Skip to content

Commit

Permalink
Merge pull request #3212 from unisonweb/cp/fix-base-path
Browse files Browse the repository at this point in the history
Fix base-pull location
  • Loading branch information
mergify[bot] committed Jul 11, 2022
2 parents 1f48861 + 881411f commit 6a18f05
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
18 changes: 12 additions & 6 deletions unison-cli/src/Unison/Codebase/Editor/VersionParser.hs
Expand Up @@ -14,25 +14,31 @@ import qualified Unison.Codebase.Path as Path
-- | Parse git version strings into valid unison namespaces.
--
-- >>> parseMaybe defaultBaseLib "release/M1j"
-- Just (ReadShareRemoteNamespace {server = DefaultCodeserver, repo = "unison", path = public.dev.base.releases._M1j})
-- Just (ReadShareRemoteNamespace {server = DefaultCodeserver, repo = "unison", path = public.base.releases._M1j})
--
-- >>> parseMaybe defaultBaseLib "release/M1j.2"
-- Just (ReadShareRemoteNamespace {server = DefaultCodeserver, repo = "unison", path = public.dev.base.releases._M1j_2})
-- Just (ReadShareRemoteNamespace {server = DefaultCodeserver, repo = "unison", path = public.base.releases._M1j_2})
--
-- >>> parseMaybe defaultBaseLib "latest-1234"
-- Just (ReadShareRemoteNamespace {server = DefaultCodeserver, repo = "unison", path = public.dev.base.trunk})
-- 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 $> "trunk"
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
{ server = DefaultCodeserver,
repo = "unison",
path = "public" Path.:< "dev" Path.:< "base" Path.:< Path.fromText t
path = "public" Path.:< "base" Path.:< Path.fromText t
}
3 changes: 3 additions & 0 deletions unison-cli/src/Unison/CommandLine/Welcome.hs
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/tests/Unison/Test/VersionParser.hs
Expand Up @@ -15,7 +15,7 @@ test =
scope "versionparser" . tests . fmap makeTest $
[ ("release/M1j", "releases._M1j"),
("release/M1j.2", "releases._M1j_2"),
("latest-abc", "trunk"),
("latest-abc", "main"),
("release/M2i_3", "releases._M2i_3"),
("release/M2i-HOTFIX", "releases._M2i_HOTFIX")
]
Expand All @@ -29,7 +29,7 @@ makeTest (version, path) =
( ReadShareRemoteNamespace
{ server = DefaultCodeserver,
repo = "unison",
path = Path.fromList ["public", "dev", "base"] <> Path.fromText path
path = Path.fromList ["public", "base"] <> Path.fromText path
}
)
)
4 changes: 2 additions & 2 deletions unison-cli/unison/Main.hs
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 6a18f05

Please sign in to comment.