avoid using Git.Ref.describe except for when generating user messages
The other uses of it can all be simplified using Git.Ref.base, Git.Ref.under, and show. In some cases, describe was being used to shorten the branch name unnecessarily, and I instead pass the fully qualified name to git.
This commit is contained in:
parent
26040d6419
commit
556618a3ec
1 changed files with 17 additions and 19 deletions
|
@ -47,13 +47,12 @@ syncRemotes branch [] = defaultSyncRemotes branch
|
||||||
syncRemotes _ rs = mapM Remote.byName rs
|
syncRemotes _ rs = mapM Remote.byName rs
|
||||||
|
|
||||||
defaultSyncRemotes :: Git.Ref -> Annex [Remote.Remote Annex]
|
defaultSyncRemotes :: Git.Ref -> Annex [Remote.Remote Annex]
|
||||||
defaultSyncRemotes branch =
|
defaultSyncRemotes branch = mapM Remote.byName
|
||||||
mapM Remote.byName
|
|
||||||
=<< process . L.unpack <$> inRepo showref
|
=<< process . L.unpack <$> inRepo showref
|
||||||
where
|
where
|
||||||
syncbranch = Git.Ref $ "refs/heads/synced/" ++ Git.Ref.describe branch
|
syncbranch = Git.Ref.under "refs/heads/synced/" branch
|
||||||
showref = Git.Command.pipeRead
|
showref = Git.Command.pipeRead
|
||||||
[Param "show-ref", Param (Git.Ref.describe syncbranch)]
|
[Param "show-ref", Param $ show $ Git.Ref.base syncbranch]
|
||||||
process = map getRemoteName . filter isRemote .
|
process = map getRemoteName . filter isRemote .
|
||||||
map getBranchName . lines
|
map getBranchName . lines
|
||||||
isRemote r = "refs/remotes/" `isPrefixOf` r
|
isRemote r = "refs/remotes/" `isPrefixOf` r
|
||||||
|
@ -71,20 +70,21 @@ commit = do
|
||||||
return True
|
return True
|
||||||
|
|
||||||
mergeLocal :: Git.Ref -> CommandStart
|
mergeLocal :: Git.Ref -> CommandStart
|
||||||
mergeLocal branch = mergeFromIfExists $ Git.Ref $
|
mergeLocal = mergeFromIfExists . Git.Ref.under "refs/heads/synced"
|
||||||
"refs/heads/synced/" ++ Git.Ref.describe branch
|
|
||||||
|
|
||||||
pushLocal :: Git.Ref -> CommandStart
|
pushLocal :: Git.Ref -> CommandStart
|
||||||
pushLocal branch = do
|
pushLocal branch = do
|
||||||
let syncBranch = Git.Ref $ "refs/heads/synced/" ++ Git.Ref.describe branch
|
let syncBranch = Git.Ref.under "refs/heads/synced" branch
|
||||||
ex <- inRepo $ Git.Ref.exists syncBranch
|
ex <- inRepo $ Git.Ref.exists syncBranch
|
||||||
if ex then do
|
if ex then do
|
||||||
showStart "updateing" $
|
showStart "updating" $
|
||||||
Git.Ref.describe syncBranch ++
|
Git.Ref.describe syncBranch ++
|
||||||
" to the state of " ++ Git.Ref.describe branch ++ "..."
|
" to the state of " ++ Git.Ref.describe branch ++ "..."
|
||||||
next $ next $
|
next $ next $
|
||||||
inRepo $ Git.Command.runBool "branch"
|
inRepo $ Git.Command.runBool "branch"
|
||||||
[Param "-f", Param (Git.Ref.describe syncBranch)]
|
[ Param "-f"
|
||||||
|
, Param $ show $ Git.Ref.base syncBranch
|
||||||
|
]
|
||||||
else
|
else
|
||||||
return Nothing
|
return Nothing
|
||||||
|
|
||||||
|
@ -109,24 +109,22 @@ fetch remote = do
|
||||||
inRepo $ Git.Command.runBool "fetch" [Param (Remote.name remote)]
|
inRepo $ Git.Command.runBool "fetch" [Param (Remote.name remote)]
|
||||||
|
|
||||||
mergeRemote :: Remote.Remote Annex -> Git.Ref -> CommandStart
|
mergeRemote :: Remote.Remote Annex -> Git.Ref -> CommandStart
|
||||||
mergeRemote remote branch = mergeFromIfExists $ Git.Ref $
|
mergeRemote remote = mergeFromIfExists .
|
||||||
"refs/remotes/" ++ Remote.name remote ++
|
Git.Ref.under ("refs/remotes/" ++ Remote.name remote ++ "/synced")
|
||||||
"/synced/" ++ Git.Ref.describe branch
|
|
||||||
|
|
||||||
pushRemote :: Remote.Remote Annex -> Git.Ref -> CommandStart
|
pushRemote :: Remote.Remote Annex -> Git.Ref -> CommandStart
|
||||||
pushRemote remote branch = do
|
pushRemote remote branch = do
|
||||||
showStart "pushing to" (Remote.name remote)
|
showStart "pushing to" (Remote.name remote)
|
||||||
let syncbranch = Git.Ref $ "refs/heads/synced/" ++
|
let syncbranch = Git.Ref.under "refs/heads/synced" branch
|
||||||
Git.Ref.describe branch
|
let syncbranchRemote = Git.Ref.under
|
||||||
let syncbranchRemote = Git.Ref $ "refs/remotes/" ++
|
("refs/remotes/" ++ Remote.name remote) syncbranch
|
||||||
Remote.name remote ++ "/" ++ Git.Ref.describe syncbranch
|
let refspec = show (Git.Ref.base branch) ++ ":" ++ show (Git.Ref.base syncbranch)
|
||||||
let refspec = Git.Ref.describe branch ++ ":" ++ Git.Ref.describe syncbranch
|
|
||||||
ex <- inRepo $ Git.Ref.exists syncbranchRemote
|
ex <- inRepo $ Git.Ref.exists syncbranchRemote
|
||||||
next $ next $ do
|
next $ next $ do
|
||||||
showOutput
|
showOutput
|
||||||
inRepo $ Git.Command.runBool "push" $
|
inRepo $ Git.Command.runBool "push" $
|
||||||
[ Param (Remote.name remote)
|
[ Param (Remote.name remote)
|
||||||
, Param (Git.Ref.describe Annex.Branch.name) ] ++
|
, Param (show $ Annex.Branch.name) ] ++
|
||||||
[ Param refspec | ex ]
|
[ Param refspec | ex ]
|
||||||
|
|
||||||
currentBranch :: Annex Git.Ref
|
currentBranch :: Annex Git.Ref
|
||||||
|
|
Loading…
Add table
Reference in a new issue