-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #257 from adamralph/independent-tests
remove use of LibGit2Sharp from test assertion
- Loading branch information
Showing
9 changed files
with
111 additions
and
140 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 |
---|---|---|
@@ -1,41 +1,47 @@ | ||
namespace MinVerTests.Infra | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using LibGit2Sharp; | ||
using static MinVerTests.Infra.FileSystem; | ||
using static SimpleExec.Command; | ||
|
||
public static class Git | ||
{ | ||
public static Repository EnsureEmptyRepositoryAndCommit(string path) | ||
public static void EnsureEmptyRepositoryAndCommit(string path) | ||
{ | ||
var repo = EnsureEmptyRepository(path); | ||
|
||
EnsureEmptyRepository(path); | ||
Commit(path); | ||
|
||
return repo; | ||
} | ||
|
||
public static void Commit(string path) => Run("git", "commit -m '.' --allow-empty", path); | ||
|
||
public static Repository EnsureEmptyRepository(string path) | ||
public static void EnsureEmptyRepository(string path) | ||
{ | ||
EnsureEmptyDirectory(path); | ||
|
||
Repository.Init(path); | ||
|
||
return new Repository(path).PrepareForCommits(); | ||
Init(path); | ||
PrepareForCommits(path); | ||
} | ||
|
||
public static Repository PrepareForCommits(this Repository repo) | ||
{ | ||
repo.Config.Set("user.email", "johndoe @tempuri.org"); | ||
repo.Config.Set("user.name", "John Doe"); | ||
repo.Config.Set("commit.gpgsign", "false"); | ||
public static void Init(string path) => Run("git", "init", path); | ||
|
||
return repo; | ||
public static void PrepareForCommits(string path) | ||
{ | ||
Run("git", "config user.email [email protected]", path); | ||
Run("git", "config user.name John Doe", path); | ||
Run("git", "config commit.gpgsign false", path); | ||
} | ||
|
||
public static Task<string> GetGraph(string path) => ReadAsync("git", "log --graph --pretty=format:'%d'", path); | ||
|
||
internal static void Tag(string path, string tag) => Run("git", $"tag {tag}", path); | ||
|
||
internal static void Tag(string path, string tagName, string sha) => Run("git", $"tag {tagName} {sha}", path); | ||
|
||
internal static IEnumerable<string> GetCommitShas(string path) => | ||
Read("git", "log --pretty=format:\"%H\"", path, noEcho: true) | ||
.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); | ||
|
||
internal static void Checkout(string path, string sha) => Run("git", $"checkout {sha}", path); | ||
} | ||
} |
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
Oops, something went wrong.