Skip to content

Commit c2b7c51

Browse files
Sync prob-specs-repo
1 parent c30fe28 commit c2b7c51

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

generators.new/CanonicalData.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System.Text.Json;
33
using System.Text.Json.Nodes;
44

5+
using LibGit2Sharp;
6+
57
namespace Generators;
68

79
internal record TestCase(
@@ -15,7 +17,25 @@ internal record TestCase(
1517
internal static class CanonicalData
1618
{
1719
private static readonly JsonSerializerOptions SerializerOptions = new() { PropertyNameCaseInsensitive = true };
18-
20+
21+
static CanonicalData()
22+
{
23+
CloneProbSpecsRepo();
24+
UpdateProbSpecsRepo();
25+
}
26+
27+
private static void CloneProbSpecsRepo()
28+
{
29+
if (!Directory.Exists(Paths.ProbSpecsDir))
30+
Repository.Clone("https://github.com/exercism/problem-specifications.git", Paths.ProbSpecsDir);
31+
}
32+
33+
private static void UpdateProbSpecsRepo()
34+
{
35+
using var repo = new Repository(Paths.ProbSpecsDir);
36+
Commands.Pull(repo, new Signature("Exercism", "[email protected]", DateTimeOffset.Now), new PullOptions());
37+
}
38+
1939
internal static TestCase[] Parse(string canonicalDataFile) =>
2040
Parse(JsonNode.Parse(File.ReadAllText(canonicalDataFile))!.AsObject(), ImmutableQueue<string>.Empty)
2141
.ToArray();

generators.new/Generators.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<PackageReference Include="CommandLineParser" Version="2.9.1" />
1212
<PackageReference Include="Handlebars.Net" Version="2.1.6" />
1313
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
14+
<PackageReference Include="LibGit2Sharp" Version="0.31.0" />
1415
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.12.0" />
1516
<PackageReference Include="Tomlyn" Version="0.18.0" />
1617
</ItemGroup>

generators.new/Paths.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ namespace Generators;
33
internal static class Paths
44
{
55
private static readonly string RootDir = GetRootDir();
6-
private static readonly string ProbSpecsExercisesDir = Path.Join(RootDir, ".problem-specifications", "exercises");
6+
internal static readonly string ProbSpecsDir = Path.Join(RootDir, ".problem-specifications");
7+
private static readonly string ProbSpecsExercisesDir = Path.Join(ProbSpecsDir, "exercises");
78
internal static readonly string PracticeExercisesDir = Path.Join(RootDir, "exercises", "practice");
89

910
internal static string ExerciseDir(Exercise exercise) => Path.Join(PracticeExercisesDir, exercise.Slug);

0 commit comments

Comments
 (0)