mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 04:04:59 +00:00
enhance: Git LFS support
This commit is contained in:
parent
e731807c91
commit
9a0b10bd9c
24 changed files with 780 additions and 34 deletions
|
@ -527,7 +527,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
|
||||
var assumeUnchanged = new MenuItem();
|
||||
assumeUnchanged.Header = App.Text("FileCM.AssumeUnchanged");
|
||||
assumeUnchanged.Icon = App.CreateMenuIcon("Icons.File.Ignore");
|
||||
|
@ -556,7 +556,9 @@ namespace SourceGit.ViewModels
|
|||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
menu.Items.Add(history);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
|
||||
|
||||
var extension = Path.GetExtension(change.Path);
|
||||
var hasExtra = false;
|
||||
if (change.WorkTree == Models.ChangeState.Untracked)
|
||||
{
|
||||
var isRooted = change.Path.IndexOf('/', StringComparison.Ordinal) <= 0;
|
||||
|
@ -583,8 +585,7 @@ namespace SourceGit.ViewModels
|
|||
};
|
||||
addToIgnore.Items.Add(byParentFolder);
|
||||
|
||||
var extension = Path.GetExtension(change.Path);
|
||||
if (!string.IsNullOrEmpty(extension))
|
||||
if (!string.IsNullOrEmpty(extension))
|
||||
{
|
||||
var byExtension = new MenuItem();
|
||||
byExtension.Header = App.Text("WorkingCopy.AddToGitIgnore.Extension", extension);
|
||||
|
@ -594,7 +595,7 @@ namespace SourceGit.ViewModels
|
|||
e.Handled = true;
|
||||
};
|
||||
addToIgnore.Items.Add(byExtension);
|
||||
|
||||
|
||||
var byExtensionInSameFolder = new MenuItem();
|
||||
byExtensionInSameFolder.Header = App.Text("WorkingCopy.AddToGitIgnore.ExtensionInSameFolder", extension);
|
||||
byExtensionInSameFolder.IsVisible = !isRooted;
|
||||
|
@ -607,8 +608,77 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
|
||||
menu.Items.Add(addToIgnore);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
hasExtra = true;
|
||||
}
|
||||
|
||||
var lfsEnabled = new Commands.LFS(_repo.FullPath).IsEnabled();
|
||||
if (lfsEnabled)
|
||||
{
|
||||
var lfs = new MenuItem();
|
||||
lfs.Header = App.Text("GitLFS");
|
||||
lfs.Icon = App.CreateMenuIcon("Icons.LFS");
|
||||
|
||||
var filename = Path.GetFileName(change.Path);
|
||||
var lfsTrackThisFile = new MenuItem();
|
||||
lfsTrackThisFile.Header = App.Text("GitLFS.Track", filename);
|
||||
lfsTrackThisFile.Click += async (_, e) =>
|
||||
{
|
||||
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Track(filename, true));
|
||||
if (succ)
|
||||
App.SendNotification(_repo.FullPath, $"Tracking file named {filename} successfully!");
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
lfs.Items.Add(lfsTrackThisFile);
|
||||
|
||||
if (!string.IsNullOrEmpty(extension))
|
||||
{
|
||||
var lfsTrackByExtension = new MenuItem();
|
||||
lfsTrackByExtension.Header = App.Text("GitLFS.TrackByExtension", extension);
|
||||
lfsTrackByExtension.Click += async (_, e) =>
|
||||
{
|
||||
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Track("*" + extension, false));
|
||||
if (succ)
|
||||
App.SendNotification(_repo.FullPath, $"Tracking all *{extension} files successfully!");
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
lfs.Items.Add(lfsTrackByExtension);
|
||||
}
|
||||
|
||||
var lfsLock = new MenuItem();
|
||||
lfsLock.Header = App.Text("GitLFS.Locks.Lock");
|
||||
lfsLock.Icon = App.CreateMenuIcon("Icons.Lock");
|
||||
lfsLock.Click += async (_, e) =>
|
||||
{
|
||||
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Lock(change.Path));
|
||||
if (succ)
|
||||
App.SendNotification(_repo.FullPath, $"Lock file \"{change.Path}\" successfully!");
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
lfs.Items.Add(new MenuItem() { Header = "-" });
|
||||
lfs.Items.Add(lfsLock);
|
||||
|
||||
var lfsUnlock = new MenuItem();
|
||||
lfsUnlock.Header = App.Text("GitLFS.Locks.Unlock");
|
||||
lfsUnlock.Icon = App.CreateMenuIcon("Icons.Unlock");
|
||||
lfsUnlock.Click += async (_, e) =>
|
||||
{
|
||||
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Unlock(change.Path, false));
|
||||
if (succ)
|
||||
App.SendNotification(_repo.FullPath, $"Unlock file \"{change.Path}\" successfully!");
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
lfs.Items.Add(lfsUnlock);
|
||||
|
||||
menu.Items.Add(lfs);
|
||||
hasExtra = true;
|
||||
}
|
||||
|
||||
if (hasExtra)
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
|
||||
var copy = new MenuItem();
|
||||
|
@ -702,9 +772,8 @@ namespace SourceGit.ViewModels
|
|||
stash.Click += (_, e) =>
|
||||
{
|
||||
if (PopupHost.CanCreatePopup())
|
||||
{
|
||||
PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false));
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
|
@ -797,9 +866,8 @@ namespace SourceGit.ViewModels
|
|||
stash.Click += (_, e) =>
|
||||
{
|
||||
if (PopupHost.CanCreatePopup())
|
||||
{
|
||||
PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, false));
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
|
@ -854,6 +922,45 @@ namespace SourceGit.ViewModels
|
|||
menu.Items.Add(stash);
|
||||
menu.Items.Add(patch);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
|
||||
var lfsEnabled = new Commands.LFS(_repo.FullPath).IsEnabled();
|
||||
if (lfsEnabled)
|
||||
{
|
||||
var lfs = new MenuItem();
|
||||
lfs.Header = App.Text("GitLFS");
|
||||
lfs.Icon = App.CreateMenuIcon("Icons.LFS");
|
||||
|
||||
var lfsLock = new MenuItem();
|
||||
lfsLock.Header = App.Text("GitLFS.Locks.Lock");
|
||||
lfsLock.Icon = App.CreateMenuIcon("Icons.Lock");
|
||||
lfsLock.Click += async (_, e) =>
|
||||
{
|
||||
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Lock(change.Path));
|
||||
if (succ)
|
||||
App.SendNotification(_repo.FullPath, $"Lock file \"{change.Path}\" successfully!");
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
lfs.Items.Add(new MenuItem() { Header = "-" });
|
||||
lfs.Items.Add(lfsLock);
|
||||
|
||||
var lfsUnlock = new MenuItem();
|
||||
lfsUnlock.Header = App.Text("GitLFS.Locks.Unlock");
|
||||
lfsUnlock.Icon = App.CreateMenuIcon("Icons.Unlock");
|
||||
lfsUnlock.Click += async (_, e) =>
|
||||
{
|
||||
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Unlock(change.Path, false));
|
||||
if (succ)
|
||||
App.SendNotification(_repo.FullPath, $"Unlock file \"{change.Path}\" successfully!");
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
lfs.Items.Add(lfsUnlock);
|
||||
|
||||
menu.Items.Add(lfs);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
|
||||
menu.Items.Add(copyPath);
|
||||
menu.Items.Add(copyFileName);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue