packages feed

githash 0.1.6.1 → 0.1.6.2

raw patch · 3 files changed

+38/−3 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,13 @@ # ChangeLog for githash +## 0.1.6.2++* Fixed bugs; now this library's Template Haskell functions are much more+  likely on recompilation to detect Git update that doesn't affect workspace:+  e.g. `git switch -c <new_branch>` (equivalently+  `git checkout -b <new_branch>`) and `git commit --amend --only`.+  Implemented in [#23](https://github.com/snoyberg/githash/pull/23).+ ## 0.1.6.1  * [Support template-haskell 2.17](https://github.com/snoyberg/githash/pull/22)
githash.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           githash-version:        0.1.6.1+version:        0.1.6.2 synopsis:       Compile git revision info into Haskell projects description:    Please see the README and documentation at <https://www.stackage.org/package/githash> category:       Development
src/GitHash.hs view
@@ -63,6 +63,7 @@ import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as B8 import Data.Typeable (Typeable)+import Data.Word (Word8) import Language.Haskell.TH import Language.Haskell.TH.Syntax import Language.Haskell.TH.Syntax.Compat@@ -130,6 +131,23 @@  -- | Get a list of files from within a @.git@ directory. getGitFilesRegular :: FilePath -> IO [FilePath]+-- [Note: Current implementation's limitation]+-- the current implementation doesn't work right if:+-- 1. the current branch's name contains Non-ASCII character (due to @B8.unpack@),+-- 2. the current branch is only in .git/packed-refs, or+-- 3. the current branch is a symbolic ref to another reference.+-- In these cases, the file with the name `ref` in the following+-- code cannot be found in the filesystem (in the cases 1 & 2),+-- or can be found but will not be updated on commit (in the case 3).+-- As a result, if a module uses @tGitInfo@ as TH macro+-- and the target git repo is in one of the conditions 1--3+-- at the time of compilation, content-change-free commits will fail to+-- trigger recompilation.+--+-- [Note: reftable]+-- In the near future, the technology called reftable may replace the+-- Git's reference management. This function's implementation does not+-- work with reftable, and therefore will need to be updated. getGitFilesRegular git = do   -- a lot of bookkeeping to record the right dependencies   let hd         = git </> "HEAD"@@ -144,12 +162,12 @@       Right hdRef -> do         -- the HEAD file either contains the hash of a detached head         -- or a pointer to the file that contains the hash of the head-        case B.splitAt 5 hdRef of+        case B.splitAt 5 $ B.takeWhile (not . isSmallASCIIControl) hdRef of           -- pointer to ref           ("ref: ", relRef) -> do             let ref = git </> B8.unpack relRef             refExists <- doesFileExist ref-            return $ if refExists then [ref] else []+            return $ if refExists then [hd,ref] else [hd]           -- detached head           _hash -> return [hd]   -- add the index if it exists to set the dirty flag@@ -162,6 +180,15 @@   let files3 = if packedExists then [packedRefs] else []    return $ concat [files1, files2, files3]+  where+    -- This is to quickly strip newline characters+    -- from the content of .git/HEAD.+    -- Git references don't include ASCII control char bytes:+    -- 0x00 -- 0x1F and 0x7F.+    -- .git/HEAD may contain some ASCII control bytes LF (0xA) and+    -- CR (0xD) before EOF, which should be ignored.+    isSmallASCIIControl :: Word8 -> Bool+    isSmallASCIIControl = (<0x20)  -- | Get a list of dependent files from a @.git@ file representing a -- git-worktree.