private static async Task <IEnumerable <DependencyDetail> > GetDependenciesAsync(
            DarcSettings darcSettings,
            bool remote,
            ILogger logger,
            DependencyGraphNode node,
            IEnumerable <string> remotesMap,
            string reposFolder,
            string testPath = null)
        {
            try
            {
                IEnumerable <DependencyDetail> dependencies = null;

                if (!string.IsNullOrEmpty(testPath))
                {
                    testPath = Path.Combine(
                        testPath,
                        node.DependencyDetail.RepoUri,
                        node.DependencyDetail.Commit);

                    if (!string.IsNullOrEmpty(node.DependencyDetail.Commit) &&
                        Directory.Exists(testPath))
                    {
                        Local local = new Local(
                            Path.Combine(
                                testPath,
                                ".git"),
                            logger);
                        dependencies = await local.GetDependenciesAsync();
                    }
                }
                else if (remote)
                {
                    Remote remoteClient = new Remote(darcSettings, logger);
                    dependencies = await remoteClient.GetDependenciesAsync(
                        node.DependencyDetail.RepoUri,
                        node.DependencyDetail.Commit);
                }
                else
                {
                    string repoPath = GetRepoPath(node.DependencyDetail, remotesMap, reposFolder, logger);

                    if (!string.IsNullOrEmpty(repoPath))
                    {
                        // Local's constructor expects the repo's .git folder to be passed in. In this
                        // particular case we could pass any folder under 'repoPath' or even a fake one
                        // but we use .git to keep things consistent to what Local expects
                        Local  local        = new Local($"{repoPath}/.git", logger);
                        string fileContents = LocalHelpers.GitShow(
                            repoPath,
                            node.DependencyDetail.Commit,
                            VersionFiles.VersionDetailsXml,
                            logger);
                        dependencies = local.GetDependenciesFromFileContents(fileContents);
                    }
                }

                return(dependencies);
            }
            catch (Exception exc)
            {
                logger.LogError(exc, $"Something failed while trying the fetch the " +
                                $"dependencies of repo '{node.DependencyDetail.RepoUri}' at sha " +
                                $"'{node.DependencyDetail.Commit}'");
                throw;
            }
        }
        private static async Task <IEnumerable <DependencyDetail> > GetDependenciesAsync(
            IRemoteFactory remoteFactory,
            bool remote,
            ILogger logger,
            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);

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

                if (!includeToolset)
                {
                    dependencies = dependencies.Where(dependency => dependency.Type != DependencyType.Toolset);
                }
                return(dependencies);
            }
            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;
            }
        }