Skip to content

Commit

Permalink
actually save new repo state
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Oct 2, 2024
1 parent 1e0782b commit d17152e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Plogon/BuildProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1302,20 +1302,16 @@ private BuildResult.ReviewedNeed GetNeedStatus(string key, string version, State

private void CommitReviewedNeeds(IEnumerable<BuildResult.ReviewedNeed> needs)
{
foreach (var need in needs)
{
if (need.ReviewedBy != null)
continue;

this.pluginRepository.State.ReviewedNeeds.Add(new State.Need
this.pluginRepository.AddReviewedNeeds(needs
.Where(need => need.ReviewedBy != null)
.Select(need => new State.Need
{
Key = need.Name,
ReviewedBy = this.actor ?? throw new Exception("Committing, but reviewer is null"),
Version = need.Version,
ReviewedAt = DateTime.UtcNow,
Type = need.Type,
});
}
}));
}

private static void CopySourceForArchive(DirectoryInfo from, DirectoryInfo to, int depth = 0)
Expand Down
30 changes: 30 additions & 0 deletions Plogon/Repo/PluginRepository.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

Expand Down Expand Up @@ -148,4 +149,33 @@ public void UpdatePluginHave(string channelName, string plugin, string haveCommi

SaveState();
}

/// <summary>
/// Add a list of needs to the repository.
/// </summary>
/// <param name="needs">The needs to add.</param>
public void AddReviewedNeeds(IEnumerable<State.Need> needs)
{
foreach (var need in needs)
{
AddReviewedNeed(need);
}

this.SaveState();
}

/// <summary>
/// Add a need to the repository.
/// </summary>
/// <param name="need">The need to add.</param>
/// <exception cref="Exception">Thrown if the need was already reviewed.</exception>
private void AddReviewedNeed(State.Need need)
{
if (this.State.ReviewedNeeds.Any(x => x.Key == need.Key && x.Version == need.Version))
{
throw new Exception($"Need {need.Key}(v{need.Version}) already in state");
}

this.State.ReviewedNeeds.Add(need);
}
}

0 comments on commit d17152e

Please sign in to comment.