Skip to content

Instantly share code, notes, and snippets.

@allomov
Last active March 27, 2021 15:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allomov/e9b7d4506c271a24e87d91371a323076 to your computer and use it in GitHub Desktop.
Save allomov/e9b7d4506c271a24e87d91371a323076 to your computer and use it in GitHub Desktop.
function updateSubmodulesRecursevly(repository, cloneOptions) {
return repository.getSubmoduleNames().then(function(names) {
return names.reduce(function(promiseChain, name) {
return promiseChain.then(function() {
return new Promise(function(resolve, reject) {
Submodule.lookup(repository, name)
.then(function(submodule) {
return submodule.init(1)
.then(function(result) {
return submodule.update(1, cloneOptions)
})
.then(function() {
let submoduleRepoPath = path.join(repository.workdir(), submodule.path());
return Repository.open(submoduleRepoPath)
.then(function(submoduleRepository) {
return updateSubmodulesRecursevly(submoduleRepository, cloneOptions);
})
})
.then(resolve, reject)
});
});
});
}, Promise.resolve());
})
}
@paymog
Copy link

paymog commented Mar 27, 2021

I get the following error on the call to submodule.update: 'protos' exists and is not an empty directory. However, if I cd into the parent directory and run git submodule update it executes without any problems. Any chance you know what might be going on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment