diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2017-02-22 13:21:49 +0900 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2017-04-27 09:19:08 +0200 |
commit | 005e5feb4ecd08c4e4d141a38b9e7942accb3212 (patch) | |
tree | 686086609d3a9c559614a90c033a4965b1416bd3 /org.eclipse.jgit.pgm | |
parent | 76e86f4e48c98e742be99adff3b8b43cff94263c (diff) | |
download | jgit-005e5feb4ecd08c4e4d141a38b9e7942accb3212.tar.gz jgit-005e5feb4ecd08c4e4d141a38b9e7942accb3212.zip |
Clone: add --recurse-submodules option
Add the --recurse-submodules option on the command, which causes
submodules to also be initialized and updated.
Add a callback interface on CloneCommand and SubmoduleUpdateCommand to
them to provide progress feedback for clone operations.
Change-Id: I41b1668bc0d0bdfa46a9a89882c9657ea3063fc1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
3 files changed, 51 insertions, 3 deletions
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties index 06e4d94f74..f630ceeb8f 100644 --- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties +++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties @@ -44,6 +44,7 @@ cantFindGitDirectory=error: can't find git directory cantWrite=Can''t write {0} changesNotStagedForCommit=Changes not staged for commit: changesToBeCommitted=Changes to be committed: +checkingOut=Submodule path ''{0}'': checked out ''{1}'' checkoutConflict=error: Your local changes to the following files would be overwritten by checkout: checkoutConflictPathLine=\t{0} cleanRequireForce=clean.requireForce defaults to true and neither -n nor -f given; refusing to clean @@ -197,6 +198,7 @@ statusAddedByThem=added by them: statusDeletedByUs=deleted by us: statusBothAdded=both added: statusBothModified=both modified: +submoduleRegistered=Submodule {0} registered switchedToNewBranch=Switched to a new branch ''{0}'' switchedToBranch=Switched to branch ''{0}'' tagAlreadyExists=tag ''{0}'' already exists @@ -371,6 +373,7 @@ usage_pushUrls=push URLs are manipulated usage_quiet=don't show progress messages usage_recordChangesToRepository=Record changes to the repository usage_recurseIntoSubtrees=recurse into subtrees +usage_recurseSubmodules=recurse into submodules usage_removeUntrackedDirectories=remove untracked directories usage_renameLimit=limit size of rename matrix usage_reset=Reset current HEAD to the specified state diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java index 04078287fb..ca5205a4e1 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java @@ -44,11 +44,14 @@ package org.eclipse.jgit.pgm; import java.io.File; +import java.io.IOException; import java.text.MessageFormat; +import java.util.Collection; import org.eclipse.jgit.api.CloneCommand; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.TextProgressMonitor; import org.eclipse.jgit.pgm.internal.CLIText; @@ -58,7 +61,7 @@ import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; @Command(common = true, usage = "usage_cloneRepositoryIntoNewDir") -class Clone extends AbstractFetchCommand { +class Clone extends AbstractFetchCommand implements CloneCommand.Callback { @Option(name = "--origin", aliases = { "-o" }, metaVar = "metaVar_remoteName", usage = "usage_useNameInsteadOfOriginToTrackUpstream") private String remoteName = Constants.DEFAULT_REMOTE_NAME; @@ -74,6 +77,9 @@ class Clone extends AbstractFetchCommand { @Option(name = "--quiet", usage = "usage_quiet") private Boolean quiet; + @Option(name = "--recurse-submodules", usage = "usage_recurseSubmodules") + private boolean cloneSubmodules; + @Argument(index = 0, required = true, metaVar = "metaVar_uriish") private String sourceUri; @@ -109,13 +115,15 @@ class Clone extends AbstractFetchCommand { CloneCommand command = Git.cloneRepository(); command.setURI(sourceUri).setRemote(remoteName).setBare(isBare) - .setNoCheckout(noCheckout).setBranch(branch); + .setNoCheckout(noCheckout).setBranch(branch) + .setCloneSubmodules(cloneSubmodules); command.setGitDir(gitdir == null ? null : new File(gitdir)); command.setDirectory(localNameF); boolean msgs = quiet == null || !quiet.booleanValue(); if (msgs) { - command.setProgressMonitor(new TextProgressMonitor(errw)); + command.setProgressMonitor(new TextProgressMonitor(errw)) + .setCallback(this); outw.println(MessageFormat.format( CLIText.get().cloningInto, localName)); outw.flush(); @@ -136,4 +144,39 @@ class Clone extends AbstractFetchCommand { outw.flush(); } } + + @Override + public void initializedSubmodules(Collection<String> submodules) { + try { + for (String submodule : submodules) { + outw.println(MessageFormat + .format(CLIText.get().submoduleRegistered, submodule)); + } + outw.flush(); + } catch (IOException e) { + // ignore + } + } + + @Override + public void cloningSubmodule(String path) { + try { + outw.println(MessageFormat.format( + CLIText.get().cloningInto, path)); + outw.flush(); + } catch (IOException e) { + // ignore + } + } + + @Override + public void checkingOut(AnyObjectId commit, String path) { + try { + outw.println(MessageFormat.format(CLIText.get().checkingOut, + path, commit.getName())); + outw.flush(); + } catch (IOException e) { + // ignore + } + } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java index 4842b98731..e10ecbeebc 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java @@ -121,6 +121,7 @@ public class CLIText extends TranslationBundle { /***/ public String cantWrite; /***/ public String changesNotStagedForCommit; /***/ public String changesToBeCommitted; + /***/ public String checkingOut; /***/ public String checkoutConflict; /***/ public String checkoutConflictPathLine; /***/ public String cleanRequireForce; @@ -263,6 +264,7 @@ public class CLIText extends TranslationBundle { /***/ public String statusDeletedByUs; /***/ public String statusBothAdded; /***/ public String statusBothModified; + /***/ public String submoduleRegistered; /***/ public String switchedToNewBranch; /***/ public String switchedToBranch; /***/ public String tagAlreadyExists; |