feature: supports adding custom LFS track pattern

This commit is contained in:
leo 2024-06-18 14:14:13 +08:00
parent c56d0cf85e
commit a3c6431efa
No known key found for this signature in database
GPG key ID: B528468E49CD0E58
7 changed files with 113 additions and 0 deletions

View file

@ -0,0 +1,43 @@
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class LFSTrackCustomPattern : Popup
{
[Required(ErrorMessage = "LFS track pattern is required!!!")]
public string Pattern
{
get => _pattern;
set => SetProperty(ref _pattern, value, true);
}
public bool IsFilename
{
get;
set;
} = false;
public LFSTrackCustomPattern(Repository repo)
{
_repo = repo;
View = new Views.LFSTrackCustomPattern() { DataContext = this };
}
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
ProgressDescription = "Adding custom LFS tracking pattern ...";
return Task.Run(() =>
{
var succ = new Commands.LFS(_repo.FullPath).Track(_pattern, IsFilename);
CallUIThread(() => _repo.SetWatcherEnabled(true));
return succ;
});
}
private readonly Repository _repo = null;
private string _pattern = string.Empty;
}
}

View file

@ -834,6 +834,19 @@ namespace SourceGit.ViewModels
var lfs = new Commands.LFS(_fullpath);
if (lfs.IsEnabled())
{
var addPattern = new MenuItem();
addPattern.Header = App.Text("GitLFS.AddTrackPattern");
addPattern.Icon = App.CreateMenuIcon("Icons.File.Add");
addPattern.Click += (o, e) =>
{
if (PopupHost.CanCreatePopup())
PopupHost.ShowPopup(new LFSTrackCustomPattern(this));
e.Handled = true;
};
menu.Items.Add(addPattern);
menu.Items.Add(new MenuItem() { Header = "-" });
var fetch = new MenuItem();
fetch.Header = App.Text("GitLFS.Fetch");
fetch.Icon = App.CreateMenuIcon("Icons.Fetch");