move commitStaged out of Command.Sync which no longer uses it

It's trivial enough that it it's not worth factoring it out to somewhere
in common with Command.Undo and the assistant.

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
This commit is contained in:
Joey Hess 2024-02-07 16:19:28 -04:00
parent 21123ba368
commit fa9197560d
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 16 additions and 13 deletions

View file

@ -40,6 +40,7 @@ import qualified Database.Keys
import qualified Command.Sync import qualified Command.Sync
import qualified Command.Add import qualified Command.Add
import Config.GitConfig import Config.GitConfig
import qualified Git.Branch
import Utility.Tuple import Utility.Tuple
import Utility.Metered import Utility.Metered
import qualified Utility.RawFilePath as R import qualified Utility.RawFilePath as R
@ -240,7 +241,11 @@ commitStaged msg = do
Left _ -> return False Left _ -> return False
Right _ -> do Right _ -> do
cmode <- annexCommitMode <$> Annex.getGitConfig cmode <- annexCommitMode <$> Annex.getGitConfig
ok <- Command.Sync.commitStaged cmode msg ok <- inRepo $ Git.Branch.commitCommand cmode
(Git.Branch.CommitQuiet True)
[ Param "-m"
, Param msg
]
when ok $ when ok $
Command.Sync.updateBranches =<< getCurrentBranch Command.Sync.updateBranches =<< getCurrentBranch
return ok return ok

View file

@ -19,7 +19,6 @@ module Command.Sync (
prepMerge, prepMerge,
mergeLocal, mergeLocal,
mergeRemote, mergeRemote,
commitStaged,
commitMsg, commitMsg,
pushBranch, pushBranch,
updateBranch, updateBranch,
@ -429,14 +428,6 @@ commitMsg = do
m <- uuidDescMap m <- uuidDescMap
return $ "git-annex in " ++ maybe "unknown" fromUUIDDesc (M.lookup u m) return $ "git-annex in " ++ maybe "unknown" fromUUIDDesc (M.lookup u m)
commitStaged :: Git.Branch.CommitMode -> String -> Annex Bool
commitStaged commitmode commitmessage =
inRepo $ Git.Branch.commitCommand commitmode
(Git.Branch.CommitQuiet True)
[ Param "-m"
, Param commitmessage
]
mergeLocal :: [Git.Merge.MergeConfig] -> SyncOptions -> CurrBranch -> CommandStart mergeLocal :: [Git.Merge.MergeConfig] -> SyncOptions -> CurrBranch -> CommandStart
mergeLocal mergeconfig o currbranch = stopUnless (notOnlyAnnex o) $ mergeLocal mergeconfig o currbranch = stopUnless (notOnlyAnnex o) $
mergeLocal' mergeconfig o currbranch mergeLocal' mergeconfig o currbranch

View file

@ -1,6 +1,6 @@
{- git-annex command {- git-annex command
- -
- Copyright 2014 Joey Hess <id@joeyh.name> - Copyright 2014-2024 Joey Hess <id@joeyh.name>
- -
- Licensed under the GNU AGPL version 3 or higher. - Licensed under the GNU AGPL version 3 or higher.
-} -}
@ -18,7 +18,6 @@ import qualified Annex
import qualified Git.LsFiles as LsFiles import qualified Git.LsFiles as LsFiles
import qualified Git.Command as Git import qualified Git.Command as Git
import qualified Git.Branch import qualified Git.Branch
import qualified Command.Sync
import qualified Utility.RawFilePath as R import qualified Utility.RawFilePath as R
cmd :: Command cmd :: Command
@ -42,7 +41,7 @@ seek ps = do
-- Committing staged changes before undo allows later -- Committing staged changes before undo allows later
-- undoing the undo. It would be nicer to only commit staged -- undoing the undo. It would be nicer to only commit staged
-- changes to the specified files, rather than all staged changes. -- changes to the specified files, rather than all staged changes.
void $ Command.Sync.commitStaged Git.Branch.ManualCommit void $ commitStaged Git.Branch.ManualCommit
"commit before undo" "commit before undo"
withStrings (commandAction . start) ps withStrings (commandAction . start) ps
@ -81,3 +80,11 @@ perform p = do
inRepo $ Git.run [Param "checkout", Param "--", File f] inRepo $ Git.run [Param "checkout", Param "--", File f]
next $ liftIO cleanup next $ liftIO cleanup
commitStaged :: Git.Branch.CommitMode -> String -> Annex Bool
commitStaged commitmode commitmessage =
inRepo $ Git.Branch.commitCommand commitmode
(Git.Branch.CommitQuiet True)
[ Param "-m"
, Param commitmessage
]