public void MainBranchNullFails( IGitRepository repo, ResetToLatestMain sut) { repo.MainBranch.Returns(default(IBranch?)); sut.TryReset(repo) .Succeeded.Should().BeFalse(); }
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 ChecksOutMainBranch( IGitRepository repo, ResetToLatestMain sut) { var branch = Substitute.For <IBranch>(); repo.MainBranch.Returns(branch); sut.TryReset(repo); repo.Received(1).Checkout(branch); }
public void ReturnsMainBranch( IBranch branch, IGitRepository repo, ResetToLatestMain sut) { repo.MainBranch.Returns(branch); var resp = sut.TryReset(repo); resp.Succeeded.Should().BeTrue(); resp.Value.Should().Be(branch); }
public void GeneralPipelineOrder( IGitRepository repo, ResetToLatestMain sut) { var branch = Substitute.For <IBranch>(); repo.MainBranch.Returns(branch); sut.TryReset(repo); Received.InOrder(() => { repo.ResetHard(); repo.Checkout(Arg.Any <IBranch>()); repo.Pull(); }); }
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)); }