automatically create the syncbranch
This commit is contained in:
parent
14d16b77b3
commit
f6f7ee7131
1 changed files with 15 additions and 12 deletions
|
@ -34,7 +34,7 @@ seek args = do
|
||||||
remotes <- syncRemotes syncbranch args
|
remotes <- syncRemotes syncbranch args
|
||||||
return $ concat $
|
return $ concat $
|
||||||
[ [ commit ]
|
[ [ commit ]
|
||||||
, [ mergeLocal branch ]
|
, [ mergeLocal branch syncbranch ]
|
||||||
, [ pullRemote remote branch | remote <- remotes ]
|
, [ pullRemote remote branch | remote <- remotes ]
|
||||||
, [ mergeAnnex ]
|
, [ mergeAnnex ]
|
||||||
, [ pushLocal syncbranch ]
|
, [ pushLocal syncbranch ]
|
||||||
|
@ -63,28 +63,31 @@ commit = do
|
||||||
[Param "-a", Param "-m", Param "git-annex automatic sync"]
|
[Param "-a", Param "-m", Param "git-annex automatic sync"]
|
||||||
return True
|
return True
|
||||||
|
|
||||||
mergeLocal :: Git.Ref -> CommandStart
|
mergeLocal :: Git.Ref -> Git.Ref -> CommandStart
|
||||||
mergeLocal branch = go =<< needmerge
|
mergeLocal branch syncbranch = go =<< needmerge
|
||||||
where
|
where
|
||||||
mergebranch = Git.Ref.under "refs/heads/synced" branch
|
|
||||||
needmerge = do
|
needmerge = do
|
||||||
unlessM (inRepo $ Git.Ref.exists mergebranch) $
|
unlessM (inRepo $ Git.Ref.exists syncbranch) $
|
||||||
error $ Git.Ref.describe mergebranch ++ " does not exist; create it to enable sync"
|
updateBranch syncbranch
|
||||||
inRepo $ Git.Branch.changed branch mergebranch
|
inRepo $ Git.Branch.changed branch syncbranch
|
||||||
go False = stop
|
go False = stop
|
||||||
go True = do
|
go True = do
|
||||||
showStart "merge" $ Git.Ref.describe mergebranch
|
showStart "merge" $ Git.Ref.describe syncbranch
|
||||||
next $ next $ mergeFromIfExists mergebranch
|
next $ next $ mergeFromIfExists syncbranch
|
||||||
|
|
||||||
pushLocal :: Git.Ref -> CommandStart
|
pushLocal :: Git.Ref -> CommandStart
|
||||||
pushLocal syncbranch = go =<< inRepo (Git.Ref.exists syncbranch)
|
pushLocal syncbranch = go =<< inRepo (Git.Ref.exists syncbranch)
|
||||||
where
|
where
|
||||||
go False = stop
|
go False = stop
|
||||||
go True = do
|
go True = do
|
||||||
unlessM (updatebranch) $
|
updateBranch syncbranch
|
||||||
error $ "failed to update " ++ show syncbranch
|
|
||||||
stop
|
stop
|
||||||
updatebranch = inRepo $ Git.Command.runBool "branch"
|
|
||||||
|
updateBranch :: Git.Ref -> Annex ()
|
||||||
|
updateBranch syncbranch =
|
||||||
|
unlessM go $ error $ "failed to update " ++ show syncbranch
|
||||||
|
where
|
||||||
|
go = inRepo $ Git.Command.runBool "branch"
|
||||||
[ Param "-f"
|
[ Param "-f"
|
||||||
, Param $ show $ Git.Ref.base syncbranch
|
, Param $ show $ Git.Ref.base syncbranch
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue