public async Task Prep(GameRelease release, CancellationToken cancel) { _output.OnNext("Cloning repository"); var cloneResult = await GitUtility.CheckOrCloneRepo(GetResponse <string> .Succeed(_settings.RemoteRepoPath), _localDir, (x) => _output.OnNext(x), cancel); if (cloneResult.Failed) { throw new SynthesisBuildFailure(cloneResult.Reason); } throw new NotImplementedException("Need to migrate in proper git checkouts"); //_output.OnNext($"Locating path to solution based on local dir {_localDir}"); //var pathToSln = GetPathToSolution(_localDir); //_output.OnNext($"Locating path to project based on {pathToSln} AND {_settings.SelectedProjectSubpath}"); //var foundProjSubPath = SolutionPatcherRun.AvailableProject(pathToSln, _settings.SelectedProjectSubpath); //if (foundProjSubPath == null) //{ // throw new SynthesisBuildFailure("Could not locate project sub path"); //} //var pathToProj = Path.Combine(_localDir, foundProjSubPath); //SolutionRun = new SolutionPatcherRun( // _settings.Nickname, // pathToSln: Path.Combine(_localDir, pathToSln), // pathToProj: pathToProj); //using var outputSub = SolutionRun.Output.Subscribe(this._output); //using var errSub = SolutionRun.Error.Subscribe(this._error); //await SolutionRun.Prep(release, cancel).ConfigureAwait(false); }
public GitPatcherInitVM(ProfileVM profile) : base(profile) { Patcher = new GitPatcherVM(profile); _CanCompleteConfiguration = this.WhenAnyValue(x => x.Patcher.RepoClonesValid) .Select(x => ErrorResponse.Create(x)) .ToGuiProperty(this, nameof(CanCompleteConfiguration), ErrorResponse.Success); PatcherRepos = Observable.Return(Unit.Default) .ObserveOn(RxApp.TaskpoolScheduler) .SelectTask(async _ => { try { var localRepoPath = await GitUtility.CheckOrCloneRepo( GetResponse <string> .Succeed("https://github.com/Mutagen-Modding/Synthesis.Registry"), Paths.RegistryFolder, Log.Logger.Error, CancellationToken.None); if (localRepoPath.Failed) { Error = localRepoPath; return(Observable.Empty <IChangeSet <PatcherStoreListingVM> >()); } using var repo = new Repository(localRepoPath.Value.Local); var master = repo.Branches.Where(b => b.IsCurrentRepositoryHead).FirstOrDefault(); if (master == null) { Error = ErrorResponse.Fail("Could not find master branch"); Log.Logger.Error(Error.Reason); return(Observable.Empty <IChangeSet <PatcherStoreListingVM> >()); } repo.Reset(ResetMode.Hard, repo.Branches[$"{master.RemoteName}/{master.FriendlyName}"].Tip); var listingPath = Path.Combine(repo.Info.WorkingDirectory, Constants.AutomaticListingFileName); if (!File.Exists(listingPath)) { Error = ErrorResponse.Fail("Could not locate listing file"); Log.Logger.Error(Error.Reason); return(Observable.Empty <IChangeSet <PatcherStoreListingVM> >()); } var settings = new JsonSerializerOptions(); settings.Converters.Add(new JsonStringEnumConverter()); var customization = JsonSerializer.Deserialize <MutagenPatchersListing>(File.ReadAllText(listingPath), settings) !; return(customization.Repositories .NotNull() .SelectMany(repo => { var repoVM = new RepositoryStoreListingVM(repo); return repo.Patchers .Select(p => { return new PatcherStoreListingVM(this, p, repoVM); }); }) .AsObservableChangeSet()); } catch (Exception ex) { Log.Logger.Error(ex, "Error downloading patcher listing"); Error = ErrorResponse.Fail(ex); } return(Observable.Empty <IChangeSet <PatcherStoreListingVM> >()); }) .Switch() .Sort(Comparer <PatcherStoreListingVM> .Create((x, y) => x.Name.CompareTo(y.Name))) .Filter(this.WhenAnyValue(x => x.ShowAll) .DistinctUntilChanged() .Select(show => new Func <PatcherStoreListingVM, bool>( (p) => { if (p.Raw.Customization?.Visibility is VisibilityOptions.Visible) { return(true); } else if (p.Raw.Customization?.Visibility is VisibilityOptions.IncludeButHide) { return(show); } else if (p.Raw.Customization?.Visibility is VisibilityOptions.Exclude) { return(false); // just in case. } else { return(true); } }))) .Filter(this.WhenAnyValue(x => x.Search) .Debounce(TimeSpan.FromMilliseconds(350), RxApp.MainThreadScheduler) .Select(x => x.Trim()) .DistinctUntilChanged() .Select(search => { if (string.IsNullOrWhiteSpace(search)) { return(new Func <PatcherStoreListingVM, bool>(_ => true)); } return(new Func <PatcherStoreListingVM, bool>( (p) => { if (p.Name.Contains(search, StringComparison.OrdinalIgnoreCase)) { return true; } if (p.Raw.Customization?.OneLineDescription?.Contains(search, StringComparison.OrdinalIgnoreCase) ?? false) { return true; } return false; })); })) .ToObservableCollection(this); OpenPopulationInfoCommand = ReactiveCommand.Create(() => Utility.NavigateToPath(Constants.ListingRepositoryAddress)); ClearSearchCommand = ReactiveCommand.Create(() => Search = string.Empty); }