diff --git a/src/Hooky/Internal/GitFile.hs b/src/Hooky/Internal/GitFile.hs index 470b760..de84421 100644 --- a/src/Hooky/Internal/GitFile.hs +++ b/src/Hooky/Internal/GitFile.hs @@ -141,7 +141,7 @@ resolveGitFiles git = \case [oldMode0, newMode, _oldHash, _newHash, status] <- pure $ Text.words s (':', _oldMode) <- Text.uncons oldMode0 (path, rest') <- - if status `elem` ["C", "R"] + if any (`Text.isPrefixOf` status) ["C", "R"] then do _src : dest : rest' <- pure rest Just (dest, rest') diff --git a/test/Hooky/E2ESpec.hs b/test/Hooky/E2ESpec.hs index c88d930..d28428c 100644 --- a/test/Hooky/E2ESpec.hs +++ b/test/Hooky/E2ESpec.hs @@ -83,6 +83,14 @@ spec = do removeFile "bad.txt" runHooky ["run", "--all"] `shouldSatisfy` P.returns (P.eq ExitSuccess) + it "works after `git mv`" $ do + withGitRepo $ \git -> do + commitHookyEofFixer git + writeFile "good.txt" "" + git.exec ["add", "good.txt"] >> git.exec ["commit", "-m", "test"] + git.exec ["mv", "good.txt", "good-moved.txt"] + runHooky ["run"] `shouldSatisfy` P.returns (P.eq ExitSuccess) + it "stashes intent-to-add files" $ do withGitRepo $ \git -> do commitHookyEofFixer git