1
1
mirror of https://github.com/nmattia/niv.git synced 2024-09-18 19:07:19 +03:00

Parse ref and rev in git

This commit is contained in:
Nicolas Mattia 2019-11-30 12:36:23 +01:00
parent 5faeb0a621
commit dfc838aba2
3 changed files with 16 additions and 5 deletions

View File

@ -19,7 +19,7 @@ let
pkgs.fetchzip { inherit (spec) url sha256; };
fetch_git = spec:
builtins.fetchGit { url = spec.repo; inherit (spec) rev; };
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
fetch_builtin-tarball = spec:
builtins.trace

View File

@ -7,6 +7,7 @@
module Niv.Git.Cmd (gitCmd) where
import Control.Arrow
import Control.Applicative
import Data.String.QQ (s)
import Data.Text.Extended as T
import Niv.Cmd
@ -32,14 +33,24 @@ gitCmd = Cmd
-- TODO: don't hardcode here
parseGitPackageSpec :: Opts.Parser PackageSpec
parseGitPackageSpec =
(PackageSpec . HMS.singleton "repo") <$>
parseRepo
(PackageSpec . HMS.fromList) <$>
many (parseRepo <|> parseRef <|> parseRev)
where
parseRepo =
Aeson.String <$> Opts.strOption
("repo", ) . Aeson.String <$> Opts.strOption
( Opts.long "repo" <>
Opts.metavar "URL"
)
parseRev =
("rev", ) . Aeson.String <$> Opts.strOption
( Opts.long "rev" <>
Opts.metavar "SHA"
)
parseRef =
("ref", ) . Aeson.String <$> Opts.strOption
( Opts.long "ref" <>
Opts.metavar "REF"
)
describeGit :: Opts.InfoMod a
describeGit = mconcat

View File

@ -176,7 +176,7 @@ sourcesVersionToMD5 = \case
V9 -> "87149616c1b3b1e5aa73178f91c20b53"
V10 -> "d8625c0a03dd935e1c79f46407faa8d3"
V11 -> "8a95b7d93b16f7c7515d98f49b0ec741"
V12 -> "b42c201152bb6d93c6c24388e3cf3249"
V12 -> "2f9629ad9a8f181ed71d2a59b454970c"
-- | The MD5 sum of ./nix/sources.nix
sourcesNixMD5 :: IO T.Text