1
1
mirror of https://github.com/nmattia/niv.git synced 2024-11-07 22:36:53 +03:00

Merge pull request #47 from nmattia/nm-missing-repo

Warn if GitHub repository cannot be read
This commit is contained in:
Nicolas Mattia 2019-04-11 09:57:24 +02:00 committed by GitHub
commit 7aa070d8b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -209,7 +209,8 @@ completePackageSpec = execStateT $ do
(Just (Aeson.String owner), Just (Aeson.String repo)) -> do
liftIO (GH.executeRequest' $ GH.repositoryR (GH.N owner) (GH.N repo))
>>= \case
Left _ -> pure ()
Left {} ->
liftIO $ warnCouldNotFetchGitHubRepo (T.unpack owner, T.unpack repo)
Right ghRepo -> do
-- Description
@ -664,6 +665,29 @@ pathNixSourcesJson = "nix" </> "sources.json"
initNixSourcesJsonContent :: B.ByteString
initNixSourcesJsonContent = "{}"
-------------------------------------------------------------------------------
-- Warn
-------------------------------------------------------------------------------
warnCouldNotFetchGitHubRepo :: (String, String) -> IO ()
warnCouldNotFetchGitHubRepo (owner, repo) = putStrLn $ unlines [ line1, line2 ]
where
line1 = "WARNING: Could not read from GitHub repo: " <> owner <> "/" <> repo
line2 = [s|
I assumed that your package was a GitHub repository. An error occurred while
gathering information from the repository. Check whether your package was added
correctly:
niv show
If not, try re-adding it:
niv drop <package>
niv add <package-without-typo>
Make sure the repository exists.
|]
-------------------------------------------------------------------------------
-- Abort
-------------------------------------------------------------------------------