Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ghc-file-embed for openSUSE:Factory checked in at 2021-06-01 10:38:49 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-file-embed (Old) and /work/SRC/openSUSE:Factory/.ghc-file-embed.new.1898 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-file-embed" Tue Jun 1 10:38:49 2021 rev:16 rq:896189 version:0.0.14.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-file-embed/ghc-file-embed.changes 2020-12-22 11:39:23.461496139 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-file-embed.new.1898/ghc-file-embed.changes 2021-06-01 10:40:27.809119677 +0200 @@ -1,0 +2,8 @@ +Tue May 11 09:10:44 UTC 2021 - psim...@suse.com + +- Update file-embed to version 0.0.14.0. + ## 0.0.14.0 + + * Add `embedFileIfExists` + +------------------------------------------------------------------- Old: ---- file-embed-0.0.13.0.tar.gz New: ---- file-embed-0.0.14.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-file-embed.spec ++++++ --- /var/tmp/diff_new_pack.7z5XCY/_old 2021-06-01 10:40:28.225120386 +0200 +++ /var/tmp/diff_new_pack.7z5XCY/_new 2021-06-01 10:40:28.229120392 +0200 @@ -1,7 +1,7 @@ # # spec file for package ghc-file-embed # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %global pkg_name file-embed %bcond_with tests Name: ghc-%{pkg_name} -Version: 0.0.13.0 +Version: 0.0.14.0 Release: 0 Summary: Use Template Haskell to embed file contents directly License: BSD-2-Clause ++++++ file-embed-0.0.13.0.tar.gz -> file-embed-0.0.14.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/file-embed-0.0.13.0/ChangeLog.md new/file-embed-0.0.14.0/ChangeLog.md --- old/file-embed-0.0.13.0/ChangeLog.md 2020-07-01 09:40:24.000000000 +0200 +++ new/file-embed-0.0.14.0/ChangeLog.md 2021-05-10 17:54:57.000000000 +0200 @@ -1,5 +1,9 @@ # ChangeLog for file-embed +## 0.0.14.0 + +* Add `embedFileIfExists` + ## 0.0.13.0 * Ensure that directory listings are returned in sorted order for reproducibility [yesodweb/yesod#1684](https://github.com/yesodweb/yesod/issues/1684) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/file-embed-0.0.13.0/Data/FileEmbed.hs new/file-embed-0.0.14.0/Data/FileEmbed.hs --- old/file-embed-0.0.13.0/Data/FileEmbed.hs 2020-07-01 09:39:04.000000000 +0200 +++ new/file-embed-0.0.14.0/Data/FileEmbed.hs 2021-05-10 17:55:11.000000000 +0200 @@ -19,6 +19,7 @@ module Data.FileEmbed ( -- * Embed at compile time embedFile + , embedFileIfExists , embedOneFileOf , embedDir , embedDirListing @@ -60,13 +61,14 @@ #endif import System.Directory (doesDirectoryExist, doesFileExist, getDirectoryContents, canonicalizePath) -import Control.Exception (throw, ErrorCall(..)) -import Control.Monad (filterM) +import Control.Exception (throw, tryJust, ErrorCall(..)) +import Control.Monad (filterM, guard) import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as B8 import Control.Arrow ((&&&), second) import Control.Applicative ((<$>)) import Data.ByteString.Unsafe (unsafePackAddressLen) +import System.IO.Error (isDoesNotExistError) import System.IO.Unsafe (unsafePerformIO) import System.FilePath ((</>), takeDirectory, takeExtension) import Data.String (fromString) @@ -87,6 +89,33 @@ #endif (runIO $ B.readFile fp) >>= bsToExp +-- | Maybe embed a single file in your source code depending on whether or not file exists. +-- +-- Warning: When a build is compiled with the file missing, a recompile when the file exists might not trigger an embed of the file. +-- You might try to fix this by doing a clean build. +-- +-- > import qualified Data.ByteString +-- > +-- > maybeMyFile :: Maybe Data.ByteString.ByteString +-- > maybeMyFile = $(embedFileIfExists "dirName/fileName") +-- +-- @since 0.0.14.0 +embedFileIfExists :: FilePath -> Q Exp +embedFileIfExists fp = do + mbs <- runIO maybeFile + case mbs of + Nothing -> [| Nothing |] + Just bs -> do +#if MIN_VERSION_template_haskell(2,7,0) + qAddDependentFile fp +#endif + [| Just $(bsToExp bs) |] + where + maybeFile :: IO (Maybe B.ByteString) + maybeFile = + either (const Nothing) Just <$> + tryJust (guard . isDoesNotExistError) (B.readFile fp) + -- | Embed a single existing file in your source code -- out of list a list of paths supplied. -- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/file-embed-0.0.13.0/file-embed.cabal new/file-embed-0.0.14.0/file-embed.cabal --- old/file-embed-0.0.13.0/file-embed.cabal 2020-07-01 09:40:44.000000000 +0200 +++ new/file-embed-0.0.14.0/file-embed.cabal 2021-05-10 17:55:01.000000000 +0200 @@ -1,5 +1,5 @@ name: file-embed -version: 0.0.13.0 +version: 0.0.14.0 license: BSD3 license-file: LICENSE author: Michael Snoyman <mich...@snoyman.com> @@ -33,6 +33,7 @@ main-is: main.hs hs-source-dirs: test build-depends: base + , bytestring , file-embed , filepath diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/file-embed-0.0.13.0/test/main.hs new/file-embed-0.0.14.0/test/main.hs --- old/file-embed-0.0.13.0/test/main.hs 2020-07-01 09:39:37.000000000 +0200 +++ new/file-embed-0.0.14.0/test/main.hs 2021-05-10 17:53:58.000000000 +0200 @@ -2,6 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} import Control.Monad (unless) +import qualified Data.ByteString as B (ByteString, filter) import Data.FileEmbed import System.FilePath ((</>)) @@ -19,3 +20,9 @@ ] let str = $(embedStringFile "test/sample/foo") :: String filter (/= '\r') str @?= "foo\n" + + let mbs = $(embedFileIfExists "test/sample/foo") + fmap (B.filter (/= fromIntegral (fromEnum '\r'))) mbs @?= Just "foo\n" + + let mbs2 = $(embedFileIfExists "test/sample/foo2") :: Maybe B.ByteString + mbs2 @?= Nothing