packages feed

update-nix-fetchgit 0.1.1.0 → 0.1.2.0

raw patch · 6 files changed

+48/−13 lines, 6 filesdep −data-fixdep −trifectaPVP ok

version bump matches the API change (PVP)

Dependencies removed: data-fix, trifecta

API changes (from Hackage documentation)

+ Update.Nix.FetchGit.Utils: GitLab :: Text -> Text -> RepoLocation

Files

CHANGELOG.md view
@@ -1,3 +1,9 @@+# Version [0.1.2.0](https://github.com/expipiplus1/update-nix-fetchgit/compare/0.1.1.0...0.1.2.0)++* Additions+  * Support updating `fetchFromGitLab`+  * Support updating `fetchgit` and `fetchgitPrivate+ # Version [0.1.1.0](https://github.com/expipiplus1/update-nix-fetchgit/compare/0.1.0.0...0.1.1.0)  * Changelog started. Previous release was `0.1.0.0`.
README.md view
@@ -5,7 +5,7 @@ When you run `update-nix-fetchgit` on a file, it will:  - Read the file and parse it as a Nix expression.-- Find all Git fetches (calls to `fetchgit`, `fetchgitPrivate`, or `fetchFromGitHub`).+- Find all Git fetches (calls to `fetchgit`, `fetchgitPrivate`, `fetchFromGitHub` or `fetchFromGitLab`). - Run [`nix-prefetch-git`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/fetchgit/nix-prefetch-git) to get information about the latest HEAD commit of each repository. - Update the corresponding rev, sha256, and version attributes for each repository. - Overwrite the original input file.
src/Update/Nix/FetchGit.hs view
@@ -73,11 +73,21 @@     || extractFuncName function == Just "fetchgitPrivate"     -> FetchNode <$> extractFetchGitArgs bindings -  -- Similarly, record calls to fetchFromGitHub.+  -- Similarly for builtins.fetchGit which needs special handling.   AnnE _ (NBinary NApp function (AnnE _ (NSet _rec bindings)))+    | extractFuncName function == Just "fetchGit"+    -> FetchNode <$> extractFetchGitBuiltinArgs bindings++  -- Also record calls to fetchFromGitHub.+  AnnE _ (NBinary NApp function (AnnE _ (NSet _rec bindings)))     | extractFuncName function == Just "fetchFromGitHub"     -> FetchNode <$> extractFetchFromGitHubArgs bindings +  -- And to fetchFromGitLab.+  AnnE _ (NBinary NApp function (AnnE _ (NSet _rec bindings)))+    | extractFuncName function == Just "fetchFromGitLab"+    -> FetchNode <$> extractFetchFromGitLabArgs bindings+   -- If it is an attribute set, find any attributes in it that we   -- might want to update.   AnnE _ (NSet _rec bindings)@@ -91,16 +101,32 @@ extractFetchGitArgs bindings =     FetchGitArgs <$> (URL <$> (exprText =<< extractAttr "url" bindings))                  <*> extractAttr "rev" bindings-                 <*> extractAttr "sha256" bindings+                 <*> (Just <$> extractAttr "sha256" bindings) +-- | Extract a 'FetchGitArgs' from the attrset being passed to builtins.fetchGit,+--   unlike all the other functions it does not include a sha256 field.+extractFetchGitBuiltinArgs :: [Binding NExprLoc] -> Either Warning FetchGitArgs+extractFetchGitBuiltinArgs bindings =+    FetchGitArgs <$> (URL <$> (exprText =<< extractAttr "url" bindings))+                 <*> extractAttr "rev" bindings+                 <*> pure Nothing+ -- | Extract a 'FetchGitArgs' from the attrset being passed to fetchFromGitHub. extractFetchFromGitHubArgs :: [Binding NExprLoc] -> Either Warning FetchGitArgs extractFetchFromGitHubArgs bindings =     FetchGitArgs <$> (GitHub <$> (exprText =<< extractAttr "owner" bindings)                              <*> (exprText =<< extractAttr "repo" bindings))                  <*> extractAttr "rev" bindings-                 <*> extractAttr "sha256" bindings+                 <*> (Just <$> extractAttr "sha256" bindings) +-- | Extract a 'FetchGitArgs' from the attrset being passed to fetchFromGitLab.+extractFetchFromGitLabArgs :: [Binding NExprLoc] -> Either Warning FetchGitArgs+extractFetchFromGitLabArgs bindings =+    FetchGitArgs <$> (GitLab <$> (exprText =<< extractAttr "owner" bindings)+                             <*> (exprText =<< extractAttr "repo" bindings))+                 <*> extractAttr "rev" bindings+                 <*> (Just <$> extractAttr "sha256" bindings)+ -------------------------------------------------------------------------------- -- Getting updated information from the internet. --------------------------------------------------------------------------------@@ -119,11 +145,11 @@ fetchTreeToSpanUpdates node@(Node _ cs) =   concatMap fetchTreeToSpanUpdates cs ++   toList (maybeUpdateVersion node)-fetchTreeToSpanUpdates (FetchNode f) = [revUpdate, sha256Update]+fetchTreeToSpanUpdates (FetchNode f) = catMaybes [Just revUpdate, sha256Update]   where revUpdate = SpanUpdate (exprSpan (revExpr args))                                (quoteString (latestRev f))-        sha256Update = SpanUpdate (exprSpan (sha256Expr args))-                                  (quoteString (latestSha256 f))+        sha256Update = SpanUpdate <$> (exprSpan <$> sha256Expr args)+                                  <*> Just (quoteString (latestSha256 f))         args = originalInfo f  -- Given a node of the fetch tree which might contain a version
src/Update/Nix/FetchGit/Types.hs view
@@ -24,11 +24,12 @@                          | FetchNode fetchInfo   deriving (Show, Data, Functor, Foldable, Traversable) --- | Represents the arugments to a call to fetchgit or fetchFromGitHub---   as parsed from a .nix file.+-- | Represents the arguments to a call to fetchgit, fetchFromGitHub+--   or fetchFromGitLab as parsed from a .nix file.+--   sha256Expr will be empty on calls to builtins.fetchGit. data FetchGitArgs = FetchGitArgs { repoLocation :: RepoLocation                                  , revExpr      :: NExprLoc-                                 , sha256Expr   :: NExprLoc+                                 , sha256Expr   :: Maybe NExprLoc                                  }   deriving (Show, Data) @@ -44,6 +45,9 @@ -- | A repo is either specified by URL or by Github owner/repo. data RepoLocation = URL Text                   | GitHub { owner :: Text+                           , repo  :: Text+                           }+                  | GitLab { owner :: Text                            , repo  :: Text                            }   deriving (Show, Data)
src/Update/Nix/FetchGit/Utils.hs view
@@ -48,6 +48,7 @@ extractUrlString = \case   URL u -> u   GitHub o r -> "https://github.com/" <> o <> "/" <> r <> ".git"+  GitLab o r -> "https://gitlab.com/" <> o <> "/" <> r <> ".git"  -- Add double quotes around a string so it can be inserted into a Nix -- file as a string literal.
update-nix-fetchgit.cabal view
@@ -1,5 +1,5 @@ name:                update-nix-fetchgit-version:             0.1.1.0+version:             0.1.2.0 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 of keeping such expressions up-to-date with the latest upstream sources.@@ -29,7 +29,6 @@                      , aeson >= 0.9                      , async >= 2.1                      , bytestring >= 0.10-                     , data-fix >= 0.0                      , errors >= 2.1                      , hnix >= 0.8                      , prettyprinter@@ -37,7 +36,6 @@                      , text >= 1.2                      , time >= 1.5                      , transformers >= 0.4-                     , trifecta >= 1.6                      , uniplate >= 1.6                      , utf8-string >= 1.0   default-language:    Haskell2010