mirror of
https://github.com/FalloutCollaborationProject/FCP-Mod-Updater.git
synced 2026-07-27 17:04:05 -07:00
Improve Checking out older commits
This commit is contained in:
@@ -174,6 +174,16 @@ public partial class GitService : IGitService
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> ResetToCommitAsync(string path, string commitHash, CancellationToken ct = default)
|
||||
{
|
||||
var (exitCode, _, _) = await RunGitCommandAsync(path, $"reset --hard \"{commitHash}\"", ct);
|
||||
if (exitCode != 0)
|
||||
return false;
|
||||
|
||||
await RunGitCommandAsync(path, "submodule update --init --recursive", ct);
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> HasLocalChangesAsync(string path, CancellationToken ct = default)
|
||||
{
|
||||
var (exitCode, output, _) = await RunGitCommandAsync(path, "status --porcelain", ct);
|
||||
|
||||
@@ -15,6 +15,7 @@ public interface IGitService
|
||||
Task<bool> CloneAsync(string url, string targetPath, IProgress<string>? progress = null, IProgress<double>? percentProgress = null, CancellationToken ct = default);
|
||||
Task<IReadOnlyList<string>> GetRemoteBranchesAsync(string path, CancellationToken ct = default);
|
||||
Task<bool> CheckoutAsync(string path, string branchOrCommit, CancellationToken ct = default);
|
||||
Task<bool> ResetToCommitAsync(string path, string commitHash, CancellationToken ct = default);
|
||||
Task<bool> HasLocalChangesAsync(string path, CancellationToken ct = default);
|
||||
Task<IReadOnlyList<GitCommitInfo>> GetCommitHistoryAsync(string path, int limit = 20, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user