Пример #1
0
 public async Task GetRepoTargetCalled(
     IGitRepository repo,
     GitPatcherVersioning patcherVersioning,
     CancellationToken cancel,
     ResetToTarget sut)
 {
     sut.Reset(repo, patcherVersioning, cancel);
     sut.GetRepoTarget.Received(1).Get(repo, patcherVersioning);
 }
Пример #2
0
 public async Task CheckoutPassedToRunnerBranchCheckout(
     IGitRepository repo,
     GitPatcherVersioning patcherVersioning,
     CancellationToken cancel,
     ResetToTarget sut)
 {
     sut.Reset(repo, patcherVersioning, cancel);
     sut.CheckoutRunnerBranch.Received(1).Checkout(repo);
 }
Пример #3
0
        public async Task <ConfigurationState <RunnerRepoInfo> > Checkout(
            CheckoutInput checkoutInput,
            CancellationToken cancel)
        {
            try
            {
                cancel.ThrowIfCancellationRequested();

                _logger.Information("Targeting {PatcherVersioning}", checkoutInput.PatcherVersioning);

                using var repoCheckout = RepoCheckouts.Get(RunnerRepoDirectoryProvider.Path);

                var target = ResetToTarget.Reset(repoCheckout.Repository, checkoutInput.PatcherVersioning, cancel);
                if (target.Failed)
                {
                    return(target.BubbleFailure <RunnerRepoInfo>());
                }

                cancel.ThrowIfCancellationRequested();

                checkoutInput.LibraryNugets.Log(_logger);

                var slnPath = SolutionFileLocator.GetPath(RunnerRepoDirectoryProvider.Path);
                if (slnPath == null)
                {
                    return(GetResponse <RunnerRepoInfo> .Fail("Could not locate solution to run."));
                }

                var foundProjSubPath = RunnerRepoProjectPathRetriever.Get(slnPath.Value, checkoutInput.Proj);
                if (foundProjSubPath == null)
                {
                    return(GetResponse <RunnerRepoInfo> .Fail($"Could not locate target project file: {checkoutInput.Proj}."));
                }

                cancel.ThrowIfCancellationRequested();

                ModifyRunnerProjects.Modify(
                    slnPath.Value,
                    drivingProjSubPath: foundProjSubPath.SubPath,
                    versions: checkoutInput.LibraryNugets.ReturnIfMatch(new NugetVersionPair(null, null)),
                    listedVersions: out var listedVersions);

                var runInfo = new RunnerRepoInfo(
                    SolutionPath: slnPath,
                    ProjPath: foundProjSubPath.FullPath,
                    MetaPath: _metaFilePathProvider.Path,
                    Target: target.Value.Target,
                    CommitMessage: target.Value.CommitMessage,
                    CommitDate: target.Value.CommitDate,
                    ListedVersions: listedVersions,
                    TargetVersions: checkoutInput.LibraryNugets.ReturnIfMatch(listedVersions));

                return(GetResponse <RunnerRepoInfo> .Succeed(runInfo));
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception ex)
            {
                return(GetResponse <RunnerRepoInfo> .Fail(ex));
            }
        }