git-monitor 1.3.2 → 1.4.0
raw patch · 2 files changed
+27/−30 lines, 2 filesdep ~gitlibdep ~gitlib-libgit2
Dependency ranges changed: gitlib, gitlib-libgit2
Files
- Main.hs +24/−27
- git-monitor.cabal +3/−3
Main.hs view
@@ -141,16 +141,15 @@ then resolveReference sref else return Nothing scr' <- maybe (fromJust <$> resolveReference "HEAD") return scr- sc <- resolveCommitRef scr'- let tref = commitTree sc- toid = treeRefOid tref- tree <- resolveTreeRef tref+ sc <- lookupCommit scr'+ let toid = commitTree sc+ tree <- lookupTree toid ft <- readFileTree' tree wd (isNothing scr) -- Begin the snapshotting process, which continues indefinitely until -- the process is stopped. It is safe to cancel this process at any -- time, typically using SIGINT (C-c) or even SIGKILL.- snapshotTree opts wd userName userEmail ref sref sc tref toid ft+ snapshotTree opts wd userName userEmail ref sref sc toid ft -- | 'snapshotTree' is the core workhorse of this utility. It periodically -- checks the filesystem for changes to Git-tracked files, and snapshots@@ -163,39 +162,37 @@ -> Text -> Text -> Commit (LgRepository m)- -> TreeRef (LgRepository m) -> TreeOid (LgRepository m) -> Map FilePath (FileEntry (LgRepository m)) -> LgRepository m ()-snapshotTree opts wd name email ref sref = fix $ \loop sc tref toid ft -> do+snapshotTree opts wd name email ref sref = fix $ \loop sc toid ft -> do -- Read the current working tree's state on disk ft' <- readFileTree ref wd False -- Prune files which have been removed since the last interval, and find -- files which have been added or changed- tref' <- mutateTreeRef tref $ do+ toid' <- mutateTreeOid toid $ do Map.foldlWithKey' (\a p e -> a >> scanOldEntry ft' p e) (return ()) ft Map.foldlWithKey' (\a p e -> a >> scanNewEntry ft p e) (return ()) ft' -- If the snapshot tree changed, create a new commit to reflect it- let toid' = treeRefOid tref'- sc' <- if toid /= toid'- then do- now <- liftIO getZonedTime- let sig = Signature- { signatureName = name- , signatureEmail = email- , signatureWhen = now- }- msg = "Snapshot at "- ++ formatTime defaultTimeLocale "%F %T %Z" now+ sc' <- if toid /= toid'+ then do+ now <- liftIO getZonedTime+ let sig = Signature+ { signatureName = name+ , signatureEmail = email+ , signatureWhen = now+ }+ msg = "Snapshot at "+ ++ formatTime defaultTimeLocale "%F %T %Z" now - c <- createCommit [commitRef sc] tref'- sig sig (T.pack msg) (Just sref)- infoL $ "Commit "- ++ (T.unpack . renderObjOid . commitOid $ c)- return c- else return sc+ c <- createCommit [commitOid sc] toid'+ sig sig (T.pack msg) (Just sref)+ infoL $ "Commit "+ ++ (T.unpack . renderObjOid . commitOid $ c)+ return c+ else return sc -- Wait a given number of seconds liftIO $ threadDelay (interval opts * 1000000)@@ -208,7 +205,7 @@ if ref /= curRef then infoL $ "Branch changed to " ++ T.unpack curRef ++ ", restarting"- else loop sc' tref' toid' ft'+ else loop sc' toid' ft' where scanOldEntry :: MonadGit m@@ -265,7 +262,7 @@ case h of Nothing -> pure Map.empty Just h' -> do- tr <- resolveTreeRef . commitTree =<< resolveCommitRef h'+ tr <- lookupTree . commitTree =<< lookupCommit h' readFileTree' tr wdir getHash readFileTree' :: MonadGit m
git-monitor.cabal view
@@ -1,5 +1,5 @@ Name: git-monitor-Version: 1.3.2+Version: 1.4.0 Synopsis: Passively snapshots working tree changes efficiently. Description: Passively snapshots working tree changes efficiently.@@ -23,8 +23,8 @@ Build-depends: base >= 4 && < 5 , bytestring >= 0.9.2.1 , containers >= 0.4.2.1- , gitlib >= 1.3.1- , gitlib-libgit2 >= 1.3.1+ , gitlib >= 1.4.0+ , gitlib-libgit2 >= 1.4.0 , hslogger >= 1.2 , old-locale >= 1.0.0.4 , optparse-applicative >= 0.5.2.1