refactor RemoteTrackingBranch
Not specific to Import; export will use it too.
This commit is contained in:
parent
d28b0a8bd0
commit
519cadd1de
5 changed files with 38 additions and 15 deletions
34
Annex/RemoteTrackingBranch.hs
Normal file
34
Annex/RemoteTrackingBranch.hs
Normal file
|
@ -0,0 +1,34 @@
|
|||
{- git-annex remote tracking branches
|
||||
-
|
||||
- Copyright 2019 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Annex.RemoteTrackingBranch
|
||||
( RemoteTrackingBranch
|
||||
, mkRemoteTrackingBranch
|
||||
, fromRemoteTrackingBranch
|
||||
, setRemoteTrackingBranch
|
||||
) where
|
||||
|
||||
import Annex.Common
|
||||
import Git.Types
|
||||
import qualified Git.Ref
|
||||
import qualified Git.Branch
|
||||
import qualified Types.Remote as Remote
|
||||
|
||||
newtype RemoteTrackingBranch = RemoteTrackingBranch
|
||||
{ fromRemoteTrackingBranch :: Ref }
|
||||
deriving (Show, Eq)
|
||||
|
||||
{- Makes a remote tracking branch corresponding to a local branch.
|
||||
- Note that the local branch does not need to exist yet. -}
|
||||
mkRemoteTrackingBranch :: Remote -> Branch -> RemoteTrackingBranch
|
||||
mkRemoteTrackingBranch remote ref = RemoteTrackingBranch $
|
||||
Git.Ref.underBase ("refs/remotes/" ++ Remote.name remote) ref
|
||||
|
||||
{- Set remote tracking branch to point to a commit. -}
|
||||
setRemoteTrackingBranch :: RemoteTrackingBranch -> Sha -> Annex ()
|
||||
setRemoteTrackingBranch tb commit =
|
||||
inRepo $ Git.Branch.update' (fromRemoteTrackingBranch tb) commit
|
Loading…
Add table
Add a link
Reference in a new issue