Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggog committed Nov 25, 2024
2 parents 37be700 + e2b4df2 commit a7bba30
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 9 deletions.
10 changes: 9 additions & 1 deletion Synthesis.Bethesda.Execution/Modules/SolutionPatcherModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Autofac;
using Autofac;
using Mutagen.Bethesda.Synthesis.Projects;
using Noggog.Autofac;
using Synthesis.Bethesda.Execution.Patchers.Git.Services;
using Synthesis.Bethesda.Execution.Patchers.Solution;
Expand All @@ -18,5 +19,12 @@ protected override void Load(ContainerBuilder builder)
.NotInjection()
.AsImplementedInterfaces()
.AsSelf();

builder.RegisterAssemblyTypes(typeof(CreateTemplatePatcherSolution).Assembly)
.InNamespacesOf(
typeof(CreateTemplatePatcherSolution))
.NotInjection()
.AsImplementedInterfaces()
.AsSelf();
}
}
48 changes: 42 additions & 6 deletions Synthesis.Bethesda.GUI/Settings/BackupSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,55 @@ public BackupSettings(

public void Start()
{
_initRepository.Init(RepoDirectory);
CreateGitIgnore();
using var repo = _repositoryCheckouts.Get(RepoDirectory);
StageIfExists(GitIgnorePath, repo.Repository);
StageIfExists(PipelineSettings, repo.Repository);
StageIfExists(GuiSettings, repo.Repository);
try
{
_initRepository.Init(RepoDirectory);
}
catch (LibGit2SharpException e)
{
_logger.Warning(e, "Could not initiate backup repository.");
return;
}
try
{
CreateGitIgnore();
using var repo = _repositoryCheckouts.Get(RepoDirectory);
StageIfExists(GitIgnorePath, repo.Repository);
StageIfExists(PipelineSettings, repo.Repository);
StageIfExists(GuiSettings, repo.Repository);
repo.Repository.Commit("Settings changed");
}
catch (EmptyCommitException)
{
}
catch (Exception ex)
{
HandleException(ex);
}
}

private void HandleException(Exception? ex)
{
switch (ex)
{
case LibGit2SharpException:
case NullReferenceException:
WipeBackup(ex);
break;
case AggregateException agg:
HandleException(agg.InnerException);
break;
case null:
return;
default:
throw ex;
}
}

private void WipeBackup(Exception ex)
{
_logger.Warning(ex, "Wiping backup settings.");
_fileSystem.Directory.DeleteEntireFolder(RepoDirectory);
}

private void CreateGitIgnore()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.IO;
using System.Reactive.Linq;
using Mutagen.Bethesda.Environments.DI;
using Mutagen.Bethesda.Synthesis.Projects;
using Noggog;
using Noggog.WPF;
Expand Down Expand Up @@ -33,7 +32,6 @@ public class NewSolutionInitVm : ASolutionInitializer
public string ProjectNameWatermark => _projectNameWatermark.Value;

public NewSolutionInitVm(
IGameCategoryContext gameCategoryContext,
IPatcherFactory patcherFactory,
IValidateProjectPath validateProjectPath,
CreateTemplatePatcherSolution createTemplatePatcherSolution)
Expand Down

0 comments on commit a7bba30

Please sign in to comment.