sync --quiet

* sync: When --quiet is used, run git commit, push, and pull without
  their ususual output.
* merge: When --quiet is used, run git merge without its usual output.

This might also make --quiet work better for some other commands
that make commits, like git-annex adjust.

Sponsored-by: Kevin Mueller on Patreon
This commit is contained in:
Joey Hess 2021-07-19 11:28:31 -04:00
parent f84bd8e921
commit 33a80d083a
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
13 changed files with 124 additions and 65 deletions

View file

@ -60,8 +60,8 @@ initRepo True primary_assistant_repo dir desc mgroup = inDir dir $ do
unlessM (Git.Config.isBare <$> gitRepo) $ do
cmode <- annexCommitMode <$> Annex.getGitConfig
void $ inRepo $ Git.Branch.commitCommand cmode
[ Param "--quiet"
, Param "--allow-empty"
(Git.Branch.CommitQuiet True)
[ Param "--allow-empty"
, Param "-m"
, Param "created repository"
]

View file

@ -21,6 +21,7 @@ import qualified Git
import qualified Git.Command
import qualified Remote
import qualified Types.Remote as Remote
import qualified Annex
import qualified Annex.Branch
import Remote.List.Util
import Annex.UUID
@ -125,25 +126,26 @@ pushToRemotes remotes = do
pushToRemotes' :: UTCTime -> [Remote] -> Assistant [Remote]
pushToRemotes' now remotes = do
(g, branch, u) <- liftAnnex $ do
(g, branch, u, ms) <- liftAnnex $ do
Annex.Branch.commit =<< Annex.Branch.commitMessage
(,,)
(,,,)
<$> gitRepo
<*> getCurrentBranch
<*> getUUID
ret <- go True branch g u remotes
<*> Annex.getState Annex.output
ret <- go ms True branch g u remotes
return ret
where
go _ (Nothing, _) _ _ _ = return [] -- no branch, so nothing to do
go _ _ _ _ [] = return [] -- no remotes, so nothing to do
go shouldretry currbranch@(Just branch, _) g u rs = do
go _ _ (Nothing, _) _ _ _ = return [] -- no branch, so nothing to do
go _ _ _ _ _ [] = return [] -- no remotes, so nothing to do
go ms shouldretry currbranch@(Just branch, _) g u rs = do
debug ["pushing to", show rs]
(succeeded, failed) <- parallelPush g rs (push branch)
(succeeded, failed) <- parallelPush g rs (push ms branch)
updatemap succeeded []
if null failed
then return []
else if shouldretry
then retry currbranch g u failed
then retry ms currbranch g u failed
else fallback branch g u failed
updatemap succeeded failed = do
@ -153,10 +155,10 @@ pushToRemotes' now remotes = do
M.difference m (makemap succeeded)
makemap l = M.fromList $ zip l (repeat now)
retry currbranch g u rs = do
retry ms currbranch g u rs = do
debug ["trying manual pull to resolve failed pushes"]
void $ manualPull currbranch rs
go False currbranch g u rs
go ms False currbranch g u rs
fallback branch g u rs = do
debug ["fallback pushing to", show rs]
@ -164,7 +166,7 @@ pushToRemotes' now remotes = do
updatemap succeeded failed
return failed
push branch remote = Command.Sync.pushBranch remote (Just branch)
push ms branch remote = Command.Sync.pushBranch remote (Just branch) ms
parallelPush :: Git.Repo -> [Remote] -> (Remote -> Git.Repo -> IO Bool)-> Assistant ([Remote], [Remote])
parallelPush g rs a = do
@ -211,6 +213,7 @@ syncAction rs a
manualPull :: Command.Sync.CurrBranch -> [Remote] -> Assistant ([Remote], Bool)
manualPull currentbranch remotes = do
g <- liftAnnex gitRepo
mc <- liftAnnex Command.Sync.mergeConfig
failed <- forM remotes $ \r -> if wantpull $ Remote.gitconfig r
then do
g' <- liftAnnex $ do
@ -225,7 +228,7 @@ manualPull currentbranch remotes = do
<$> liftAnnex Annex.Branch.forceUpdate
forM_ remotes $ \r ->
liftAnnex $ Command.Sync.mergeRemote r
currentbranch Command.Sync.mergeConfig def
currentbranch mc def
when haddiverged $
updateExportTreeFromLogAll
return (catMaybes failed, haddiverged)

View file

@ -90,8 +90,10 @@ onChange file
]
void $ liftAnnex $ do
cmode <- annexCommitMode <$> Annex.getGitConfig
mc <- Command.Sync.mergeConfig
Command.Sync.merge
currbranch Command.Sync.mergeConfig
currbranch
mc
def
cmode
changedbranch