improve adjusted branch name parsing to support adjusted view branches
An adjusted view branch has a name like "adjusted/views/master(author=_)(unlocked)" and so the adjustment starts at the last open paren, not the first open paren. Note that git-annex sync still does not do anything useful when run in such a branch, because it does not realize that it is a view branch. This is only groundwork for adjusted view branches. This also fixes adjusted branches when the basis branch name contains parens for some other reason, though that is not common in a git branch name. Sponsored-by: Boyd Stephen Smith Jr. on Patreon
This commit is contained in:
parent
df007925e6
commit
9b1fe37818
2 changed files with 9 additions and 1 deletions
|
@ -88,7 +88,7 @@ type OrigBranch = Branch
|
|||
adjustedToOriginal :: Branch -> Maybe (Adjustment, OrigBranch)
|
||||
adjustedToOriginal b
|
||||
| adjustedBranchPrefix `S.isPrefixOf` bs = do
|
||||
let (base, as) = separate' (== openparen) (S.drop prefixlen bs)
|
||||
let (base, as) = separateEnd' (== openparen) (S.drop prefixlen bs)
|
||||
adj <- deserializeAdjustment (S.takeWhile (/= closeparen) as)
|
||||
Just (adj, Git.Ref.branchRef (Ref base))
|
||||
| otherwise = Nothing
|
||||
|
|
|
@ -12,6 +12,7 @@ module Utility.Misc (
|
|||
readFileStrict,
|
||||
separate,
|
||||
separate',
|
||||
separateEnd',
|
||||
firstLine,
|
||||
firstLine',
|
||||
segment,
|
||||
|
@ -62,6 +63,13 @@ separate' c l = unbreak $ S.break c l
|
|||
| S.null b = r
|
||||
| otherwise = (a, S.tail b)
|
||||
|
||||
separateEnd' :: (Word8 -> Bool) -> S.ByteString -> (S.ByteString, S.ByteString)
|
||||
separateEnd' c l = unbreak $ S.breakEnd c l
|
||||
where
|
||||
unbreak r@(a, b)
|
||||
| S.null a = r
|
||||
| otherwise = (S.init a, b)
|
||||
|
||||
{- Breaks out the first line. -}
|
||||
firstLine :: String -> String
|
||||
firstLine = takeWhile (/= '\n')
|
||||
|
|
Loading…
Reference in a new issue