refactor<*>: rewrite all with AvaloniaUI

This commit is contained in:
leo 2024-02-06 15:08:37 +08:00
parent 0136904612
commit 2a62596999
521 changed files with 19780 additions and 23244 deletions

View file

@ -2,59 +2,59 @@
using System.Text.RegularExpressions;
namespace SourceGit.Commands {
/// <summary>
/// 查看、添加或移除忽略变更文件
/// </summary>
public class AssumeUnchanged {
private string repo;
class ViewCommand : Command {
private static readonly Regex REG = new Regex(@"^(\w)\s+(.+)$");
private List<string> outs = new List<string>();
public ViewCommand(string repo) {
Cwd = repo;
WorkingDirectory = repo;
Args = "ls-files -v";
RaiseError = false;
}
public List<string> Result() {
Exec();
return outs;
return _outs;
}
public override void OnReadline(string line) {
protected override void OnReadline(string line) {
var match = REG.Match(line);
if (!match.Success) return;
if (match.Groups[1].Value == "h") {
outs.Add(match.Groups[2].Value);
_outs.Add(match.Groups[2].Value);
}
}
private List<string> _outs = new List<string>();
}
class ModCommand : Command {
public ModCommand(string repo, string file, bool bAdd) {
var mode = bAdd ? "--assume-unchanged" : "--no-assume-unchanged";
Cwd = repo;
WorkingDirectory = repo;
Context = repo;
Args = $"update-index {mode} -- \"{file}\"";
}
}
public AssumeUnchanged(string repo) {
this.repo = repo;
_repo = repo;
}
public List<string> View() {
return new ViewCommand(repo).Result();
return new ViewCommand(_repo).Result();
}
public void Add(string file) {
new ModCommand(repo, file, true).Exec();
new ModCommand(_repo, file, true).Exec();
}
public void Remove(string file) {
new ModCommand(repo, file, false).Exec();
new ModCommand(_repo, file, false).Exec();
}
private string _repo;
}
}