private static async Task <IEnumerable <DependencyDetail> > GetDependenciesAsync(
            IRemoteFactory remoteFactory,
            bool remote,
            ILogger logger,
            string gitExecutable,
            string repoUri,
            string commit,
            bool includeToolset,
            IEnumerable <string> remotesMap,
            string reposFolder,
            string testPath = null)
        {
            try
            {
                IEnumerable <DependencyDetail> dependencies = null;

                if (!string.IsNullOrEmpty(testPath))
                {
                    testPath = Path.Combine(
                        testPath,
                        repoUri,
                        commit);

                    if (Directory.Exists(testPath))
                    {
                        Local local = new Local(logger, testPath);
                        dependencies = await local.GetDependenciesAsync();
                    }
                }
                else if (remote)
                {
                    IRemote remoteClient = await remoteFactory.GetRemoteAsync(repoUri, logger);

                    dependencies = await remoteClient.GetDependenciesAsync(
                        repoUri,
                        commit);
                }
                else
                {
                    string repoPath = GetRepoPath(repoUri, commit, remotesMap, reposFolder, logger, gitExecutable);

                    if (!string.IsNullOrEmpty(repoPath))
                    {
                        Local  local        = new Local(logger);
                        string fileContents = LocalHelpers.GitShow(
                            gitExecutable,
                            repoPath,
                            commit,
                            VersionFiles.VersionDetailsXml,
                            logger);
                        dependencies = local.GetDependenciesFromFileContents(fileContents);
                    }
                }

                if (!includeToolset)
                {
                    dependencies = dependencies.Where(dependency => dependency.Type != DependencyType.Toolset);
                }
                return(dependencies);
            }
            catch (GithubApplicationInstallationException gexc)
            {
                // This means the Maestro APP was not installed in the repo's org. Just keep going.
                logger.LogWarning($"Failed to retrieve dependency information from {repoUri}@{commit}. Error: {gexc.Message}");
                return(null);
            }
            catch (DependencyFileNotFoundException)
            {
                // This is not an error. Dependencies can be specified with explicit shas that
                // may not have eng/Version.Details.xml at that point.
                logger.LogWarning($"{repoUri}@{commit} does not have an eng/Version.Details.xml.");
                return(null);
            }
            catch (Exception exc)
            {
                logger.LogError(exc, $"Something failed while trying the fetch the " +
                                $"dependencies of repo '{repoUri}' at sha " +
                                $"'{commit}'");
                throw;
            }
        }