Example #1
0
 public SolutionPatcherNameVm(
     IProjectSubpathDefaultSettings defaultSettings,
     ISelectedProjectInputVm selectedProjectInputVm)
 {
     _name = selectedProjectInputVm.WhenAnyValue(x => x.Picker.TargetPath)
             .Select(GetNameFromPath)
             .CombineLatest(
         this.WhenAnyValue(x => x.Nickname),
         (auto, nickname) => nickname.IsNullOrWhitespace() ? auto : nickname)
             .ToGuiProperty <string>(this, nameof(Name), GetNameFromPath(defaultSettings.ProjectSubpath), deferSubscription: true);
 }
 public CheckoutInputProvider(
     IRunnerRepositoryPreparation runnerRepositoryState,
     ISelectedProjectInputVm selectedProjectInput,
     IPatcherVersioningFollower patcherTargeting,
     INugetVersioningFollower nugetTargeting)
 {
     Input = Observable.CombineLatest(
         runnerRepositoryState.State,
         selectedProjectInput.Picker.PathState()
         .Select(x => x.Succeeded ? x : GetResponse <string> .Fail("No patcher project selected.")),
         patcherTargeting.ActivePatcherVersion,
         nugetTargeting.ActiveNugetVersion,
         (runnerState, proj, patcherVersioning, libraryNugets) => new PotentialCheckoutInput(
             runnerState,
             proj,
             patcherVersioning,
             libraryNugets))
             .Replay(1)
             .RefCount();
 }
Example #3
0
        public AvailableTags(
            ISelectedProjectInputVm selectedProjectInput,
            IDriverRepositoryPreparationFollower driverRepositoryPreparation,
            IAvailableProjects availableProjects)
        {
            var tagInput = Observable.CombineLatest(
                selectedProjectInput.Picker.WhenAnyValue(x => x.TargetPath),
                availableProjects.Projects.WhenAnyValue(x => x.Count),
                (targetPath, count) => (targetPath, count));

            Tags = driverRepositoryPreparation.DriverInfo
                   .Select(x => x.Item?.Tags ?? Enumerable.Empty <DriverTag>())
                   .Select(x => x.AsObservableChangeSet())
                   .Switch()
                   .Filter(
                tagInput.Select(x =>
            {
                if (x.count == 0)
                {
                    return(new Func <DriverTag, bool>(_ => false));
                }
                if (x.count == 1)
                {
                    return(new Func <DriverTag, bool>(_ => true));
                }
                if (!x.targetPath.EndsWith(".csproj"))
                {
                    return(new Func <DriverTag, bool>(_ => false));
                }
                var projName = Path.GetFileName(x.targetPath);
                return(new Func <DriverTag, bool>(i =>
                                                  i.Name.StartsWith(projName, StringComparison.OrdinalIgnoreCase)));
            }))
                   .Sort(SortExpressionComparer <DriverTag> .Descending(x => x.Index))
                   .Transform(x => x.Name)
                   .ObserveOn(RxApp.MainThreadScheduler)
                   .ToObservableCollection(this);
        }
Example #4
0
        public GitPatcherVm(
            IGithubPatcherIdentifier ident,
            IPatcherNameVm nameVm,
            IProfileDisplayControllerVm selPatcher,
            IConfirmationPanelControllerVm confirmation,
            ISelectedProjectInputVm selectedProjectInput,
            IGitRemoteRepoPathInputVm remoteRepoPathInputVm,
            INavigateTo navigate,
            IAvailableTags availableTags,
            ILockToCurrentVersioning lockToCurrentVersioning,
            IAvailableProjects availableProjects,
            ICompilationProvider compilationProvider,
            IBaseRepoDirectoryProvider baseRepoDir,
            IGitStatusDisplay gitStatusDisplay,
            IDriverRepoDirectoryProvider driverRepoDirectoryProvider,
            IRunnerRepoDirectoryProvider runnerRepoDirectoryProvider,
            IGetRepoPathValidity getRepoPathValidity,
            IRepoClonesValidStateVm repoClonesValid,
            INugetDiffProviderVm nugetDiff,
            IGitPatcherState state,
            ILogger logger,
            IRunnableStateProvider runnableStateProvider,
            ILifetimeScope scope,
            IGitPatcherTargetingVm patcherTargeting,
            ICheckoutInputProvider checkoutInputProvider,
            IGitNugetTargetingVm nugetTargetingVm,
            IUpdateAllCommand updateAllCommand,
            IAttemptedCheckout attemptedCheckout,
            IPatcherIdProvider idProvider,
            ICopyOverExtraData copyOverExtraData,
            PatcherRenameActionVm.Factory renameFactory,
            DeleteUserData deleteUserData,
            PatcherUserSettingsVm.Factory settingsVmFactory,
            GithubPatcherSettings?settings = null)
            : base(
                scope, nameVm, selPatcher,
                confirmation, idProvider, renameFactory, settings)
        {
            _logger              = logger;
            _copyOverExtraData   = copyOverExtraData;
            SelectedProjectInput = selectedProjectInput;
            RemoteRepoPathInput  = remoteRepoPathInputVm;
            Locking              = lockToCurrentVersioning;
            RepoClonesValid      = repoClonesValid;
            NugetDiff            = nugetDiff;
            PatcherTargeting     = patcherTargeting;
            NugetTargeting       = nugetTargetingVm;
            UpdateAllCommand     = updateAllCommand;

            DeleteUserDataCommand = ReactiveCommand.Create(deleteUserData.Delete);

            ID = ident.Id;

            CopyInSettings(settings);

            LocalDriverRepoDirectory = driverRepoDirectoryProvider.Path.Path;
            LocalRunnerRepoDirectory = runnerRepoDirectoryProvider.Path.Path;

            _repoValidity = getRepoPathValidity.RepoPath
                            .Select(r => r.RunnableState)
                            .ToGuiProperty(this, nameof(RepoValidity), deferSubscription: true);

            AvailableProjects = availableProjects.Projects;

            AvailableTags = availableTags.Tags;

            _attemptedCheckout = checkoutInputProvider.Input
                                 .Select(attemptedCheckout.Attempted)
                                 .ToGuiProperty(this, nameof(AttemptedCheckout), deferSubscription: true);

            _runnableData = runnableStateProvider.WhenAnyValue(x => x.State.Item)
                            .ToGuiProperty(this, nameof(RunnableData), default(RunnerRepoInfo?), deferSubscription: true);

            _state = state.State
                     .ToGuiProperty(this, nameof(State), new ConfigurationState(ErrorResponse.Fail("Evaluating"))
            {
                IsHaltingError = false
            }, deferSubscription: true);

            OpenGitPageCommand = ReactiveCommand.Create(
                canExecute: this.WhenAnyValue(x => x.RepoValidity)
                .Select(x => x.Succeeded),
                execute: () => navigate.Navigate(RemoteRepoPathInput.RemoteRepoPath));

            OpenGitPageToVersionCommand = ReactiveCommand.Create(
                canExecute: this.WhenAnyFallback(x => x.RunnableData)
                .Select(x => x != null),
                execute: () =>
            {
                try
                {
                    if (RunnableData is not {
                    } runnable)
                    {
                        return;
                    }
                    navigate.Navigate(Path.Combine(RemoteRepoPathInput.RemoteRepoPath, "tree", runnable.Target.Target));
                }
                catch (Exception ex)
                {
                    _logger.Error(ex, "Error opening Git webpage");
                }
            });

            NavigateToInternalFilesCommand = ReactiveCommand.Create(() => navigate.Navigate(baseRepoDir.Path));

            PatcherSettings = settingsVmFactory(
                false,
                compilationProvider.State.Select(c =>
            {
                if (c.RunnableState.Failed)
                {
                    return(new PatcherUserSettingsVm.Inputs(c.RunnableState.BubbleFailure <FilePath>(), null, default));
                }
                return(new PatcherUserSettingsVm.Inputs(GetResponse <FilePath> .Succeed(c.Item.ProjPath), c.Item.TargetVersions.Synthesis, c.Item.MetaPath));
            })
                .DistinctUntilChanged())
                              .DisposeWith(this);

            _statusDisplay = gitStatusDisplay.StatusDisplay
                             .ToGuiProperty(this, nameof(StatusDisplay),
                                            new StatusRecord(
                                                Text: "Initializing",
                                                Processing: false,
                                                Blocking: false,
                                                Command: null), deferSubscription: true);

            SetToLastSuccessfulRunCommand = ReactiveCommand.Create(
                canExecute: this.WhenAnyValue(x => x.LastSuccessfulRun)
                .Select(x =>
            {
                return(x != null &&
                       !x.TargetRepo.IsNullOrWhitespace() &&
                       !x.ProjectSubpath.IsNullOrWhitespace() &&
                       !x.Commit.IsNullOrWhitespace() &&
                       !x.MutagenVersion.IsNullOrWhitespace() &&
                       !x.SynthesisVersion.IsNullOrWhitespace());
            }),
                execute: () =>
            {
                if (LastSuccessfulRun == null)
                {
                    return;
                }
                RemoteRepoPathInput.RemoteRepoPath         = LastSuccessfulRun.TargetRepo;
                this.SelectedProjectInput.ProjectSubpath   = LastSuccessfulRun.ProjectSubpath;
                this.PatcherTargeting.TargetCommit         = LastSuccessfulRun.Commit;
                this.NugetTargeting.ManualMutagenVersion   = LastSuccessfulRun.MutagenVersion;
                this.NugetTargeting.ManualSynthesisVersion = LastSuccessfulRun.SynthesisVersion;
                this.PatcherTargeting.PatcherVersioning    = PatcherVersioningEnum.Commit;
                this.NugetTargeting.SynthesisVersioning    = PatcherNugetVersioningEnum.Manual;
                this.NugetTargeting.MutagenVersioning      = PatcherNugetVersioningEnum.Manual;
            });
        }