From a9f8f8336bbb141c238ba9c71d78de00d8d0091e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 28 Sep 2017 14:14:07 -0400 Subject: sync: Added --cleanup, which removes local and remote synced/ branches. Also deletes any tagged pushes that the assistant might have done, since those would also prevent resetting a branch back. This commit was sponsored by andrea rota. --- Annex/AdjustedBranch.hs | 2 +- Annex/TaggedPush.hs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'Annex') diff --git a/Annex/AdjustedBranch.hs b/Annex/AdjustedBranch.hs index 52f73e638..9eedf06f5 100644 --- a/Annex/AdjustedBranch.hs +++ b/Annex/AdjustedBranch.hs @@ -167,7 +167,7 @@ adjustedToOriginal b | adjustedBranchPrefix `isPrefixOf` bs = do let (base, as) = separate (== '(') (drop prefixlen bs) adj <- deserialize (takeWhile (/= ')') as) - Just (adj, Git.Ref.underBase "refs/heads" (Ref base)) + Just (adj, Git.Ref.branchRef (Ref base)) | otherwise = Nothing where bs = fromRef b diff --git a/Annex/TaggedPush.hs b/Annex/TaggedPush.hs index 3b06170b3..13c53a3ca 100644 --- a/Annex/TaggedPush.hs +++ b/Annex/TaggedPush.hs @@ -30,7 +30,7 @@ import Utility.Base64 - Both UUIDs and Base64 encoded data are always legal to be used in git - refs, per git-check-ref-format. -} -toTaggedBranch :: UUID -> Maybe String -> Git.Branch -> Git.Branch +toTaggedBranch :: UUID -> Maybe String -> Git.Branch -> Git.Ref toTaggedBranch u info b = Git.Ref $ intercalate "/" $ catMaybes [ Just "refs/synced" , Just $ fromUUID u @@ -38,7 +38,7 @@ toTaggedBranch u info b = Git.Ref $ intercalate "/" $ catMaybes , Just $ Git.fromRef $ Git.Ref.base b ] -fromTaggedBranch :: Git.Branch -> Maybe (UUID, Maybe String) +fromTaggedBranch :: Git.Ref -> Maybe (UUID, Maybe String) fromTaggedBranch b = case splitc '/' $ Git.fromRef b of ("refs":"synced":u:info:_base) -> Just (toUUID u, fromB64Maybe info) @@ -46,6 +46,10 @@ fromTaggedBranch b = case splitc '/' $ Git.fromRef b of Just (toUUID u, Nothing) _ -> Nothing +listTaggedBranches :: Annex [(Git.Sha, Git.Ref)] +listTaggedBranches = filter (isJust . fromTaggedBranch . snd) + <$> inRepo Git.Ref.list + taggedPush :: UUID -> Maybe String -> Git.Ref -> Remote -> Git.Repo -> IO Bool taggedPush u info branch remote = Git.Command.runBool [ Param "push" -- cgit v1.2.3