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));
        }
Ejemplo n.º 2
0
        public ErrorResponse Prep(CancellationToken cancellationToken)
        {
            var localRepoPath = CheckOrClone.Check(
                RegistryUrlProvider.Url,
                RegistryFolderProvider.RegistryFolder,
                cancellationToken);

            if (localRepoPath.Failed)
            {
                return(localRepoPath);
            }

            using var repoCheckout = RepositoryCheckouts.Get(localRepoPath.Value.Local);
            var repo = repoCheckout.Repository;

            return(ResetToLatestMain.TryReset(repo));
        }