private CloneCommand.Callback callback;
+ private boolean fetch = false;
+
/**
* @param repo
*/
return this;
}
+ /**
+ * Whether to fetch the submodules before we update them. By default, this
+ * is set to <code>false</code>
+ *
+ * @param fetch
+ * @return this command
+ * @since 4.9
+ */
+ public SubmoduleUpdateCommand setFetch(final boolean fetch) {
+ this.fetch = fetch;
+ return this;
+ }
+
/**
* Add repository-relative submodule path to initialize
*
continue;
Repository submoduleRepo = generator.getRepository();
- // Clone repository is not present
+ // Clone repository if not present
if (submoduleRepo == null) {
if (callback != null) {
callback.cloningSubmodule(generator.getPath());
if (monitor != null)
clone.setProgressMonitor(monitor);
submoduleRepo = clone.call().getRepository();
+ } else if (this.fetch) {
+ if (callback != null) {
+ // FIXME: Do we need a new callback to tell them we're
+ // fetching?
+ callback.cloningSubmodule(generator.getPath());
+ }
+ FetchCommand fetchCommand = Git.wrap(submoduleRepo).fetch();
+ if (monitor != null) {
+ fetchCommand.setProgressMonitor(monitor);
+ }
+ configure(fetchCommand);
+ fetchCommand.call();
}
try (RevWalk walk = new RevWalk(submoduleRepo)) {