-
-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0eaef3
commit a5149b0
Showing
6 changed files
with
65 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,16 +2,12 @@ | |
using System.Text.Json; | ||
using System.Text.Json.Nodes; | ||
|
||
using LibGit2Sharp; | ||
|
||
namespace Generators; | ||
|
||
internal record CanonicalData(Exercise Exercise, JsonNode[] TestCases); | ||
|
||
internal static class CanonicalDataParser | ||
{ | ||
static CanonicalDataParser() => ProbSpecs.Sync(); | ||
|
||
internal static CanonicalData Parse(Exercise exercise) => new(exercise, ParseTestCases(exercise)); | ||
|
||
private static JsonNode[] ParseTestCases(Exercise exercise) => | ||
|
@@ -36,26 +32,4 @@ private static JsonNode ToTestCase(JsonNode testCaseJson, IEnumerable<string> pa | |
testCaseJson["path"] = JsonSerializer.SerializeToNode(path); | ||
return testCaseJson; | ||
} | ||
|
||
private static class ProbSpecs | ||
{ | ||
internal static void Sync() | ||
{ | ||
Clone(); | ||
Pull(); | ||
} | ||
|
||
private static void Clone() | ||
{ | ||
if (!Directory.Exists(Paths.ProbSpecsDir)) | ||
Repository.Clone("https://github.com/exercism/problem-specifications.git", Paths.ProbSpecsDir); | ||
} | ||
|
||
private static void Pull() | ||
{ | ||
using var repo = new Repository(Paths.ProbSpecsDir); | ||
Commands.Pull(repo, new Signature("Exercism", "[email protected]", DateTimeOffset.Now), new PullOptions()); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using LibGit2Sharp; | ||
|
||
namespace Generators; | ||
|
||
internal static class ProbSpecs | ||
{ | ||
internal static void Sync() | ||
{ | ||
Clone(); | ||
Pull(); | ||
} | ||
|
||
private static void Clone() | ||
{ | ||
if (!Directory.Exists(Paths.ProbSpecsDir)) | ||
Repository.Clone("https://github.com/exercism/problem-specifications.git", Paths.ProbSpecsDir); | ||
} | ||
|
||
private static void Pull() | ||
{ | ||
using var repo = new Repository(Paths.ProbSpecsDir); | ||
Commands.Pull(repo, new Signature("Exercism", "[email protected]", DateTimeOffset.Now), new PullOptions()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters