packages feed

update-nix-fetchgit 0.2.5 → 0.2.7

raw patch · 11 files changed

+144/−35 lines, 11 filesdep ~hnix

Dependency ranges changed: hnix

Files

CHANGELOG.md view
@@ -2,6 +2,15 @@  ## WIP +## [0.2.7] - 2021-05-23++- `hnix-0.13` support++## [0.2.6] - 2021-05-17++- `git ls-remote` calls are printed in verbose mode+- Small packaging changes+ ## [0.2.5] - 2020-11-14  - Pass `--heads --tags` to `git ls-remote` to avoid fetching remote
README.md view
@@ -18,6 +18,7 @@ - `builtins.fetchTarball` (Only updates the url when this is a archive fetch   from GitHub) - `pkgs.haskellPackages.callHackageDirect` (Only updates the hash)+- `fetchurl` (Only updates the hash)  The options `deepClone`, `leaveDotGit`, `fetchSubmodules` are also supported. 
app/Main.hs view
@@ -127,6 +127,3 @@ instance ParseField Regex where   metavar _ = "REGEX"   readField = eitherReader makeRegexM--instance (e ~ String) => MonadFail (Either e) where-  fail = Left
default.nix view
@@ -1,4 +1,5 @@-{ pkgs ? import ./nixpkgs.nix, compiler ? null }:+{ pkgs ? import ./nixpkgs.nix, compiler ? null, forShell ? pkgs.lib.inNixShell+}:  with pkgs; @@ -9,10 +10,16 @@ in hp.developPackage {   name = "update-nix-fetchgit";   root = nix-gitignore.gitignoreSource [ ] ./.;-  overrides = self: _super: {-    optparse-generic = self.optparse-generic_1_4_4;-    optparse-applicative = self.optparse-applicative_0_16_0_0;+  overrides = self: super: {+    hnix = pkgs.haskell.lib.dontCheck (self.callHackageDirect {+      pkg = "hnix";+      ver = "0.13.1";+      sha256 = "0v3r33azlv050fv8y5vw0pahdnch7vqq94viwrp9vlw8hpiys8qn";+    } { });+    relude = self.relude_1_0_0_1;+    semialign = self.semialign_1_2;   };   modifier = drv: haskell.lib.addBuildTools drv [ git nix nix-prefetch-git ];+  returnShellEnv = forShell; } 
package.yaml view
@@ -1,5 +1,5 @@ name: update-nix-fetchgit-version: "0.2.5"+version: "0.2.7" synopsis: A program to update fetchgit values in Nix expressions description: |   This command-line utility is meant to be used by people maintaining Nix@@ -46,7 +46,7 @@   - bytestring >= 0.10   - data-fix   - github-rest-  - hnix >= 0.11+  - hnix >= 0.13.1   - monad-validate   - mtl   - process >= 1.2@@ -62,6 +62,8 @@   update-nix-fetchgit-samples:     source-dirs: tests     main: Driver.hs+    build-tools:+    - tasty-discover     dependencies:     - base >= 4.7 && < 5     - directory
src/Nix/Match/Typed.hs view
@@ -201,8 +201,8 @@   -> Q (([T.Text], [T.Text]), Exp) typedMatcherGen parseNix collect add strip s = do   expr <- case parseNix (T.pack s) of-    Failure err -> fail $ show err-    Success e   -> pure e+    Left err -> fail $ show err+    Right e  -> pure e   let (opt, req) = collect expr       optT       = symbolList opt       reqT       = symbolList req
src/Update/Nix/FetchGit/Prefetch.hs view
@@ -53,7 +53,7 @@     ExitSuccess   -> pure ()   note (InvalidPrefetchGitOutput (pack nsStdout)) (decode (fromString nsStdout)) --- | Run nix-prefetch-url --unpack+-- | Run nix-prefetch-url nixPrefetchUrl   :: [Text] -- ^ Extra arguments for nix-prefetch-url   -> Text   -- ^ The URL to prefetch@@ -61,7 +61,7 @@ nixPrefetchUrl extraArgs prefetchURL = do   (exitCode, nsStdout, nsStderr) <- liftIO $ readProcessWithExitCode     "nix-prefetch-url"-    ("--unpack" : map unpack extraArgs ++ [unpack prefetchURL])+    (map unpack extraArgs ++ [unpack prefetchURL])     ""   case exitCode of     ExitFailure e -> refute1 (NixPrefetchUrlFailed e (pack nsStderr))@@ -111,16 +111,12 @@   let headsTags = if T.isPrefixOf "refs/" (unRevision revision)         then []         else ["--heads", "--tags"]-  (exitCode, nsStdout, nsStderr) <- liftIO $ readProcessWithExitCode-    "git"-    (  [ "ls-remote"-       , "--sort=-v:refname"-       , T.unpack repo-       , T.unpack (unRevision revision)-       ]-    <> headsTags-    )-    ""+      args =+        ["ls-remote", "--sort=-v:refname", repo, unRevision revision]+          <> headsTags :: [Text]+  logVerbose $ "Calling: git " <> T.unwords args+  (exitCode, nsStdout, nsStderr) <- liftIO+    $ readProcessWithExitCode "git" (T.unpack <$> args) ""   case exitCode of     ExitFailure e -> refute1 (NixPrefetchGitFailed e (pack nsStderr))     ExitSuccess   -> pure ()
src/Update/Nix/FetchGit/Utils.hs view
@@ -38,7 +38,7 @@                                                 ) import           Nix.Atoms                      ( NAtom(NBool) ) import           Nix.Expr                hiding ( SourcePos )-import           Nix.Parser                     ( Result(..)+import           Nix.Parser                     ( Result                                                 , parseNixFileLoc                                                 , parseNixTextLoc                                                 )@@ -48,13 +48,13 @@  ourParseNixText :: Text -> Either Warning NExprLoc ourParseNixText t = case parseNixTextLoc t of-  Failure parseError -> Left (CouldNotParseInput (tShow parseError))-  Success expr       -> pure expr+  Left parseError -> Left (CouldNotParseInput (tShow parseError))+  Right expr      -> pure expr  ourParseNixFile :: FilePath -> M NExprLoc ourParseNixFile f = liftIO (parseNixFileLoc f) >>= \case-  Failure parseError -> refute1 (CouldNotParseInput (tShow parseError))-  Success expr       -> pure expr+  Left parseError -> refute1 (CouldNotParseInput (tShow parseError))+  Right expr      -> pure expr  -- | Get the url from either a nix expression for the url or a repo and owner -- expression.
src/Update/Nix/Updater.hs view
@@ -36,6 +36,7 @@         , builtinsFetchGitUpdater         , fetchTarballGithubUpdater         , builtinsFetchTarballUpdater+        , fetchurlUpdater         , fetchGitHubUpdater         , hackageDirectUpdater         ]@@ -118,6 +119,20 @@       pure $ tarballUpdater url' sha256   _ -> Nothing +fetchurlUpdater :: Fetcher+fetchurlUpdater onlyCommented getComment = \case+  [matchNixLoc|+    ^fetcher {+      url = ^url; # [pin]+      sha256 = ^sha256;+    }|] | Just "fetchurl" <- extractFuncName fetcher+        , comment <- getComment url+        , onlyCommented ~> isJust comment+    -> Just $ do+      url' <- fromEither $ exprText url+      pure $ urlUpdater url' sha256+  _ -> Nothing+ fetchGitHubUpdater :: Fetcher fetchGitHubUpdater onlyCommented getComment = \case   [matchNixLoc|@@ -230,6 +245,17 @@   -- ^ sha256   -> Updater tarballUpdater url sha256Expr = Updater $ do+  logVerbose $ "Updating " <> url+  sha256 <- nixPrefetchUrl ["--unpack"] url+  pure (Nothing, [SpanUpdate (exprSpan sha256Expr) (quoteString sha256)])++urlUpdater+  :: Text+  -- ^ URL+  -> NExprLoc+  -- ^ sha256+  -> Updater+urlUpdater url sha256Expr = Updater $ do   logVerbose $ "Updating " <> url   sha256 <- nixPrefetchUrl [] url   pure (Nothing, [SpanUpdate (exprSpan sha256Expr) (quoteString sha256)])
tests/test_dotgit.expected.nix view
@@ -19,7 +19,7 @@   srcDeep = fetchgit {     url = "/tmp/nix-update-fetchgit-test/repo1";     rev = "1c60ae07b5740aab02e32b4f64600f002112e6fd";-    sha256 = "0xnazgn7p7xspda2wsfk1v1xrw9z5vvban0nhwd7xd3f70223gzz";+    sha256 = "1qw5y2n4a7i7f9mscqf4xwyxg5bn5cbrha797kdc7fcgjnhp5dy7";     deepClone = true;   }; }
update-nix-fetchgit.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.2.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack  name:           update-nix-fetchgit-version:        0.2.5+version:        0.2.7 synopsis:       A program to update fetchgit values in Nix expressions description:    This command-line utility is meant to be used by people maintaining Nix                 expressions that fetch files from Git repositories. It automates the process@@ -76,7 +76,30 @@       Paths_update_nix_fetchgit   hs-source-dirs:       src-  default-extensions: DataKinds DefaultSignatures DeriveAnyClass DeriveDataTypeable DeriveGeneric DerivingStrategies FlexibleContexts FlexibleInstances GADTs LambdaCase MultiParamTypeClasses OverloadedStrings PolyKinds RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskellQuotes TupleSections TypeApplications TypeFamilies TypeOperators ViewPatterns+  default-extensions:+      DataKinds+      DefaultSignatures+      DeriveAnyClass+      DeriveDataTypeable+      DeriveGeneric+      DerivingStrategies+      FlexibleContexts+      FlexibleInstances+      GADTs+      LambdaCase+      MultiParamTypeClasses+      OverloadedStrings+      PolyKinds+      RankNTypes+      RecordWildCards+      ScopedTypeVariables+      StandaloneDeriving+      TemplateHaskellQuotes+      TupleSections+      TypeApplications+      TypeFamilies+      TypeOperators+      ViewPatterns   ghc-options: -Wall   build-depends:       aeson >=0.9@@ -85,7 +108,7 @@     , bytestring >=0.10     , data-fix     , github-rest-    , hnix >=0.11+    , hnix >=0.13.1     , monad-validate     , mtl     , process >=1.2@@ -104,7 +127,30 @@       Paths_update_nix_fetchgit   hs-source-dirs:       app-  default-extensions: DataKinds DefaultSignatures DeriveAnyClass DeriveDataTypeable DeriveGeneric DerivingStrategies FlexibleContexts FlexibleInstances GADTs LambdaCase MultiParamTypeClasses OverloadedStrings PolyKinds RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskellQuotes TupleSections TypeApplications TypeFamilies TypeOperators ViewPatterns+  default-extensions:+      DataKinds+      DefaultSignatures+      DeriveAnyClass+      DeriveDataTypeable+      DeriveGeneric+      DerivingStrategies+      FlexibleContexts+      FlexibleInstances+      GADTs+      LambdaCase+      MultiParamTypeClasses+      OverloadedStrings+      PolyKinds+      RankNTypes+      RecordWildCards+      ScopedTypeVariables+      StandaloneDeriving+      TemplateHaskellQuotes+      TupleSections+      TypeApplications+      TypeFamilies+      TypeOperators+      ViewPatterns   ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N   build-depends:       base >=4.13@@ -124,8 +170,33 @@       Paths_update_nix_fetchgit   hs-source-dirs:       tests-  default-extensions: DataKinds DefaultSignatures DeriveAnyClass DeriveDataTypeable DeriveGeneric DerivingStrategies FlexibleContexts FlexibleInstances GADTs LambdaCase MultiParamTypeClasses OverloadedStrings PolyKinds RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskellQuotes TupleSections TypeApplications TypeFamilies TypeOperators ViewPatterns+  default-extensions:+      DataKinds+      DefaultSignatures+      DeriveAnyClass+      DeriveDataTypeable+      DeriveGeneric+      DerivingStrategies+      FlexibleContexts+      FlexibleInstances+      GADTs+      LambdaCase+      MultiParamTypeClasses+      OverloadedStrings+      PolyKinds+      RankNTypes+      RecordWildCards+      ScopedTypeVariables+      StandaloneDeriving+      TemplateHaskellQuotes+      TupleSections+      TypeApplications+      TypeFamilies+      TypeOperators+      ViewPatterns   ghc-options: -Wall+  build-tool-depends:+      tasty-discover:tasty-discover   build-depends:       base >=4.7 && <5     , directory