public void DriverRepoPassedIntoSolutionFileLocator(
     DirectoryPath localPath,
     GetDriverPaths sut)
 {
     sut.DriverRepoDirectoryProvider.Path.Returns(localPath);
     sut.Get();
     sut.SolutionFileLocator.Received(1).GetPath(localPath);
 }
        public GetResponse <DriverRepoInfo> Prepare(GetResponse <string> remotePath, CancellationToken cancel)
        {
            // Clone and/or double check the clone is correct
            var state = CheckOrClone.Check(
                remotePath,
                DriverRepoDirectoryProvider.Path,
                cancel);

            if (state.Failed)
            {
                _logger.Error("Failed to check out driver repository: {Reason}", state.Reason);
                return(state.BubbleFailure <DriverRepoInfo>());
            }

            cancel.ThrowIfCancellationRequested();

            // Grab all the interesting metadata
            List <DriverTag>            tags;
            Dictionary <string, string> branchShas;
            IBranch masterBranch;

            try
            {
                using var repoCheckout = RepoCheckouts.Get(DriverRepoDirectoryProvider.Path);

                var masterBranchGet = ResetToLatestMain.TryReset(repoCheckout.Repository);
                if (masterBranchGet.Failed)
                {
                    _logger.Error("Failed to check out driver repository: {Reason}", masterBranchGet.Reason);
                    return(masterBranchGet.BubbleFailure <DriverRepoInfo>());
                }

                masterBranch = masterBranchGet.Value;

                RetrieveRepoVersioningPoints.Retrieve(repoCheckout.Repository, out tags, out branchShas);
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Failed to check out driver repository");
                return(GetResponse <DriverRepoInfo> .Fail(ex));
            }

            var paths = GetDriverPaths.Get();

            if (paths.Failed)
            {
                _logger.Error("Failed to check out driver repository: {Reason}", paths.Reason);
                return(paths.BubbleFailure <DriverRepoInfo>());
            }

            return(new DriverRepoInfo(
                       SolutionPath: paths.Value.SolutionPath,
                       MasterBranchName: masterBranch.FriendlyName,
                       BranchShas: branchShas,
                       Tags: tags,
                       AvailableProjects: paths.Value.AvailableProjects));
        }
 public void FailedSolutionFileLocatorFails(
     GetDriverPaths sut)
 {
     sut.SolutionFileLocator.GetPath(default).ReturnsForAnyArgs(default(FilePath?));