assistant: Merge changes from refs/remotes/foo/master into master.
Previously, only sync branches were merged. This makes regular git push into a repository watched by the assistant auto-merge. While this does hardcode an assumption about what the remote tracking branch is named, which some unusual git configurations won't match, git-annex sync already made the same assumption. Also, changed behavior when a tracking branch like refs/remotes/synced/not/master is received. When on the master branch, that used to get merged into it, but it's the tracking branch for not/master, so should only be merged in when on the not/master branch. This commit was sponsored by Ewen McNeill.
This commit is contained in:
parent
86e4ea00b2
commit
4a92eac23e
2 changed files with 17 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex assistant git merge thread
|
{- git-annex assistant git merge thread
|
||||||
-
|
-
|
||||||
- Copyright 2012 Joey Hess <id@joeyh.name>
|
- Copyright 2012-2017 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -15,6 +15,7 @@ import Utility.DirWatcher.Types
|
||||||
import qualified Annex.Branch
|
import qualified Annex.Branch
|
||||||
import qualified Git
|
import qualified Git
|
||||||
import qualified Git.Branch
|
import qualified Git.Branch
|
||||||
|
import qualified Git.Ref
|
||||||
import qualified Command.Sync
|
import qualified Command.Sync
|
||||||
|
|
||||||
{- This thread watches for changes to .git/refs/, and handles incoming
|
{- This thread watches for changes to .git/refs/, and handles incoming
|
||||||
|
@ -63,19 +64,14 @@ onChange file
|
||||||
diverged <- liftAnnex Annex.Branch.forceUpdate
|
diverged <- liftAnnex Annex.Branch.forceUpdate
|
||||||
when diverged $
|
when diverged $
|
||||||
queueDeferredDownloads "retrying deferred download" Later
|
queueDeferredDownloads "retrying deferred download" Later
|
||||||
-- Merge only from /synced/ branches, which are pushed by git-annex
|
| otherwise = mergecurrent
|
||||||
-- sync and by remote instances of the assistant.
|
|
||||||
-- It would be nice to merge other remote tracking branches,
|
|
||||||
-- but it's hard to get an efficient list of them (git remote -r)
|
|
||||||
| "/synced/" `isInfixOf` file = mergecurrent
|
|
||||||
| otherwise = noop
|
|
||||||
where
|
where
|
||||||
changedbranch = fileToBranch file
|
changedbranch = fileToBranch file
|
||||||
|
|
||||||
mergecurrent =
|
mergecurrent =
|
||||||
mergecurrent' =<< liftAnnex (join Command.Sync.getCurrBranch)
|
mergecurrent' =<< liftAnnex (join Command.Sync.getCurrBranch)
|
||||||
mergecurrent' currbranch@(Just b, _)
|
mergecurrent' currbranch@(Just b, _)
|
||||||
| equivBranches changedbranch b =
|
| changedbranch `isRelatedTo` b =
|
||||||
whenM (liftAnnex $ inRepo $ Git.Branch.changed b changedbranch) $ do
|
whenM (liftAnnex $ inRepo $ Git.Branch.changed b changedbranch) $ do
|
||||||
debug
|
debug
|
||||||
[ "merging", Git.fromRef changedbranch
|
[ "merging", Git.fromRef changedbranch
|
||||||
|
@ -88,10 +84,17 @@ onChange file
|
||||||
changedbranch
|
changedbranch
|
||||||
mergecurrent' _ = noop
|
mergecurrent' _ = noop
|
||||||
|
|
||||||
equivBranches :: Git.Ref -> Git.Ref -> Bool
|
{- Is the first branch a synced branch or remote tracking branch related
|
||||||
equivBranches x y = base x == base y
|
- to the second branch, which should be merged into it? -}
|
||||||
|
isRelatedTo :: Git.Ref -> Git.Ref -> Bool
|
||||||
|
isRelatedTo x y
|
||||||
|
| basex /= takeDirectory basex ++ "/" ++ basey = False
|
||||||
|
| "/synced/" `isInfixOf` Git.fromRef x = True
|
||||||
|
| "refs/remotes/" `isPrefixOf` Git.fromRef x = True
|
||||||
|
| otherwise = False
|
||||||
where
|
where
|
||||||
base = takeFileName . Git.fromRef
|
basex = Git.fromRef $ Git.Ref.base x
|
||||||
|
basey = Git.fromRef $ Git.Ref.base y
|
||||||
|
|
||||||
isAnnexBranch :: FilePath -> Bool
|
isAnnexBranch :: FilePath -> Bool
|
||||||
isAnnexBranch f = n `isSuffixOf` f
|
isAnnexBranch f = n `isSuffixOf` f
|
||||||
|
|
|
@ -22,6 +22,9 @@ git-annex (6.20170520) UNRELEASED; urgency=medium
|
||||||
* Fix bug that prevented transfer locks from working when
|
* Fix bug that prevented transfer locks from working when
|
||||||
run on SMB or other filesystem that does not support fcntl locks
|
run on SMB or other filesystem that does not support fcntl locks
|
||||||
and hard links.
|
and hard links.
|
||||||
|
* assistant: Merge changes from refs/remotes/foo/master into master.
|
||||||
|
Previously, only sync branches were merged. This makes regular git push
|
||||||
|
into a repository watched by the assistant auto-merge.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Wed, 24 May 2017 14:03:40 -0400
|
-- Joey Hess <id@joeyh.name> Wed, 24 May 2017 14:03:40 -0400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue