feature<Cleanup>: add toolbar button to run git gc and git lfs prune

This commit is contained in:
leo 2022-02-10 14:27:46 +08:00
parent bc404de937
commit b04c94ccc1
9 changed files with 103 additions and 1 deletions

21
src/Commands/GC.cs Normal file
View file

@ -0,0 +1,21 @@
using System;
namespace SourceGit.Commands {
/// <summary>
/// GC
/// </summary>
public class GC : Command {
private Action<string> handler;
public GC(string repo, Action<string> onProgress) {
Cwd = repo;
Args = "gc";
TraitErrorAsOutput = true;
handler = onProgress;
}
public override void OnReadline(string line) {
handler?.Invoke(line);
}
}
}

View file

@ -1,3 +1,4 @@
using System;
using System.IO;
namespace SourceGit.Commands {
@ -7,6 +8,21 @@ namespace SourceGit.Commands {
public class LFS {
private string repo;
private class PruneCmd : Command {
private Action<string> handler;
public PruneCmd(string repo, Action<string> onProgress) {
Cwd = repo;
Args = "lfs prune";
TraitErrorAsOutput = true;
handler = onProgress;
}
public override void OnReadline(string line) {
handler?.Invoke(line);
}
}
public LFS(string repo) {
this.repo = repo;
}
@ -27,5 +43,9 @@ namespace SourceGit.Commands {
var rs = cmd.ReadToEnd();
return rs.Output.Contains("filter\0lfs");
}
public void Prune(Action<string> onProgress) {
new PruneCmd(repo, onProgress).Exec();
}
}
}