Skip to content
Permalink
Browse files

Parse ref and rev in git

  • Loading branch information
nmattia committed Nov 30, 2019
1 parent 5faeb0a commit dfc838aba2b955e25e319720078d81b79d478e45
Showing with 16 additions and 5 deletions.
  1. +1 −1 nix/sources.nix
  2. +14 −3 src/Niv/Git/Cmd.hs
  3. +1 −1 src/Niv/Sources.hs
@@ -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
@@ -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
@@ -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

0 comments on commit dfc838a

Please sign in to comment.
You can’t perform that action at this time.