refactor getCurrentBranch
Both Command.Sync and Annex.Ingest had their own versions of this. The one in Annex.Ingest used Git.Branch.currentUnsafe, but does not seem to need it. That is only checking to see if it's in an adjusted unlocked branch, and when in an adjusted branch, the branch does in fact exist, so the added check that Git.Branch.current does is fine. This commit was sponsored by Denis Dzyubenko on Patreon.
This commit is contained in:
parent
c94e62cab5
commit
8be5a7269a
15 changed files with 228 additions and 169 deletions
|
@ -25,6 +25,7 @@ import qualified Annex.Branch
|
|||
import Annex.UUID
|
||||
import Annex.TaggedPush
|
||||
import Annex.Ssh
|
||||
import Annex.CurrentBranch
|
||||
import qualified Config
|
||||
import Git.Config
|
||||
import Config.DynamicConfig
|
||||
|
@ -79,8 +80,7 @@ reconnectRemotes rs = void $ do
|
|||
{- No local branch exists yet, but we can try pulling. -}
|
||||
sync (Nothing, _) = manualPull (Nothing, Nothing) =<< gitremotes
|
||||
go = do
|
||||
(failed, diverged) <- sync
|
||||
=<< liftAnnex (join Command.Sync.getCurrBranch)
|
||||
(failed, diverged) <- sync =<< liftAnnex getCurrentBranch
|
||||
addScanRemotes diverged =<<
|
||||
filterM (not <$$> liftIO . getDynamicConfig . remoteAnnexIgnore . Remote.gitconfig) rs
|
||||
return failed
|
||||
|
@ -127,7 +127,7 @@ pushToRemotes' now remotes = do
|
|||
Annex.Branch.commit =<< Annex.Branch.commitMessage
|
||||
(,,)
|
||||
<$> gitRepo
|
||||
<*> join Command.Sync.getCurrBranch
|
||||
<*> getCurrentBranch
|
||||
<*> getUUID
|
||||
ret <- go True branch g u remotes
|
||||
return ret
|
||||
|
|
|
@ -32,6 +32,7 @@ import Annex.Link
|
|||
import Annex.CatFile
|
||||
import Annex.InodeSentinal
|
||||
import Annex.Version
|
||||
import Annex.CurrentBranch
|
||||
import qualified Annex
|
||||
import Utility.InodeCache
|
||||
import Annex.Content.Direct
|
||||
|
@ -228,7 +229,7 @@ commitStaged msg = do
|
|||
Right _ -> do
|
||||
ok <- Command.Sync.commitStaged Git.Branch.AutomaticCommit msg
|
||||
when ok $
|
||||
Command.Sync.updateSyncBranch =<< join Command.Sync.getCurrBranch
|
||||
Command.Sync.updateSyncBranch =<< getCurrentBranch
|
||||
return ok
|
||||
|
||||
{- OSX needs a short delay after a file is added before locking it down,
|
||||
|
|
|
@ -12,6 +12,7 @@ import Assistant.Commits
|
|||
import Assistant.Pushes
|
||||
import Assistant.DaemonStatus
|
||||
import Annex.Concurrent
|
||||
import Annex.CurrentBranch
|
||||
import Utility.ThreadScheduler
|
||||
import qualified Annex
|
||||
import qualified Remote
|
||||
|
@ -64,7 +65,7 @@ exportToRemotes rs = do
|
|||
Annex.changeState $ \st -> st { Annex.errcounter = 0 }
|
||||
start <- liftIO getCurrentTime
|
||||
void $ Command.Sync.seekExportContent rs
|
||||
=<< join Command.Sync.getCurrBranch
|
||||
=<< getCurrentBranch
|
||||
-- Look at command error counter to see if the export
|
||||
-- didn't work.
|
||||
failed <- (> 0) <$> Annex.getState Annex.errcounter
|
||||
|
|
|
@ -13,6 +13,7 @@ import Assistant.BranchChange
|
|||
import Assistant.Sync
|
||||
import Utility.DirWatcher
|
||||
import Utility.DirWatcher.Types
|
||||
import Annex.CurrentBranch
|
||||
import qualified Annex.Branch
|
||||
import qualified Git
|
||||
import qualified Git.Branch
|
||||
|
@ -71,7 +72,7 @@ onChange file
|
|||
changedbranch = fileToBranch file
|
||||
|
||||
mergecurrent =
|
||||
mergecurrent' =<< liftAnnex (join Command.Sync.getCurrBranch)
|
||||
mergecurrent' =<< liftAnnex getCurrentBranch
|
||||
mergecurrent' currbranch@(Just b, _)
|
||||
| changedbranch `isRelatedTo` b =
|
||||
whenM (liftAnnex $ inRepo $ Git.Branch.changed b changedbranch) $ do
|
||||
|
|
|
@ -20,7 +20,6 @@ import qualified Annex
|
|||
import qualified Git
|
||||
import qualified Git.Config
|
||||
import qualified Git.Command
|
||||
import qualified Command.Sync
|
||||
import Config.Files
|
||||
import Utility.FreeDesktop
|
||||
import Utility.DiskFree
|
||||
|
@ -30,6 +29,7 @@ import Utility.Mounts
|
|||
import Utility.DataUnits
|
||||
import Remote (prettyUUID)
|
||||
import Annex.UUID
|
||||
import Annex.CurrentBranch
|
||||
import Types.StandardGroups
|
||||
import Logs.PreferredContent
|
||||
import Logs.UUID
|
||||
|
@ -212,7 +212,7 @@ postNewRepositoryR = page "Add another repository" (Just Configuration) $ do
|
|||
- immediately pulling from it. Also spawns a sync to push to it as well. -}
|
||||
immediateSyncRemote :: Remote -> Assistant ()
|
||||
immediateSyncRemote r = do
|
||||
currentbranch <- liftAnnex $ join Command.Sync.getCurrBranch
|
||||
currentbranch <- liftAnnex $ getCurrentBranch
|
||||
void $ manualPull currentbranch [r]
|
||||
syncRemote r
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue