grgit
grgit copied to clipboard
Pull specific repository and refspec
I would need functionality similar to git pull
from the command line:
- pull specific
repository
- pull specific
refspec
(commit, branch or tag)
The obvious place to put them would seem to be org.ajoberstar.grgit.operation.PullOp.
I can try to come up with a pull request, but please comment on the idea.
PullOp
(which maps to JGit's PullCommand) already supports:
-
remote
(which maps to the JGItremote
supporting remote names or uris) -
branch
(which maps to the JGitremoteBranchName
)
From their doc, it doesn't imply much flexibility beyond the branch name. If you need full refspec support, you could separate it into a fetch and merge. FetchOp definitely supports refspecs.
remote
did indeed support also URIs.
I had some success using fetch
+ merge
using a fixed ref
of the form refs/heads/<branch>
.
grgit.fetch('refSpecs': [ref], 'remote': uri, 'tagMode': FetchOp.TagMode.AUTO)
grgit.merge('head': 'FETCH_HEAD', 'mode': MergeOp.Mode.ONLY_FF)
This allowed me to pull from a dynamically determined remote repository without risk of overwriting any configured remote
s.
However, this approach failed when trying to pull a commit by SHA, which jgit apparently does not support yet. https://bugs.eclipse.org/bugs/show_bug.cgi?id=517858
I will have to use cgit for now, but for someone wanting to pull branches and tags I supposed the above would work.
Thanks for the follow up. I've tagged this as one waiting on JGit.
Confirming that the JGit bug is still open as of 10/22/2017.