mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
Merge branch 'develop' into feature/treedatagrid
This commit is contained in:
commit
f8b327746c
13 changed files with 253 additions and 212 deletions
9
src/Models/DealWithLocalChanges.cs
Normal file
9
src/Models/DealWithLocalChanges.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace SourceGit.Models
|
||||||
|
{
|
||||||
|
public enum DealWithLocalChanges
|
||||||
|
{
|
||||||
|
StashAndReaply,
|
||||||
|
Discard,
|
||||||
|
DoNothing,
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,8 +61,9 @@
|
||||||
<x:String x:Key="Text.Checkout.Commit.Target" xml:space="preserve">Commit :</x:String>
|
<x:String x:Key="Text.Checkout.Commit.Target" xml:space="preserve">Commit :</x:String>
|
||||||
<x:String x:Key="Text.Checkout.Target" xml:space="preserve">Branch :</x:String>
|
<x:String x:Key="Text.Checkout.Target" xml:space="preserve">Branch :</x:String>
|
||||||
<x:String x:Key="Text.Checkout.LocalChanges" xml:space="preserve">Local Changes :</x:String>
|
<x:String x:Key="Text.Checkout.LocalChanges" xml:space="preserve">Local Changes :</x:String>
|
||||||
<x:String x:Key="Text.Checkout.LocalChanges.StashAndReply" xml:space="preserve">Stash & Reapply</x:String>
|
|
||||||
<x:String x:Key="Text.Checkout.LocalChanges.Discard" xml:space="preserve">Discard</x:String>
|
<x:String x:Key="Text.Checkout.LocalChanges.Discard" xml:space="preserve">Discard</x:String>
|
||||||
|
<x:String x:Key="Text.Checkout.LocalChanges.DoNothing" xml:space="preserve">Do Nothing</x:String>
|
||||||
|
<x:String x:Key="Text.Checkout.LocalChanges.StashAndReply" xml:space="preserve">Stash & Reapply</x:String>
|
||||||
<x:String x:Key="Text.CherryPick" xml:space="preserve">Cherry-Pick This Commit</x:String>
|
<x:String x:Key="Text.CherryPick" xml:space="preserve">Cherry-Pick This Commit</x:String>
|
||||||
<x:String x:Key="Text.CherryPick.Commit" xml:space="preserve">Commit :</x:String>
|
<x:String x:Key="Text.CherryPick.Commit" xml:space="preserve">Commit :</x:String>
|
||||||
<x:String x:Key="Text.CherryPick.CommitChanges" xml:space="preserve">Commit all changes</x:String>
|
<x:String x:Key="Text.CherryPick.CommitChanges" xml:space="preserve">Commit all changes</x:String>
|
||||||
|
@ -118,8 +119,8 @@
|
||||||
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">Check out after created</x:String>
|
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">Check out after created</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.LocalChanges" xml:space="preserve">Local Changes :</x:String>
|
<x:String x:Key="Text.CreateBranch.LocalChanges" xml:space="preserve">Local Changes :</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.LocalChanges.Discard" xml:space="preserve">Discard</x:String>
|
<x:String x:Key="Text.CreateBranch.LocalChanges.Discard" xml:space="preserve">Discard</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.LocalChanges.StashAndReply" xml:space="preserve">Stash & Reapply</x:String>
|
|
||||||
<x:String x:Key="Text.CreateBranch.LocalChanges.DoNothing" xml:space="preserve">Do Nothing</x:String>
|
<x:String x:Key="Text.CreateBranch.LocalChanges.DoNothing" xml:space="preserve">Do Nothing</x:String>
|
||||||
|
<x:String x:Key="Text.CreateBranch.LocalChanges.StashAndReply" xml:space="preserve">Stash & Reapply</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.Name" xml:space="preserve">New Branch Name :</x:String>
|
<x:String x:Key="Text.CreateBranch.Name" xml:space="preserve">New Branch Name :</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.Name.Placeholder" xml:space="preserve">Enter branch name.</x:String>
|
<x:String x:Key="Text.CreateBranch.Name.Placeholder" xml:space="preserve">Enter branch name.</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.Title" xml:space="preserve">Create Local Branch</x:String>
|
<x:String x:Key="Text.CreateBranch.Title" xml:space="preserve">Create Local Branch</x:String>
|
||||||
|
@ -320,9 +321,12 @@
|
||||||
<x:String x:Key="Text.Preference.Merger.Path.Placeholder" xml:space="preserve">Input path for merge tool</x:String>
|
<x:String x:Key="Text.Preference.Merger.Path.Placeholder" xml:space="preserve">Input path for merge tool</x:String>
|
||||||
<x:String x:Key="Text.Preference.Merger.Type" xml:space="preserve">Merger</x:String>
|
<x:String x:Key="Text.Preference.Merger.Type" xml:space="preserve">Merger</x:String>
|
||||||
<x:String x:Key="Text.Pull" xml:space="preserve">Pull</x:String>
|
<x:String x:Key="Text.Pull" xml:space="preserve">Pull</x:String>
|
||||||
<x:String x:Key="Text.Pull.AutoStash" xml:space="preserve">Stash & reapply local changes</x:String>
|
|
||||||
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">Branch :</x:String>
|
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">Branch :</x:String>
|
||||||
<x:String x:Key="Text.Pull.Into" xml:space="preserve">Into :</x:String>
|
<x:String x:Key="Text.Pull.Into" xml:space="preserve">Into :</x:String>
|
||||||
|
<x:String x:Key="Text.Pull.LocalChanges" xml:space="preserve">Local Changes :</x:String>
|
||||||
|
<x:String x:Key="Text.Pull.LocalChanges.Discard" xml:space="preserve">Discard</x:String>
|
||||||
|
<x:String x:Key="Text.Pull.LocalChanges.DoNothing" xml:space="preserve">Do Nothing</x:String>
|
||||||
|
<x:String x:Key="Text.Pull.LocalChanges.StashAndReply" xml:space="preserve">Stash & Reapply</x:String>
|
||||||
<x:String x:Key="Text.Pull.Remote" xml:space="preserve">Remote :</x:String>
|
<x:String x:Key="Text.Pull.Remote" xml:space="preserve">Remote :</x:String>
|
||||||
<x:String x:Key="Text.Pull.Title" xml:space="preserve">Pull (Fetch & Merge)</x:String>
|
<x:String x:Key="Text.Pull.Title" xml:space="preserve">Pull (Fetch & Merge)</x:String>
|
||||||
<x:String x:Key="Text.Pull.UseRebase" xml:space="preserve">Use rebase instead of merge</x:String>
|
<x:String x:Key="Text.Pull.UseRebase" xml:space="preserve">Use rebase instead of merge</x:String>
|
||||||
|
|
|
@ -61,8 +61,9 @@
|
||||||
<x:String x:Key="Text.Checkout.Commit.Target" xml:space="preserve">提交 :</x:String>
|
<x:String x:Key="Text.Checkout.Commit.Target" xml:space="preserve">提交 :</x:String>
|
||||||
<x:String x:Key="Text.Checkout.Target" xml:space="preserve">目标分支 :</x:String>
|
<x:String x:Key="Text.Checkout.Target" xml:space="preserve">目标分支 :</x:String>
|
||||||
<x:String x:Key="Text.Checkout.LocalChanges" xml:space="preserve">未提交更改 :</x:String>
|
<x:String x:Key="Text.Checkout.LocalChanges" xml:space="preserve">未提交更改 :</x:String>
|
||||||
<x:String x:Key="Text.Checkout.LocalChanges.StashAndReply" xml:space="preserve">贮藏(stash)并自动恢复</x:String>
|
<x:String x:Key="Text.Checkout.LocalChanges.Discard" xml:space="preserve">丢弃更改</x:String>
|
||||||
<x:String x:Key="Text.Checkout.LocalChanges.Discard" xml:space="preserve">忽略</x:String>
|
<x:String x:Key="Text.Checkout.LocalChanges.DoNothing" xml:space="preserve">不做处理</x:String>
|
||||||
|
<x:String x:Key="Text.Checkout.LocalChanges.StashAndReply" xml:space="preserve">贮藏并自动恢复</x:String>
|
||||||
<x:String x:Key="Text.CherryPick" xml:space="preserve">挑选(cherry-pick)此提交</x:String>
|
<x:String x:Key="Text.CherryPick" xml:space="preserve">挑选(cherry-pick)此提交</x:String>
|
||||||
<x:String x:Key="Text.CherryPick.Commit" xml:space="preserve">提交ID :</x:String>
|
<x:String x:Key="Text.CherryPick.Commit" xml:space="preserve">提交ID :</x:String>
|
||||||
<x:String x:Key="Text.CherryPick.CommitChanges" xml:space="preserve">提交变化</x:String>
|
<x:String x:Key="Text.CherryPick.CommitChanges" xml:space="preserve">提交变化</x:String>
|
||||||
|
@ -117,9 +118,9 @@
|
||||||
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">新分支基于 :</x:String>
|
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">新分支基于 :</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">完成后切换到新分支</x:String>
|
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">完成后切换到新分支</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.LocalChanges" xml:space="preserve">未提交更改 :</x:String>
|
<x:String x:Key="Text.CreateBranch.LocalChanges" xml:space="preserve">未提交更改 :</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.LocalChanges.Discard" xml:space="preserve">放弃所有</x:String>
|
<x:String x:Key="Text.CreateBranch.LocalChanges.Discard" xml:space="preserve">丢弃更改</x:String>
|
||||||
|
<x:String x:Key="Text.CreateBranch.LocalChanges.DoNothing" xml:space="preserve">不做处理</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.LocalChanges.StashAndReply" xml:space="preserve">贮藏并自动恢复</x:String>
|
<x:String x:Key="Text.CreateBranch.LocalChanges.StashAndReply" xml:space="preserve">贮藏并自动恢复</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.LocalChanges.DoNothing" xml:space="preserve">GIT默认</x:String>
|
|
||||||
<x:String x:Key="Text.CreateBranch.Name" xml:space="preserve">新分支名 :</x:String>
|
<x:String x:Key="Text.CreateBranch.Name" xml:space="preserve">新分支名 :</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.Name.Placeholder" xml:space="preserve">填写分支名称。</x:String>
|
<x:String x:Key="Text.CreateBranch.Name.Placeholder" xml:space="preserve">填写分支名称。</x:String>
|
||||||
<x:String x:Key="Text.CreateBranch.Title" xml:space="preserve">创建本地分支</x:String>
|
<x:String x:Key="Text.CreateBranch.Title" xml:space="preserve">创建本地分支</x:String>
|
||||||
|
@ -320,9 +321,12 @@
|
||||||
<x:String x:Key="Text.Preference.Merger.Path.Placeholder" xml:space="preserve">填写工具可执行文件所在位置</x:String>
|
<x:String x:Key="Text.Preference.Merger.Path.Placeholder" xml:space="preserve">填写工具可执行文件所在位置</x:String>
|
||||||
<x:String x:Key="Text.Preference.Merger.Type" xml:space="preserve">工具</x:String>
|
<x:String x:Key="Text.Preference.Merger.Type" xml:space="preserve">工具</x:String>
|
||||||
<x:String x:Key="Text.Pull" xml:space="preserve">拉回(pull)</x:String>
|
<x:String x:Key="Text.Pull" xml:space="preserve">拉回(pull)</x:String>
|
||||||
<x:String x:Key="Text.Pull.AutoStash" xml:space="preserve">自动贮藏并恢复本地变更</x:String>
|
|
||||||
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">拉取分支 :</x:String>
|
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">拉取分支 :</x:String>
|
||||||
<x:String x:Key="Text.Pull.Into" xml:space="preserve">本地分支 :</x:String>
|
<x:String x:Key="Text.Pull.Into" xml:space="preserve">本地分支 :</x:String>
|
||||||
|
<x:String x:Key="Text.Pull.LocalChanges" xml:space="preserve">未提交更改 :</x:String>
|
||||||
|
<x:String x:Key="Text.Pull.LocalChanges.Discard" xml:space="preserve">丢弃更改</x:String>
|
||||||
|
<x:String x:Key="Text.Pull.LocalChanges.DoNothing" xml:space="preserve">不做处理</x:String>
|
||||||
|
<x:String x:Key="Text.Pull.LocalChanges.StashAndReply" xml:space="preserve">贮藏并自动恢复</x:String>
|
||||||
<x:String x:Key="Text.Pull.Remote" xml:space="preserve">远程 :</x:String>
|
<x:String x:Key="Text.Pull.Remote" xml:space="preserve">远程 :</x:String>
|
||||||
<x:String x:Key="Text.Pull.Title" xml:space="preserve">拉回(拉取并合并)</x:String>
|
<x:String x:Key="Text.Pull.Title" xml:space="preserve">拉回(拉取并合并)</x:String>
|
||||||
<x:String x:Key="Text.Pull.UseRebase" xml:space="preserve">使用变基方式合并分支</x:String>
|
<x:String x:Key="Text.Pull.UseRebase" xml:space="preserve">使用变基方式合并分支</x:String>
|
||||||
|
|
|
@ -10,10 +10,10 @@ namespace SourceGit.ViewModels
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AutoStash
|
public Models.DealWithLocalChanges PreAction
|
||||||
{
|
{
|
||||||
get => _autoStash;
|
get => _preAction;
|
||||||
set => SetProperty(ref _autoStash, value);
|
set => SetProperty(ref _preAction, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Checkout(Repository repo, string branch)
|
public Checkout(Repository repo, string branch)
|
||||||
|
@ -34,7 +34,7 @@ namespace SourceGit.ViewModels
|
||||||
var needPopStash = false;
|
var needPopStash = false;
|
||||||
if (hasLocalChanges)
|
if (hasLocalChanges)
|
||||||
{
|
{
|
||||||
if (AutoStash)
|
if (_preAction == Models.DealWithLocalChanges.StashAndReaply)
|
||||||
{
|
{
|
||||||
SetProgressDescription("Adding untracked changes ...");
|
SetProgressDescription("Adding untracked changes ...");
|
||||||
var succ = new Commands.Add(_repo.FullPath).Exec();
|
var succ = new Commands.Add(_repo.FullPath).Exec();
|
||||||
|
@ -52,7 +52,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
needPopStash = true;
|
needPopStash = true;
|
||||||
}
|
}
|
||||||
else
|
else if (_preAction == Models.DealWithLocalChanges.Discard)
|
||||||
{
|
{
|
||||||
SetProgressDescription("Discard local changes ...");
|
SetProgressDescription("Discard local changes ...");
|
||||||
Commands.Discard.All(_repo.FullPath);
|
Commands.Discard.All(_repo.FullPath);
|
||||||
|
@ -78,6 +78,6 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Repository _repo = null;
|
private readonly Repository _repo = null;
|
||||||
private bool _autoStash = true;
|
private Models.DealWithLocalChanges _preAction = Models.DealWithLocalChanges.StashAndReaply;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,7 @@
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SourceGit.ViewModels
|
namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
public enum BeforeCreateBranchAction
|
|
||||||
{
|
|
||||||
StashAndReaply,
|
|
||||||
Discard,
|
|
||||||
DoNothing,
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CreateBranch : Popup
|
public class CreateBranch : Popup
|
||||||
{
|
{
|
||||||
[Required(ErrorMessage = "Branch name is required!")]
|
[Required(ErrorMessage = "Branch name is required!")]
|
||||||
|
@ -27,7 +20,7 @@ namespace SourceGit.ViewModels
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeforeCreateBranchAction PreAction
|
public Models.DealWithLocalChanges PreAction
|
||||||
{
|
{
|
||||||
get => _preAction;
|
get => _preAction;
|
||||||
set => SetProperty(ref _preAction, value);
|
set => SetProperty(ref _preAction, value);
|
||||||
|
@ -97,7 +90,7 @@ namespace SourceGit.ViewModels
|
||||||
bool needPopStash = false;
|
bool needPopStash = false;
|
||||||
if (_repo.WorkingCopyChangesCount > 0)
|
if (_repo.WorkingCopyChangesCount > 0)
|
||||||
{
|
{
|
||||||
if (_preAction == BeforeCreateBranchAction.StashAndReaply)
|
if (_preAction == Models.DealWithLocalChanges.StashAndReaply)
|
||||||
{
|
{
|
||||||
SetProgressDescription("Adding untracked changes...");
|
SetProgressDescription("Adding untracked changes...");
|
||||||
var succ = new Commands.Add(_repo.FullPath).Exec();
|
var succ = new Commands.Add(_repo.FullPath).Exec();
|
||||||
|
@ -115,7 +108,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
needPopStash = true;
|
needPopStash = true;
|
||||||
}
|
}
|
||||||
else if (_preAction == BeforeCreateBranchAction.Discard)
|
else if (_preAction == Models.DealWithLocalChanges.Discard)
|
||||||
{
|
{
|
||||||
SetProgressDescription("Discard local changes...");
|
SetProgressDescription("Discard local changes...");
|
||||||
Commands.Discard.All(_repo.FullPath);
|
Commands.Discard.All(_repo.FullPath);
|
||||||
|
@ -144,6 +137,6 @@ namespace SourceGit.ViewModels
|
||||||
private readonly Repository _repo = null;
|
private readonly Repository _repo = null;
|
||||||
private string _name = null;
|
private string _name = null;
|
||||||
private readonly string _baseOnRevision = null;
|
private readonly string _baseOnRevision = null;
|
||||||
private BeforeCreateBranchAction _preAction = BeforeCreateBranchAction.StashAndReaply;
|
private Models.DealWithLocalChanges _preAction = Models.DealWithLocalChanges.StashAndReaply;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -513,7 +513,7 @@ namespace SourceGit.ViewModels
|
||||||
checkout.Icon = App.CreateMenuIcon("Icons.Check");
|
checkout.Icon = App.CreateMenuIcon("Icons.Check");
|
||||||
checkout.Click += (o, e) =>
|
checkout.Click += (o, e) =>
|
||||||
{
|
{
|
||||||
_repo.CheckoutLocalBranch(branch.Name);
|
_repo.CheckoutBranch(branch);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
submenu.Items.Add(checkout);
|
submenu.Items.Add(checkout);
|
||||||
|
@ -585,20 +585,7 @@ namespace SourceGit.ViewModels
|
||||||
checkout.Icon = App.CreateMenuIcon("Icons.Check");
|
checkout.Icon = App.CreateMenuIcon("Icons.Check");
|
||||||
checkout.Click += (o, e) =>
|
checkout.Click += (o, e) =>
|
||||||
{
|
{
|
||||||
foreach (var b in _repo.Branches)
|
_repo.CheckoutBranch(branch);
|
||||||
{
|
|
||||||
if (b.IsLocal && b.Upstream == branch.FullName)
|
|
||||||
{
|
|
||||||
if (!b.IsCurrent)
|
|
||||||
_repo.CheckoutLocalBranch(b.Name);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PopupHost.CanCreatePopup())
|
|
||||||
PopupHost.ShowPopup(new CreateBranch(_repo, branch));
|
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
submenu.Items.Add(checkout);
|
submenu.Items.Add(checkout);
|
||||||
|
|
|
@ -47,13 +47,13 @@ namespace SourceGit.ViewModels
|
||||||
set => SetProperty(ref _selectedBranch, value);
|
set => SetProperty(ref _selectedBranch, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UseRebase
|
public Models.DealWithLocalChanges PreAction
|
||||||
{
|
{
|
||||||
get;
|
get => _preAction;
|
||||||
set;
|
set => SetProperty(ref _preAction, value);
|
||||||
} = true;
|
}
|
||||||
|
|
||||||
public bool AutoStash
|
public bool UseRebase
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
|
@ -117,23 +117,31 @@ namespace SourceGit.ViewModels
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
var needPopStash = false;
|
var needPopStash = false;
|
||||||
if (AutoStash && _repo.WorkingCopyChangesCount > 0)
|
if (_repo.WorkingCopyChangesCount > 0)
|
||||||
{
|
{
|
||||||
SetProgressDescription("Adding untracked changes...");
|
if (_preAction == Models.DealWithLocalChanges.StashAndReaply)
|
||||||
var succ = new Commands.Add(_repo.FullPath).Exec();
|
|
||||||
if (succ)
|
|
||||||
{
|
{
|
||||||
SetProgressDescription("Stash local changes...");
|
SetProgressDescription("Adding untracked changes...");
|
||||||
succ = new Commands.Stash(_repo.FullPath).Push("PULL_AUTO_STASH");
|
var succ = new Commands.Add(_repo.FullPath).Exec();
|
||||||
}
|
if (succ)
|
||||||
|
{
|
||||||
|
SetProgressDescription("Stash local changes...");
|
||||||
|
succ = new Commands.Stash(_repo.FullPath).Push("PULL_AUTO_STASH");
|
||||||
|
}
|
||||||
|
|
||||||
if (!succ)
|
if (!succ)
|
||||||
|
{
|
||||||
|
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
needPopStash = true;
|
||||||
|
}
|
||||||
|
else if (_preAction == Models.DealWithLocalChanges.Discard)
|
||||||
{
|
{
|
||||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
SetProgressDescription("Discard local changes ...");
|
||||||
return false;
|
Commands.Discard.All(_repo.FullPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
needPopStash = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetProgressDescription($"Pull {_selectedRemote.Name}/{_selectedBranch.Name}...");
|
SetProgressDescription($"Pull {_selectedRemote.Name}/{_selectedBranch.Name}...");
|
||||||
|
@ -154,5 +162,6 @@ namespace SourceGit.ViewModels
|
||||||
private Models.Remote _selectedRemote = null;
|
private Models.Remote _selectedRemote = null;
|
||||||
private List<Models.Branch> _remoteBranches = null;
|
private List<Models.Branch> _remoteBranches = null;
|
||||||
private Models.Branch _selectedBranch = null;
|
private Models.Branch _selectedBranch = null;
|
||||||
|
private Models.DealWithLocalChanges _preAction = Models.DealWithLocalChanges.StashAndReaply;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -711,17 +711,35 @@ namespace SourceGit.ViewModels
|
||||||
PopupHost.ShowPopup(new CreateBranch(this, current));
|
PopupHost.ShowPopup(new CreateBranch(this, current));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckoutLocalBranch(string branch)
|
public void CheckoutBranch(Models.Branch branch)
|
||||||
{
|
{
|
||||||
if (!PopupHost.CanCreatePopup())
|
if (!PopupHost.CanCreatePopup())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (WorkingCopyChangesCount > 0)
|
if (branch.IsLocal)
|
||||||
PopupHost.ShowPopup(new Checkout(this, branch));
|
{
|
||||||
|
if (WorkingCopyChangesCount > 0)
|
||||||
|
PopupHost.ShowPopup(new Checkout(this, branch.Name));
|
||||||
|
else
|
||||||
|
PopupHost.ShowAndStartPopup(new Checkout(this, branch.Name));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
PopupHost.ShowAndStartPopup(new Checkout(this, branch));
|
{
|
||||||
|
foreach (var b in Branches)
|
||||||
|
{
|
||||||
|
if (b.IsLocal && b.Upstream == branch.FullName)
|
||||||
|
{
|
||||||
|
if (!b.IsCurrent)
|
||||||
|
CheckoutBranch(b);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PopupHost.ShowPopup(new CreateBranch(this, branch));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteMultipleBranches(List<Models.Branch> branches, bool isLocal)
|
public void DeleteMultipleBranches(List<Models.Branch> branches, bool isLocal)
|
||||||
{
|
{
|
||||||
if (PopupHost.CanCreatePopup())
|
if (PopupHost.CanCreatePopup())
|
||||||
|
@ -880,7 +898,7 @@ namespace SourceGit.ViewModels
|
||||||
checkout.Icon = App.CreateMenuIcon("Icons.Check");
|
checkout.Icon = App.CreateMenuIcon("Icons.Check");
|
||||||
checkout.Click += (o, e) =>
|
checkout.Click += (o, e) =>
|
||||||
{
|
{
|
||||||
CheckoutLocalBranch(branch.Name);
|
CheckoutBranch(branch);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
menu.Items.Add(checkout);
|
menu.Items.Add(checkout);
|
||||||
|
@ -1182,20 +1200,7 @@ namespace SourceGit.ViewModels
|
||||||
checkout.Icon = App.CreateMenuIcon("Icons.Check");
|
checkout.Icon = App.CreateMenuIcon("Icons.Check");
|
||||||
checkout.Click += (o, e) =>
|
checkout.Click += (o, e) =>
|
||||||
{
|
{
|
||||||
foreach (var b in Branches)
|
CheckoutBranch(branch);
|
||||||
{
|
|
||||||
if (b.IsLocal && b.Upstream == branch.FullName)
|
|
||||||
{
|
|
||||||
if (b.IsCurrent)
|
|
||||||
return;
|
|
||||||
if (PopupHost.CanCreatePopup())
|
|
||||||
PopupHost.ShowAndStartPopup(new Checkout(this, b.Name));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PopupHost.CanCreatePopup())
|
|
||||||
PopupHost.ShowPopup(new CreateBranch(this, branch));
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
menu.Items.Add(checkout);
|
menu.Items.Add(checkout);
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:m="using:SourceGit.Models"
|
||||||
xmlns:vm="using:SourceGit.ViewModels"
|
xmlns:vm="using:SourceGit.ViewModels"
|
||||||
|
xmlns:ac="using:Avalonia.Controls.Converters"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="SourceGit.Views.Checkout"
|
x:Class="SourceGit.Views.Checkout"
|
||||||
x:DataType="vm:Checkout">
|
x:DataType="vm:Checkout">
|
||||||
|
@ -11,7 +13,7 @@
|
||||||
Classes="bold"
|
Classes="bold"
|
||||||
Text="{DynamicResource Text.Checkout}"/>
|
Text="{DynamicResource Text.Checkout}"/>
|
||||||
|
|
||||||
<Grid Margin="0,16,0,0" RowDefinitions="32,32" ColumnDefinitions="150,*">
|
<Grid Margin="0,16,0,0" RowDefinitions="32,32" ColumnDefinitions="140,*">
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
|
@ -26,12 +28,21 @@
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
Text="{DynamicResource Text.Checkout.LocalChanges}"/>
|
Text="{DynamicResource Text.Checkout.LocalChanges}"/>
|
||||||
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
|
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
|
||||||
<RadioButton Content="{DynamicResource Text.Checkout.LocalChanges.StashAndReply}"
|
<StackPanel.Resources>
|
||||||
|
<ac:EnumToBoolConverter x:Key="EnumToBoolConverter"/>
|
||||||
|
</StackPanel.Resources>
|
||||||
|
|
||||||
|
<RadioButton Content="{DynamicResource Text.CreateBranch.LocalChanges.StashAndReply}"
|
||||||
GroupName="LocalChanges"
|
GroupName="LocalChanges"
|
||||||
IsChecked="{Binding AutoStash, Mode=TwoWay}"/>
|
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static m:DealWithLocalChanges.StashAndReaply}}"/>
|
||||||
<RadioButton Content="{DynamicResource Text.Checkout.LocalChanges.Discard}"
|
<RadioButton Content="{DynamicResource Text.CreateBranch.LocalChanges.Discard}"
|
||||||
GroupName="LocalChanges"
|
GroupName="LocalChanges"
|
||||||
Margin="8,0,0,0"/>
|
Margin="8,0,0,0"
|
||||||
|
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static m:DealWithLocalChanges.Discard}}"/>
|
||||||
|
<RadioButton Content="{DynamicResource Text.CreateBranch.LocalChanges.DoNothing}"
|
||||||
|
GroupName="LocalChanges"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static m:DealWithLocalChanges.DoNothing}}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<TextBlock FontSize="18"
|
<TextBlock FontSize="18"
|
||||||
Classes="bold"
|
Classes="bold"
|
||||||
Text="{DynamicResource Text.CreateBranch}"/>
|
Text="{DynamicResource Text.CreateBranch}"/>
|
||||||
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32,32" ColumnDefinitions="150,*">
|
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32,32" ColumnDefinitions="140,*">
|
||||||
<TextBlock Grid.Column="0"
|
<TextBlock Grid.Column="0"
|
||||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
|
@ -67,15 +67,15 @@
|
||||||
|
|
||||||
<RadioButton Content="{DynamicResource Text.CreateBranch.LocalChanges.StashAndReply}"
|
<RadioButton Content="{DynamicResource Text.CreateBranch.LocalChanges.StashAndReply}"
|
||||||
GroupName="LocalChanges"
|
GroupName="LocalChanges"
|
||||||
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static vm:BeforeCreateBranchAction.StashAndReaply}}"/>
|
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static m:DealWithLocalChanges.StashAndReaply}}"/>
|
||||||
<RadioButton Content="{DynamicResource Text.CreateBranch.LocalChanges.Discard}"
|
<RadioButton Content="{DynamicResource Text.CreateBranch.LocalChanges.Discard}"
|
||||||
GroupName="LocalChanges"
|
GroupName="LocalChanges"
|
||||||
Margin="8,0,0,0"
|
Margin="8,0,0,0"
|
||||||
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static vm:BeforeCreateBranchAction.Discard}}"/>
|
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static m:DealWithLocalChanges.Discard}}"/>
|
||||||
<RadioButton Content="{DynamicResource Text.CreateBranch.LocalChanges.DoNothing}"
|
<RadioButton Content="{DynamicResource Text.CreateBranch.LocalChanges.DoNothing}"
|
||||||
GroupName="LocalChanges"
|
GroupName="LocalChanges"
|
||||||
Margin="8,0,0,0"
|
Margin="8,0,0,0"
|
||||||
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static vm:BeforeCreateBranchAction.DoNothing}}"/>
|
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static m:DealWithLocalChanges.DoNothing}}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<CheckBox Grid.Row="3" Grid.Column="1"
|
<CheckBox Grid.Row="3" Grid.Column="1"
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
xmlns:m="using:SourceGit.Models"
|
xmlns:m="using:SourceGit.Models"
|
||||||
xmlns:vm="using:SourceGit.ViewModels"
|
xmlns:vm="using:SourceGit.ViewModels"
|
||||||
xmlns:c="using:SourceGit.Converters"
|
xmlns:c="using:SourceGit.Converters"
|
||||||
|
xmlns:ac="using:Avalonia.Controls.Converters"
|
||||||
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="450"
|
||||||
x:Class="SourceGit.Views.Pull"
|
x:Class="SourceGit.Views.Pull"
|
||||||
x:DataType="vm:Pull">
|
x:DataType="vm:Pull">
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
<TextBlock FontSize="18"
|
<TextBlock FontSize="18"
|
||||||
Classes="bold"
|
Classes="bold"
|
||||||
Text="{DynamicResource Text.Pull.Title}"/>
|
Text="{DynamicResource Text.Pull.Title}"/>
|
||||||
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32,32,32" ColumnDefinitions="150,*">
|
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32,32,32" ColumnDefinitions="140,*">
|
||||||
<TextBlock Grid.Column="0"
|
<TextBlock Grid.Column="0"
|
||||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
|
@ -58,17 +59,35 @@
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
Text="{DynamicResource Text.Pull.Into}"/>
|
Text="{DynamicResource Text.Pull.Into}"/>
|
||||||
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal" Height="20" VerticalAlignment="Center">
|
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal" Height="20" VerticalAlignment="Center">
|
||||||
<Path Margin="0,0,8,0" Width="14" Height="14" Fill="{DynamicResource Brush.FG1}" Data="{StaticResource Icons.Branch}"/>
|
<Path Margin="2,0,8,0" Width="14" Height="14" Fill="{DynamicResource Brush.FG1}" Data="{StaticResource Icons.Branch}"/>
|
||||||
<TextBlock Text="{Binding Current.Name}"/>
|
<TextBlock Text="{Binding Current.Name}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<CheckBox Grid.Row="3" Grid.Column="1"
|
<TextBlock Grid.Row="3" Grid.Column="0"
|
||||||
Content="{DynamicResource Text.Pull.UseRebase}"
|
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||||
IsChecked="{Binding UseRebase, Mode=TwoWay}"/>
|
Margin="0,0,8,0"
|
||||||
|
Text="{DynamicResource Text.Pull.LocalChanges}"/>
|
||||||
|
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal">
|
||||||
|
<StackPanel.Resources>
|
||||||
|
<ac:EnumToBoolConverter x:Key="EnumToBoolConverter"/>
|
||||||
|
</StackPanel.Resources>
|
||||||
|
|
||||||
|
<RadioButton Content="{DynamicResource Text.Pull.LocalChanges.StashAndReply}"
|
||||||
|
GroupName="LocalChanges"
|
||||||
|
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static m:DealWithLocalChanges.StashAndReaply}}"/>
|
||||||
|
<RadioButton Content="{DynamicResource Text.Pull.LocalChanges.Discard}"
|
||||||
|
GroupName="LocalChanges"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static m:DealWithLocalChanges.Discard}}"/>
|
||||||
|
<RadioButton Content="{DynamicResource Text.Pull.LocalChanges.DoNothing}"
|
||||||
|
GroupName="LocalChanges"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static m:DealWithLocalChanges.DoNothing}}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
<CheckBox Grid.Row="4" Grid.Column="1"
|
<CheckBox Grid.Row="4" Grid.Column="1"
|
||||||
Content="{DynamicResource Text.Pull.AutoStash}"
|
Content="{DynamicResource Text.Pull.UseRebase}"
|
||||||
IsChecked="{Binding AutoStash, Mode=TwoWay}"/>
|
IsChecked="{Binding UseRebase, Mode=TwoWay}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<Path Width="13" Height="13" Data="{StaticResource Icons.Terminal}"/>
|
<Path Width="13" Height="13" Data="{StaticResource Icons.Terminal}"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button Classes="icon_button" Width="32" Click="OnOpenWithExternalTools" ToolTip.Tip="{DynamicResource Text.Repository.OpenWithExternalTools}">
|
<Button Classes="icon_button" Width="32" Click="OpenWithExternalTools" ToolTip.Tip="{DynamicResource Text.Repository.OpenWithExternalTools}">
|
||||||
<Path Width="13" Height="13" Data="{StaticResource Icons.OpenWith}"/>
|
<Path Width="13" Height="13" Data="{StaticResource Icons.OpenWith}"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@
|
||||||
</TreeView.Styles>
|
</TreeView.Styles>
|
||||||
<TreeView.ItemTemplate>
|
<TreeView.ItemTemplate>
|
||||||
<TreeDataTemplate ItemsSource="{Binding Children}" x:DataType="{x:Type vm:BranchTreeNode}">
|
<TreeDataTemplate ItemsSource="{Binding Children}" x:DataType="{x:Type vm:BranchTreeNode}">
|
||||||
<Grid Height="24" ColumnDefinitions="20,*,Auto,Auto" Background="Transparent" DoubleTapped="OnDoubleTappedLocalBranchNode">
|
<Grid Height="24" ColumnDefinitions="20,*,Auto,Auto" Background="Transparent" DoubleTapped="OnDoubleTappedBranchNode">
|
||||||
<Path Grid.Column="0" Classes="folder_icon" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,1,0,0" IsVisible="{Binding IsFolder}"/>
|
<Path Grid.Column="0" Classes="folder_icon" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,1,0,0" IsVisible="{Binding IsFolder}"/>
|
||||||
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,2,0,0" Data="{StaticResource Icons.Check}" IsVisible="{Binding IsCurrent}" VerticalAlignment="Center"/>
|
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,2,0,0" Data="{StaticResource Icons.Check}" IsVisible="{Binding IsCurrent}" VerticalAlignment="Center"/>
|
||||||
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="2,0,0,0" Data="{StaticResource Icons.Branch}" VerticalAlignment="Center">
|
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="2,0,0,0" Data="{StaticResource Icons.Branch}" VerticalAlignment="Center">
|
||||||
|
@ -287,7 +287,7 @@
|
||||||
|
|
||||||
<TreeView.ItemTemplate>
|
<TreeView.ItemTemplate>
|
||||||
<TreeDataTemplate ItemsSource="{Binding Children}" x:DataType="{x:Type vm:BranchTreeNode}">
|
<TreeDataTemplate ItemsSource="{Binding Children}" x:DataType="{x:Type vm:BranchTreeNode}">
|
||||||
<Grid Height="24" ColumnDefinitions="20,*,Auto" Background="Transparent">
|
<Grid Height="24" ColumnDefinitions="20,*,Auto" Background="Transparent" DoubleTapped="OnDoubleTappedBranchNode">
|
||||||
<Path Grid.Column="0" Classes="folder_icon" Width="10" Height="10" HorizontalAlignment="Left" Margin="0,2,0,0" IsVisible="{Binding IsFolder}" VerticalAlignment="Center"/>
|
<Path Grid.Column="0" Classes="folder_icon" Width="10" Height="10" HorizontalAlignment="Left" Margin="0,2,0,0" IsVisible="{Binding IsFolder}" VerticalAlignment="Center"/>
|
||||||
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,2,0,0" Data="{StaticResource Icons.Remote}" IsVisible="{Binding IsRemote}" VerticalAlignment="Center"/>
|
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,2,0,0" Data="{StaticResource Icons.Remote}" IsVisible="{Binding IsRemote}" VerticalAlignment="Center"/>
|
||||||
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="2,0,0,0" Data="{StaticResource Icons.Branch}" IsVisible="{Binding IsBranch}" VerticalAlignment="Center"/>
|
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="2,0,0,0" Data="{StaticResource Icons.Branch}" IsVisible="{Binding IsBranch}" VerticalAlignment="Center"/>
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace SourceGit.Views
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnOpenWithExternalTools(object sender, RoutedEventArgs e)
|
private void OpenWithExternalTools(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is Button button && DataContext is ViewModels.Repository repo)
|
if (sender is Button button && DataContext is ViewModels.Repository repo)
|
||||||
{
|
{
|
||||||
|
@ -73,6 +73,58 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OpenGitFlowMenu(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (DataContext is ViewModels.Repository repo)
|
||||||
|
{
|
||||||
|
var menu = repo.CreateContextMenuForGitFlow();
|
||||||
|
(sender as Control)?.OpenContextMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OpenStatistics(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (DataContext is ViewModels.Repository repo)
|
||||||
|
{
|
||||||
|
var dialog = new Statistics() { DataContext = new ViewModels.Statistics(repo.FullPath) };
|
||||||
|
await dialog.ShowDialog(TopLevel.GetTopLevel(this) as Window);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSearchCommitPanelPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var grid = sender as Grid;
|
||||||
|
if (e.Property == IsVisibleProperty && grid.IsVisible)
|
||||||
|
txtSearchCommitsBox.Focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSearchKeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Enter)
|
||||||
|
{
|
||||||
|
if (DataContext is ViewModels.Repository repo)
|
||||||
|
repo.StartSearchCommits();
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSearchResultDataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is DataGrid datagrid && datagrid.SelectedItem != null)
|
||||||
|
{
|
||||||
|
if (DataContext is ViewModels.Repository repo)
|
||||||
|
{
|
||||||
|
var commit = datagrid.SelectedItem as Models.Commit;
|
||||||
|
repo.NavigateToCommit(commit.SHA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnLocalBranchTreeSelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void OnLocalBranchTreeSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is TreeView tree && tree.SelectedItem != null && DataContext is ViewModels.Repository repo)
|
if (sender is TreeView tree && tree.SelectedItem != null && DataContext is ViewModels.Repository repo)
|
||||||
|
@ -113,74 +165,6 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTagDataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is DataGrid datagrid && datagrid.SelectedItem != null)
|
|
||||||
{
|
|
||||||
localBranchTree.UnselectAll();
|
|
||||||
remoteBranchTree.UnselectAll();
|
|
||||||
|
|
||||||
var tag = datagrid.SelectedItem as Models.Tag;
|
|
||||||
if (DataContext is ViewModels.Repository repo)
|
|
||||||
repo.NavigateToCommit(tag.SHA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnSearchCommitPanelPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
|
|
||||||
{
|
|
||||||
var grid = sender as Grid;
|
|
||||||
if (e.Property == IsVisibleProperty && grid.IsVisible)
|
|
||||||
txtSearchCommitsBox.Focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnSearchKeyDown(object sender, KeyEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Key == Key.Enter)
|
|
||||||
{
|
|
||||||
if (DataContext is ViewModels.Repository repo)
|
|
||||||
repo.StartSearchCommits();
|
|
||||||
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnSearchResultDataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is DataGrid datagrid && datagrid.SelectedItem != null)
|
|
||||||
{
|
|
||||||
if (DataContext is ViewModels.Repository repo)
|
|
||||||
{
|
|
||||||
var commit = datagrid.SelectedItem as Models.Commit;
|
|
||||||
repo.NavigateToCommit(commit.SHA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnToggleFilter(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is ToggleButton toggle)
|
|
||||||
{
|
|
||||||
var filter = string.Empty;
|
|
||||||
if (toggle.DataContext is ViewModels.BranchTreeNode node)
|
|
||||||
{
|
|
||||||
if (node.IsBranch)
|
|
||||||
filter = (node.Backend as Models.Branch).FullName;
|
|
||||||
}
|
|
||||||
else if (toggle.DataContext is Models.Tag tag)
|
|
||||||
{
|
|
||||||
filter = tag.Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(filter) && DataContext is ViewModels.Repository repo)
|
|
||||||
{
|
|
||||||
repo.UpdateFilter(filter, toggle.IsChecked == true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnLocalBranchContextMenuRequested(object sender, ContextRequestedEventArgs e)
|
private void OnLocalBranchContextMenuRequested(object sender, ContextRequestedEventArgs e)
|
||||||
{
|
{
|
||||||
remoteBranchTree.UnselectAll();
|
remoteBranchTree.UnselectAll();
|
||||||
|
@ -193,11 +177,11 @@ namespace SourceGit.Views
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var branches = new List<Models.Branch>();
|
var branches = new List<Models.Branch>();
|
||||||
foreach (var item in tree.SelectedItems)
|
foreach (var item in tree.SelectedItems)
|
||||||
CollectBranchesFromNode(branches, item as ViewModels.BranchTreeNode);
|
CollectBranchesFromNode(branches, item as ViewModels.BranchTreeNode);
|
||||||
|
|
||||||
if (branches.Count == 1)
|
if (branches.Count == 1)
|
||||||
{
|
{
|
||||||
var item = (e.Source as Control)?.FindAncestorOfType<TreeViewItem>(true);
|
var item = (e.Source as Control)?.FindAncestorOfType<TreeViewItem>(true);
|
||||||
|
@ -229,7 +213,7 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
localBranchTree.UnselectAll();
|
localBranchTree.UnselectAll();
|
||||||
tagsList.SelectedItem = null;
|
tagsList.SelectedItem = null;
|
||||||
|
|
||||||
var repo = DataContext as ViewModels.Repository;
|
var repo = DataContext as ViewModels.Repository;
|
||||||
var tree = sender as TreeView;
|
var tree = sender as TreeView;
|
||||||
if (tree.SelectedItems.Count == 0)
|
if (tree.SelectedItems.Count == 0)
|
||||||
|
@ -249,12 +233,12 @@ namespace SourceGit.Views
|
||||||
var menu = repo.CreateContextMenuForRemote(node.Backend as Models.Remote);
|
var menu = repo.CreateContextMenuForRemote(node.Backend as Models.Remote);
|
||||||
item.OpenContextMenu(menu);
|
item.OpenContextMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var branches = new List<Models.Branch>();
|
var branches = new List<Models.Branch>();
|
||||||
foreach (var item in tree.SelectedItems)
|
foreach (var item in tree.SelectedItems)
|
||||||
CollectBranchesFromNode(branches, item as ViewModels.BranchTreeNode);
|
CollectBranchesFromNode(branches, item as ViewModels.BranchTreeNode);
|
||||||
|
@ -286,6 +270,39 @@ namespace SourceGit.Views
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDoubleTappedBranchNode(object sender, TappedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!ViewModels.PopupHost.CanCreatePopup())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (sender is Grid grid && DataContext is ViewModels.Repository repo)
|
||||||
|
{
|
||||||
|
var node = grid.DataContext as ViewModels.BranchTreeNode;
|
||||||
|
if (node != null && node.IsBranch)
|
||||||
|
{
|
||||||
|
var branch = node.Backend as Models.Branch;
|
||||||
|
if (branch.IsCurrent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
repo.CheckoutBranch(branch);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTagDataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is DataGrid datagrid && datagrid.SelectedItem != null)
|
||||||
|
{
|
||||||
|
localBranchTree.UnselectAll();
|
||||||
|
remoteBranchTree.UnselectAll();
|
||||||
|
|
||||||
|
var tag = datagrid.SelectedItem as Models.Tag;
|
||||||
|
if (DataContext is ViewModels.Repository repo)
|
||||||
|
repo.NavigateToCommit(tag.SHA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnTagContextRequested(object sender, ContextRequestedEventArgs e)
|
private void OnTagContextRequested(object sender, ContextRequestedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is DataGrid datagrid && datagrid.SelectedItem != null && DataContext is ViewModels.Repository repo)
|
if (sender is DataGrid datagrid && datagrid.SelectedItem != null && DataContext is ViewModels.Repository repo)
|
||||||
|
@ -298,6 +315,30 @@ namespace SourceGit.Views
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnToggleFilter(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is ToggleButton toggle)
|
||||||
|
{
|
||||||
|
var filter = string.Empty;
|
||||||
|
if (toggle.DataContext is ViewModels.BranchTreeNode node)
|
||||||
|
{
|
||||||
|
if (node.IsBranch)
|
||||||
|
filter = (node.Backend as Models.Branch).FullName;
|
||||||
|
}
|
||||||
|
else if (toggle.DataContext is Models.Tag tag)
|
||||||
|
{
|
||||||
|
filter = tag.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(filter) && DataContext is ViewModels.Repository repo)
|
||||||
|
{
|
||||||
|
repo.UpdateFilter(filter, toggle.IsChecked == true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnSubmoduleContextRequested(object sender, ContextRequestedEventArgs e)
|
private void OnSubmoduleContextRequested(object sender, ContextRequestedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is DataGrid datagrid && datagrid.SelectedItem != null && DataContext is ViewModels.Repository repo)
|
if (sender is DataGrid datagrid && datagrid.SelectedItem != null && DataContext is ViewModels.Repository repo)
|
||||||
|
@ -310,17 +351,6 @@ namespace SourceGit.Views
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenGitFlowMenu(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
if (DataContext is ViewModels.Repository repo)
|
|
||||||
{
|
|
||||||
var menu = repo.CreateContextMenuForGitFlow();
|
|
||||||
(sender as Control)?.OpenContextMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void UpdateSubmodules(object sender, RoutedEventArgs e)
|
private async void UpdateSubmodules(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (DataContext is ViewModels.Repository repo)
|
if (DataContext is ViewModels.Repository repo)
|
||||||
|
@ -334,36 +364,6 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDoubleTappedLocalBranchNode(object sender, TappedEventArgs e)
|
|
||||||
{
|
|
||||||
if (!ViewModels.PopupHost.CanCreatePopup())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (sender is Grid grid && DataContext is ViewModels.Repository repo)
|
|
||||||
{
|
|
||||||
var node = grid.DataContext as ViewModels.BranchTreeNode;
|
|
||||||
if (node != null && node.IsBranch)
|
|
||||||
{
|
|
||||||
var branch = node.Backend as Models.Branch;
|
|
||||||
if (branch.IsCurrent)
|
|
||||||
return;
|
|
||||||
|
|
||||||
repo.CheckoutLocalBranch(branch.Name);
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void OpenStatistics(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
if (DataContext is ViewModels.Repository repo)
|
|
||||||
{
|
|
||||||
var dialog = new Statistics() { DataContext = new ViewModels.Statistics(repo.FullPath) };
|
|
||||||
await dialog.ShowDialog(TopLevel.GetTopLevel(this) as Window);
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CollectBranchesFromNode(List<Models.Branch> outs, ViewModels.BranchTreeNode node)
|
private void CollectBranchesFromNode(List<Models.Branch> outs, ViewModels.BranchTreeNode node)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue