split out Git/Command.hs
This commit is contained in:
parent
02f1bd2bf4
commit
ef28b3fef7
22 changed files with 125 additions and 100 deletions
|
@ -10,7 +10,7 @@ module Command.Sync where
|
|||
import Common.Annex
|
||||
import Command
|
||||
import qualified Annex.Branch
|
||||
import qualified Git
|
||||
import qualified Git.Command
|
||||
import qualified Git.Config
|
||||
|
||||
import qualified Data.ByteString.Lazy.Char8 as L
|
||||
|
@ -28,7 +28,8 @@ commit = do
|
|||
next $ next $ do
|
||||
showOutput
|
||||
-- Commit will fail when the tree is clean, so ignore failure.
|
||||
_ <- inRepo $ Git.runBool "commit" [Param "-a", Param "-m", Param "sync"]
|
||||
_ <- inRepo $ Git.Command.runBool "commit"
|
||||
[Param "-a", Param "-m", Param "sync"]
|
||||
return True
|
||||
|
||||
pull :: CommandStart
|
||||
|
@ -38,7 +39,7 @@ pull = do
|
|||
next $ next $ do
|
||||
showOutput
|
||||
checkRemote remote
|
||||
inRepo $ Git.runBool "pull" [Param remote]
|
||||
inRepo $ Git.Command.runBool "pull" [Param remote]
|
||||
|
||||
push :: CommandStart
|
||||
push = do
|
||||
|
@ -47,7 +48,7 @@ push = do
|
|||
next $ next $ do
|
||||
Annex.Branch.update
|
||||
showOutput
|
||||
inRepo $ Git.runBool "push" [Param remote, matchingbranches]
|
||||
inRepo $ Git.Command.runBool "push" [Param remote, matchingbranches]
|
||||
where
|
||||
-- git push may be configured to not push matching
|
||||
-- branches; this should ensure it always does.
|
||||
|
@ -61,7 +62,7 @@ defaultRemote = do
|
|||
|
||||
currentBranch :: Annex String
|
||||
currentBranch = last . split "/" . L.unpack . head . L.lines <$>
|
||||
inRepo (Git.pipeRead [Param "symbolic-ref", Param "HEAD"])
|
||||
inRepo (Git.Command.pipeRead [Param "symbolic-ref", Param "HEAD"])
|
||||
|
||||
checkRemote :: String -> Annex ()
|
||||
checkRemote remote = do
|
||||
|
|
|
@ -13,7 +13,7 @@ import qualified Annex
|
|||
import Utility.FileMode
|
||||
import Logs.Location
|
||||
import Annex.Content
|
||||
import qualified Git
|
||||
import qualified Git.Command
|
||||
import qualified Git.LsFiles as LsFiles
|
||||
|
||||
def :: [Command]
|
||||
|
@ -34,14 +34,14 @@ cleanup :: FilePath -> Key -> CommandCleanup
|
|||
cleanup file key = do
|
||||
liftIO $ removeFile file
|
||||
-- git rm deletes empty directory without --cached
|
||||
inRepo $ Git.run "rm" [Params "--cached --quiet --", File file]
|
||||
inRepo $ Git.Command.run "rm" [Params "--cached --quiet --", File file]
|
||||
|
||||
-- If the file was already committed, it is now staged for removal.
|
||||
-- Commit that removal now, to avoid later confusing the
|
||||
-- pre-commit hook if this file is later added back to
|
||||
-- git as a normal, non-annexed file.
|
||||
whenM (not . null <$> inRepo (LsFiles.staged [file])) $ do
|
||||
inRepo $ Git.run "commit" [
|
||||
inRepo $ Git.Command.run "commit" [
|
||||
Param "-m", Param "content removed from git annex",
|
||||
Param "--", File file]
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import qualified Data.ByteString.Lazy.Char8 as B
|
|||
import Common.Annex
|
||||
import Command
|
||||
import qualified Git
|
||||
import qualified Git.Command
|
||||
import qualified Annex
|
||||
import qualified Command.Unannex
|
||||
import Init
|
||||
|
@ -29,7 +30,7 @@ check = do
|
|||
"cannot uninit when the " ++ show b ++ " branch is checked out"
|
||||
where
|
||||
current_branch = Git.Ref . head . lines . B.unpack <$> revhead
|
||||
revhead = inRepo $ Git.pipeRead
|
||||
revhead = inRepo $ Git.Command.pipeRead
|
||||
[Params "rev-parse --abbrev-ref HEAD"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
@ -57,5 +58,6 @@ cleanup = do
|
|||
liftIO $ removeDirectoryRecursive annexdir
|
||||
-- avoid normal shutdown
|
||||
saveState
|
||||
inRepo $ Git.run "branch" [Param "-D", Param $ show Annex.Branch.name]
|
||||
inRepo $ Git.Command.run "branch"
|
||||
[Param "-D", Param $ show Annex.Branch.name]
|
||||
liftIO exitSuccess
|
||||
|
|
|
@ -20,6 +20,7 @@ import Utility.TempFile
|
|||
import Logs.Location
|
||||
import qualified Annex
|
||||
import qualified Git
|
||||
import qualified Git.Command
|
||||
import qualified Git.Ref
|
||||
import qualified Git.LsFiles as LsFiles
|
||||
import qualified Git.LsTree as LsTree
|
||||
|
@ -148,7 +149,7 @@ unusedKeys = do
|
|||
excludeReferenced :: [Key] -> Annex [Key]
|
||||
excludeReferenced [] = return [] -- optimisation
|
||||
excludeReferenced l = do
|
||||
c <- inRepo $ Git.pipeRead [Param "show-ref"]
|
||||
c <- inRepo $ Git.Command.pipeRead [Param "show-ref"]
|
||||
removewith (getKeysReferenced : map getKeysReferencedInGit (refs c))
|
||||
(S.fromList l)
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue