enhance: Git LFS supports (#209)

* add a new context menu to push local LFS object to selected remote
* supports to choose remote for fetch/pull/push/lock/unlock actions
* auto select remote if there's only one remote
This commit is contained in:
leo 2024-06-26 11:49:56 +08:00
parent f18ecf53eb
commit 0c21bcd06a
No known key found for this signature in database
14 changed files with 359 additions and 59 deletions

View file

@ -55,14 +55,19 @@ namespace SourceGit.Commands
return new SubCmd(_repo, $"lfs track {opt} \"{pattern}\"", null).Exec(); return new SubCmd(_repo, $"lfs track {opt} \"{pattern}\"", null).Exec();
} }
public void Fetch(Action<string> outputHandler) public void Fetch(string remote, Action<string> outputHandler)
{ {
new SubCmd(_repo, $"lfs fetch", outputHandler).Exec(); new SubCmd(_repo, $"lfs fetch {remote}", outputHandler).Exec();
} }
public void Pull(Action<string> outputHandler) public void Pull(string remote, Action<string> outputHandler)
{ {
new SubCmd(_repo, $"lfs pull", outputHandler).Exec(); new SubCmd(_repo, $"lfs pull {remote}", outputHandler).Exec();
}
public void Push(string remote, Action<string> outputHandler)
{
new SubCmd(_repo, $"lfs push {remote}", outputHandler).Exec();
} }
public void Prune(Action<string> outputHandler) public void Prune(Action<string> outputHandler)
@ -70,10 +75,10 @@ namespace SourceGit.Commands
new SubCmd(_repo, "lfs prune", outputHandler).Exec(); new SubCmd(_repo, "lfs prune", outputHandler).Exec();
} }
public List<Models.LFSLock> Locks() public List<Models.LFSLock> Locks(string remote)
{ {
var locks = new List<Models.LFSLock>(); var locks = new List<Models.LFSLock>();
var cmd = new SubCmd(_repo, "lfs locks", null); var cmd = new SubCmd(_repo, $"lfs locks --remote={remote}", null);
var rs = cmd.ReadToEnd(); var rs = cmd.ReadToEnd();
if (rs.IsSuccess) if (rs.IsSuccess)
{ {
@ -96,21 +101,21 @@ namespace SourceGit.Commands
return locks; return locks;
} }
public bool Lock(string file) public bool Lock(string remote, string file)
{ {
return new SubCmd(_repo, $"lfs lock \"{file}\"", null).Exec(); return new SubCmd(_repo, $"lfs lock --remote={remote} \"{file}\"", null).Exec();
} }
public bool Unlock(string file, bool force) public bool Unlock(string remote, string file, bool force)
{ {
var opt = force ? "-f" : ""; var opt = force ? "-f" : "";
return new SubCmd(_repo, $"lfs unlock {opt} \"{file}\"", null).Exec(); return new SubCmd(_repo, $"lfs unlock --remote={remote} {opt} \"{file}\"", null).Exec();
} }
public bool Unlock(long id, bool force) public bool Unlock(string remote, long id, bool force)
{ {
var opt = force ? "-f" : ""; var opt = force ? "-f" : "";
return new SubCmd(_repo, $"lfs unlock {opt} --id={id}", null).Exec(); return new SubCmd(_repo, $"lfs unlock --remote={remote} {opt} --id={id}", null).Exec();
} }
private readonly string _repo; private readonly string _repo;

View file

@ -254,6 +254,10 @@
<x:String x:Key="Text.GitLFS.Pull" xml:space="preserve">Pull</x:String> <x:String x:Key="Text.GitLFS.Pull" xml:space="preserve">Pull</x:String>
<x:String x:Key="Text.GitLFS.Pull.Title" xml:space="preserve">Pull LFS Objects</x:String> <x:String x:Key="Text.GitLFS.Pull.Title" xml:space="preserve">Pull LFS Objects</x:String>
<x:String x:Key="Text.GitLFS.Pull.Tips" xml:space="preserve">Run `git lfs pull` to download all Git LFS files for current ref &amp; checkout</x:String> <x:String x:Key="Text.GitLFS.Pull.Tips" xml:space="preserve">Run `git lfs pull` to download all Git LFS files for current ref &amp; checkout</x:String>
<x:String x:Key="Text.GitLFS.Push" xml:space="preserve">Push</x:String>
<x:String x:Key="Text.GitLFS.Push.Title" xml:space="preserve">Push LFS Objects</x:String>
<x:String x:Key="Text.GitLFS.Push.Tips" xml:space="preserve">Push queued large files to the Git LFS endpoint</x:String>
<x:String x:Key="Text.GitLFS.Remote" xml:space="preserve">Remote:</x:String>
<x:String x:Key="Text.GitLFS.Track" xml:space="preserve">Track files named '{0}'</x:String> <x:String x:Key="Text.GitLFS.Track" xml:space="preserve">Track files named '{0}'</x:String>
<x:String x:Key="Text.GitLFS.TrackByExtension" xml:space="preserve">Track all *{0} files</x:String> <x:String x:Key="Text.GitLFS.TrackByExtension" xml:space="preserve">Track all *{0} files</x:String>
<x:String x:Key="Text.Histories" xml:space="preserve">Histories</x:String> <x:String x:Key="Text.Histories" xml:space="preserve">Histories</x:String>

View file

@ -257,6 +257,10 @@
<x:String x:Key="Text.GitLFS.Pull" xml:space="preserve">拉回LFS对象 (pull)</x:String> <x:String x:Key="Text.GitLFS.Pull" xml:space="preserve">拉回LFS对象 (pull)</x:String>
<x:String x:Key="Text.GitLFS.Pull.Title" xml:space="preserve">拉回LFS对象</x:String> <x:String x:Key="Text.GitLFS.Pull.Title" xml:space="preserve">拉回LFS对象</x:String>
<x:String x:Key="Text.GitLFS.Pull.Tips" xml:space="preserve">运行`git lfs pull`命令下载远程LFS对象并更新工作副本。</x:String> <x:String x:Key="Text.GitLFS.Pull.Tips" xml:space="preserve">运行`git lfs pull`命令下载远程LFS对象并更新工作副本。</x:String>
<x:String x:Key="Text.GitLFS.Push" xml:space="preserve">推送</x:String>
<x:String x:Key="Text.GitLFS.Push.Title" xml:space="preserve">推送LFS对象</x:String>
<x:String x:Key="Text.GitLFS.Push.Tips" xml:space="preserve">将排队的大文件推送到Git LFS远程服务</x:String>
<x:String x:Key="Text.GitLFS.Remote" xml:space="preserve">远程 </x:String>
<x:String x:Key="Text.GitLFS.Track" xml:space="preserve">跟踪名为'{0}'的文件</x:String> <x:String x:Key="Text.GitLFS.Track" xml:space="preserve">跟踪名为'{0}'的文件</x:String>
<x:String x:Key="Text.GitLFS.TrackByExtension" xml:space="preserve">跟踪所有 *{0} 文件</x:String> <x:String x:Key="Text.GitLFS.TrackByExtension" xml:space="preserve">跟踪所有 *{0} 文件</x:String>
<x:String x:Key="Text.Histories" xml:space="preserve">历史记录</x:String> <x:String x:Key="Text.Histories" xml:space="preserve">历史记录</x:String>

View file

@ -257,6 +257,10 @@
<x:String x:Key="Text.GitLFS.Pull" xml:space="preserve">拉回LFS物件 (pull)</x:String> <x:String x:Key="Text.GitLFS.Pull" xml:space="preserve">拉回LFS物件 (pull)</x:String>
<x:String x:Key="Text.GitLFS.Pull.Title" xml:space="preserve">拉回LFS物件</x:String> <x:String x:Key="Text.GitLFS.Pull.Title" xml:space="preserve">拉回LFS物件</x:String>
<x:String x:Key="Text.GitLFS.Pull.Tips" xml:space="preserve">執行`git lfs pull`命令下載遠端LFS物件并更新工作副本。</x:String> <x:String x:Key="Text.GitLFS.Pull.Tips" xml:space="preserve">執行`git lfs pull`命令下載遠端LFS物件并更新工作副本。</x:String>
<x:String x:Key="Text.GitLFS.Push" xml:space="preserve">推送</x:String>
<x:String x:Key="Text.GitLFS.Push.Title" xml:space="preserve">推送LFS物件</x:String>
<x:String x:Key="Text.GitLFS.Push.Tips" xml:space="preserve">將排隊的大檔推送到Git LFS遠端服務</x:String>
<x:String x:Key="Text.GitLFS.Remote" xml:space="preserve">遠端倉庫 </x:String>
<x:String x:Key="Text.GitLFS.Track" xml:space="preserve">跟蹤名為'{0}'的檔案</x:String> <x:String x:Key="Text.GitLFS.Track" xml:space="preserve">跟蹤名為'{0}'的檔案</x:String>
<x:String x:Key="Text.GitLFS.TrackByExtension" xml:space="preserve">跟蹤所有 *{0} 檔案</x:String> <x:String x:Key="Text.GitLFS.TrackByExtension" xml:space="preserve">跟蹤所有 *{0} 檔案</x:String>
<x:String x:Key="Text.Histories" xml:space="preserve">歷史記錄</x:String> <x:String x:Key="Text.Histories" xml:space="preserve">歷史記錄</x:String>

View file

@ -1,12 +1,22 @@
using System.Threading.Tasks; using System.Collections.Generic;
using System.Threading.Tasks;
namespace SourceGit.ViewModels namespace SourceGit.ViewModels
{ {
public class LFSFetch : Popup public class LFSFetch : Popup
{ {
public List<Models.Remote> Remotes => _repo.Remotes;
public Models.Remote SelectedRemote
{
get;
set;
}
public LFSFetch(Repository repo) public LFSFetch(Repository repo)
{ {
_repo = repo; _repo = repo;
SelectedRemote = _repo.Remotes[0];
View = new Views.LFSFetch() { DataContext = this }; View = new Views.LFSFetch() { DataContext = this };
} }
@ -16,7 +26,7 @@ namespace SourceGit.ViewModels
ProgressDescription = $"Fetching LFS objects from remote ..."; ProgressDescription = $"Fetching LFS objects from remote ...";
return Task.Run(() => return Task.Run(() =>
{ {
new Commands.LFS(_repo.FullPath).Fetch(SetProgressDescription); new Commands.LFS(_repo.FullPath).Fetch(SelectedRemote.Name, SetProgressDescription);
CallUIThread(() => _repo.SetWatcherEnabled(true)); CallUIThread(() => _repo.SetWatcherEnabled(true));
return true; return true;
}); });

View file

@ -27,14 +27,15 @@ namespace SourceGit.ViewModels
private set; private set;
} }
public LFSLocks(string repo) public LFSLocks(string repo, string remote)
{ {
_repo = repo; _repo = repo;
_remote = remote;
Locks = new AvaloniaList<Models.LFSLock>(); Locks = new AvaloniaList<Models.LFSLock>();
Task.Run(() => Task.Run(() =>
{ {
var collect = new Commands.LFS(_repo).Locks(); var collect = new Commands.LFS(_repo).Locks(_remote);
Dispatcher.UIThread.Invoke(() => Dispatcher.UIThread.Invoke(() =>
{ {
if (collect.Count > 0) if (collect.Count > 0)
@ -54,7 +55,7 @@ namespace SourceGit.ViewModels
IsLoading = true; IsLoading = true;
Task.Run(() => Task.Run(() =>
{ {
var succ = new Commands.LFS(_repo).Unlock(lfsLock.ID, force); var succ = new Commands.LFS(_repo).Unlock(_remote, lfsLock.ID, force);
Dispatcher.UIThread.Invoke(() => Dispatcher.UIThread.Invoke(() =>
{ {
if (succ) if (succ)
@ -67,6 +68,7 @@ namespace SourceGit.ViewModels
} }
private string _repo = string.Empty; private string _repo = string.Empty;
private string _remote = string.Empty;
private bool _isLoading = true; private bool _isLoading = true;
private bool _isEmpty = false; private bool _isEmpty = false;
} }

View file

@ -1,12 +1,22 @@
using System.Threading.Tasks; using System.Collections.Generic;
using System.Threading.Tasks;
namespace SourceGit.ViewModels namespace SourceGit.ViewModels
{ {
public class LFSPull : Popup public class LFSPull : Popup
{ {
public List<Models.Remote> Remotes => _repo.Remotes;
public Models.Remote SelectedRemote
{
get;
set;
}
public LFSPull(Repository repo) public LFSPull(Repository repo)
{ {
_repo = repo; _repo = repo;
SelectedRemote = _repo.Remotes[0];
View = new Views.LFSPull() { DataContext = this }; View = new Views.LFSPull() { DataContext = this };
} }
@ -16,7 +26,7 @@ namespace SourceGit.ViewModels
ProgressDescription = $"Pull LFS objects from remote ..."; ProgressDescription = $"Pull LFS objects from remote ...";
return Task.Run(() => return Task.Run(() =>
{ {
new Commands.LFS(_repo.FullPath).Pull(SetProgressDescription); new Commands.LFS(_repo.FullPath).Pull(SelectedRemote.Name, SetProgressDescription);
CallUIThread(() => _repo.SetWatcherEnabled(true)); CallUIThread(() => _repo.SetWatcherEnabled(true));
return true; return true;
}); });

37
src/ViewModels/LFSPush.cs Normal file
View file

@ -0,0 +1,37 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class LFSPush : Popup
{
public List<Models.Remote> Remotes => _repo.Remotes;
public Models.Remote SelectedRemote
{
get;
set;
}
public LFSPush(Repository repo)
{
_repo = repo;
SelectedRemote = _repo.Remotes[0];
View = new Views.LFSPush() { DataContext = this };
}
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
ProgressDescription = $"Push LFS objects to remote ...";
return Task.Run(() =>
{
new Commands.LFS(_repo.FullPath).Push(SelectedRemote.Name, SetProgressDescription);
CallUIThread(() => _repo.SetWatcherEnabled(true));
return true;
});
}
private readonly Repository _repo = null;
}
}

View file

@ -911,6 +911,24 @@ namespace SourceGit.ViewModels
}; };
menu.Items.Add(pull); menu.Items.Add(pull);
var push = new MenuItem();
push.Header = App.Text("GitLFS.Push");
push.Icon = App.CreateMenuIcon("Icons.Push");
push.IsEnabled = Remotes.Count > 0;
push.Click += (o, e) =>
{
if (PopupHost.CanCreatePopup())
{
if (Remotes.Count == 1)
PopupHost.ShowAndStartPopup(new LFSPush(this));
else
PopupHost.ShowPopup(new LFSPush(this));
}
e.Handled = true;
};
menu.Items.Add(push);
var prune = new MenuItem(); var prune = new MenuItem();
prune.Header = App.Text("GitLFS.Prune"); prune.Header = App.Text("GitLFS.Prune");
prune.Icon = App.CreateMenuIcon("Icons.Clean"); prune.Icon = App.CreateMenuIcon("Icons.Clean");
@ -927,13 +945,33 @@ namespace SourceGit.ViewModels
var locks = new MenuItem(); var locks = new MenuItem();
locks.Header = App.Text("GitLFS.Locks"); locks.Header = App.Text("GitLFS.Locks");
locks.Icon = App.CreateMenuIcon("Icons.Lock"); locks.Icon = App.CreateMenuIcon("Icons.Lock");
locks.Click += (o, e) => locks.IsEnabled = Remotes.Count > 0;
if (Remotes.Count == 1)
{ {
var dialog = new Views.LFSLocks() { DataContext = new LFSLocks(_fullpath) }; locks.Click += (o, e) =>
dialog.Show(App.GetTopLevel() as Window); {
var dialog = new Views.LFSLocks() { DataContext = new LFSLocks(_fullpath, Remotes[0].Name) };
dialog.Show(App.GetTopLevel() as Window);
e.Handled = true;
};
}
else
{
foreach (var remote in Remotes)
{
var remoteName = remote.Name;
var lockRemote = new MenuItem();
lockRemote.Header = remoteName;
lockRemote.Click += (o, e) =>
{
var dialog = new Views.LFSLocks() { DataContext = new LFSLocks(_fullpath, remoteName) };
dialog.Show(App.GetTopLevel() as Window);
e.Handled = true;
};
locks.Items.Add(lockRemote);
}
}
e.Handled = true;
};
menu.Items.Add(new MenuItem() { Header = "-" }); menu.Items.Add(new MenuItem() { Header = "-" });
menu.Items.Add(locks); menu.Items.Add(locks);
} }

View file

@ -643,27 +643,71 @@ namespace SourceGit.ViewModels
var lfsLock = new MenuItem(); var lfsLock = new MenuItem();
lfsLock.Header = App.Text("GitLFS.Locks.Lock"); lfsLock.Header = App.Text("GitLFS.Locks.Lock");
lfsLock.Icon = App.CreateMenuIcon("Icons.Lock"); lfsLock.Icon = App.CreateMenuIcon("Icons.Lock");
lfsLock.Click += async (_, e) => lfsLock.IsEnabled = _repo.Remotes.Count > 0;
if (_repo.Remotes.Count == 1)
{ {
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Lock(change.Path)); lfsLock.Click += async (o, e) =>
if (succ) {
App.SendNotification(_repo.FullPath, $"Lock file \"{change.Path}\" successfully!"); var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Lock(_repo.Remotes[0].Name, change.Path));
if (succ)
App.SendNotification(_repo.FullPath, $"Lock file \"{change.Path}\" successfully!");
e.Handled = true; e.Handled = true;
}; };
}
else
{
foreach (var remote in _repo.Remotes)
{
var remoteName = remote.Name;
var lockRemote = new MenuItem();
lockRemote.Header = remoteName;
lockRemote.Click += async (o, e) =>
{
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Lock(remoteName, change.Path));
if (succ)
App.SendNotification(_repo.FullPath, $"Lock file \"{change.Path}\" successfully!");
e.Handled = true;
};
lfsLock.Items.Add(lockRemote);
}
}
lfs.Items.Add(lfsLock); lfs.Items.Add(lfsLock);
var lfsUnlock = new MenuItem(); var lfsUnlock = new MenuItem();
lfsUnlock.Header = App.Text("GitLFS.Locks.Unlock"); lfsUnlock.Header = App.Text("GitLFS.Locks.Unlock");
lfsUnlock.Icon = App.CreateMenuIcon("Icons.Unlock"); lfsUnlock.Icon = App.CreateMenuIcon("Icons.Unlock");
lfsUnlock.Click += async (_, e) => lfsUnlock.IsEnabled = _repo.Remotes.Count > 0;
if (_repo.Remotes.Count == 1)
{ {
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Unlock(change.Path, false)); lfsUnlock.Click += async (o, e) =>
if (succ) {
App.SendNotification(_repo.FullPath, $"Unlock file \"{change.Path}\" successfully!"); var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Unlock(_repo.Remotes[0].Name, change.Path, false));
if (succ)
App.SendNotification(_repo.FullPath, $"Unlock file \"{change.Path}\" successfully!");
e.Handled = true; e.Handled = true;
}; };
}
else
{
foreach (var remote in _repo.Remotes)
{
var remoteName = remote.Name;
var unlockRemote = new MenuItem();
unlockRemote.Header = remoteName;
unlockRemote.Click += async (o, e) =>
{
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Unlock(remoteName, change.Path, false));
if (succ)
App.SendNotification(_repo.FullPath, $"Unlock file \"{change.Path}\" successfully!");
e.Handled = true;
};
lfsUnlock.Items.Add(unlockRemote);
}
}
lfs.Items.Add(lfsUnlock); lfs.Items.Add(lfsUnlock);
menu.Items.Add(lfs); menu.Items.Add(lfs);
@ -926,28 +970,71 @@ namespace SourceGit.ViewModels
var lfsLock = new MenuItem(); var lfsLock = new MenuItem();
lfsLock.Header = App.Text("GitLFS.Locks.Lock"); lfsLock.Header = App.Text("GitLFS.Locks.Lock");
lfsLock.Icon = App.CreateMenuIcon("Icons.Lock"); lfsLock.Icon = App.CreateMenuIcon("Icons.Lock");
lfsLock.Click += async (_, e) => lfsLock.IsEnabled = _repo.Remotes.Count > 0;
if (_repo.Remotes.Count == 1)
{ {
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Lock(change.Path)); lfsLock.Click += async (o, e) =>
if (succ) {
App.SendNotification(_repo.FullPath, $"Lock file \"{change.Path}\" successfully!"); var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Lock(_repo.Remotes[0].Name, change.Path));
if (succ)
App.SendNotification(_repo.FullPath, $"Lock file \"{change.Path}\" successfully!");
e.Handled = true; e.Handled = true;
}; };
lfs.Items.Add(new MenuItem() { Header = "-" }); }
else
{
foreach (var remote in _repo.Remotes)
{
var remoteName = remote.Name;
var lockRemote = new MenuItem();
lockRemote.Header = remoteName;
lockRemote.Click += async (o, e) =>
{
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Lock(remoteName, change.Path));
if (succ)
App.SendNotification(_repo.FullPath, $"Lock file \"{change.Path}\" successfully!");
e.Handled = true;
};
lfsLock.Items.Add(lockRemote);
}
}
lfs.Items.Add(lfsLock); lfs.Items.Add(lfsLock);
var lfsUnlock = new MenuItem(); var lfsUnlock = new MenuItem();
lfsUnlock.Header = App.Text("GitLFS.Locks.Unlock"); lfsUnlock.Header = App.Text("GitLFS.Locks.Unlock");
lfsUnlock.Icon = App.CreateMenuIcon("Icons.Unlock"); lfsUnlock.Icon = App.CreateMenuIcon("Icons.Unlock");
lfsUnlock.Click += async (_, e) => lfsUnlock.IsEnabled = _repo.Remotes.Count > 0;
if (_repo.Remotes.Count == 1)
{ {
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Unlock(change.Path, false)); lfsUnlock.Click += async (o, e) =>
if (succ) {
App.SendNotification(_repo.FullPath, $"Unlock file \"{change.Path}\" successfully!"); var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Unlock(_repo.Remotes[0].Name, change.Path, false));
if (succ)
App.SendNotification(_repo.FullPath, $"Unlock file \"{change.Path}\" successfully!");
e.Handled = true; e.Handled = true;
}; };
}
else
{
foreach (var remote in _repo.Remotes)
{
var remoteName = remote.Name;
var unlockRemote = new MenuItem();
unlockRemote.Header = remoteName;
unlockRemote.Click += async (o, e) =>
{
var succ = await Task.Run(() => new Commands.LFS(_repo.FullPath).Unlock(remoteName, change.Path, false));
if (succ)
App.SendNotification(_repo.FullPath, $"Unlock file \"{change.Path}\" successfully!");
e.Handled = true;
};
lfsUnlock.Items.Add(unlockRemote);
}
}
lfs.Items.Add(lfsUnlock); lfs.Items.Add(lfsUnlock);
menu.Items.Add(lfs); menu.Items.Add(lfs);

View file

@ -5,14 +5,37 @@
xmlns:m="using:SourceGit.Models" xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels" xmlns:vm="using:SourceGit.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.LFSFetch"> x:Class="SourceGit.Views.LFSFetch"
x:DataType="vm:LFSFetch">
<StackPanel Orientation="Vertical" Margin="8,0"> <StackPanel Orientation="Vertical" Margin="8,0">
<TextBlock FontSize="18" <TextBlock FontSize="18"
Classes="bold" Classes="bold"
Text="{DynamicResource Text.GitLFS.Fetch.Title}"/> Text="{DynamicResource Text.GitLFS.Fetch.Title}"/>
<TextBlock Text="{DynamicResource Text.GitLFS.Fetch.Tips}"
Margin="8,16,8,0" <Grid Margin="0,16,0,0" RowDefinitions="32,Auto" ColumnDefinitions="120,*">
HorizontalAlignment="Center" <TextBlock Grid.Row="0" Grid.Column="0"
TextWrapping="Wrap"/> HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
Text="{DynamicResource Text.GitLFS.Remote}"/>
<ComboBox Grid.Row="0" Grid.Column="1"
Height="28" Padding="8,0"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
ItemsSource="{Binding Remotes}"
SelectedItem="{Binding SelectedRemote, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="{x:Type m:Remote}">
<StackPanel Orientation="Horizontal" Height="20" VerticalAlignment="Center">
<Path Margin="0,6,8,0" Width="14" Height="14" Fill="{DynamicResource Brush.FG1}" Data="{StaticResource Icons.Remote}"/>
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Grid.Row="1" Grid.Column="1"
Text="{DynamicResource Text.GitLFS.Fetch.Tips}"
Margin="0,8,0,0"
TextWrapping="Wrap"/>
</Grid>
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View file

@ -5,14 +5,37 @@
xmlns:m="using:SourceGit.Models" xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels" xmlns:vm="using:SourceGit.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.LFSPull"> x:Class="SourceGit.Views.LFSPull"
x:DataType="vm:LFSPull">
<StackPanel Orientation="Vertical" Margin="8,0"> <StackPanel Orientation="Vertical" Margin="8,0">
<TextBlock FontSize="18" <TextBlock FontSize="18"
Classes="bold" Classes="bold"
Text="{DynamicResource Text.GitLFS.Pull.Title}"/> Text="{DynamicResource Text.GitLFS.Pull.Title}"/>
<TextBlock Text="{DynamicResource Text.GitLFS.Pull.Tips}"
Margin="8,16,8,0" <Grid Margin="0,16,0,0" RowDefinitions="32,Auto" ColumnDefinitions="120,*">
HorizontalAlignment="Center" <TextBlock Grid.Row="0" Grid.Column="0"
TextWrapping="Wrap"/> HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
Text="{DynamicResource Text.GitLFS.Remote}"/>
<ComboBox Grid.Row="0" Grid.Column="1"
Height="28" Padding="8,0"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
ItemsSource="{Binding Remotes}"
SelectedItem="{Binding SelectedRemote, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="{x:Type m:Remote}">
<StackPanel Orientation="Horizontal" Height="20" VerticalAlignment="Center">
<Path Margin="0,6,8,0" Width="14" Height="14" Fill="{DynamicResource Brush.FG1}" Data="{StaticResource Icons.Remote}"/>
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Grid.Row="1" Grid.Column="1"
Text="{DynamicResource Text.GitLFS.Pull.Tips}"
Margin="0,8,0,0"
TextWrapping="Wrap"/>
</Grid>
</StackPanel> </StackPanel>
</UserControl> </UserControl>

41
src/Views/LFSPush.axaml Normal file
View file

@ -0,0 +1,41 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.LFSPush"
x:DataType="vm:LFSPush">
<StackPanel Orientation="Vertical" Margin="8,0">
<TextBlock FontSize="18"
Classes="bold"
Text="{DynamicResource Text.GitLFS.Push.Title}"/>
<Grid Margin="0,16,0,0" RowDefinitions="32,Auto" ColumnDefinitions="120,*">
<TextBlock Grid.Row="0" Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
Text="{DynamicResource Text.GitLFS.Remote}"/>
<ComboBox Grid.Row="0" Grid.Column="1"
Height="28" Padding="8,0"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
ItemsSource="{Binding Remotes}"
SelectedItem="{Binding SelectedRemote, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="{x:Type m:Remote}">
<StackPanel Orientation="Horizontal" Height="20" VerticalAlignment="Center">
<Path Margin="0,6,8,0" Width="14" Height="14" Fill="{DynamicResource Brush.FG1}" Data="{StaticResource Icons.Remote}"/>
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Grid.Row="1" Grid.Column="1"
Text="{DynamicResource Text.GitLFS.Push.Tips}"
Margin="0,8,0,0"
TextWrapping="Wrap"/>
</Grid>
</StackPanel>
</UserControl>

View file

@ -0,0 +1,12 @@
using Avalonia.Controls;
namespace SourceGit.Views
{
public partial class LFSPush : UserControl
{
public LFSPush()
{
InitializeComponent();
}
}
}