Skip to content

Commit e26290d

Browse files
authored
Merge pull request #9 from openrails/feature/improved-merging
fix: Clean up working tree when resetting commits
2 parents cef1c63 + 5ff42c7 commit e26290d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Git/Project.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public void ResetHard()
4949
RunCommand("reset --hard");
5050
}
5151

52+
public void Clean()
53+
{
54+
RunCommand("clean --force -d -x");
55+
}
56+
5257
public void Merge(string reference)
5358
{
5459
RunCommand($"merge --no-edit --no-ff {reference}");

Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static async Task AsyncMain(IConfigurationRoot config)
8686
git.Init($"https://github.com/{gitHubConfig["organization"]}/{gitHubConfig["repository"]}.git");
8787
git.Fetch();
8888
git.ResetHard();
89+
git.Clean();
8990
var baseBranchCommit = git.ParseRef(gitHubConfig["baseBranch"]);
9091
var mergeBranchCommit = git.ParseRef(gitHubConfig["mergeBranch"]);
9192
var mergeBranchTree = git.ParseRef($"{mergeBranchCommit}^{{tree}}");
@@ -110,6 +111,7 @@ static async Task AsyncMain(IConfigurationRoot config)
110111
{
111112
autoMergePullRequestsFailure.Add(pullRequest);
112113
git.ResetHard();
114+
git.Clean();
113115
Console.WriteLine($"Error: {error.Message}");
114116
}
115117
}

0 commit comments

Comments
 (0)