mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-22 10:55:00 +00:00
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
64ffbb113f
commit
9bfc315ace
7 changed files with 147 additions and 0 deletions
|
@ -120,6 +120,7 @@
|
|||
<x:String x:Key="Text.CommitCM.InteractiveRebase" xml:space="preserve">Interactively Rebase ${0}$ on Here</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Merge" xml:space="preserve">Merge to ${0}$</x:String>
|
||||
<x:String x:Key="Text.CommitCM.MergeMultiple" xml:space="preserve">Merge ...</x:String>
|
||||
<x:String x:Key="Text.CommitCM.PushRevision" xml:space="preserve">Push ${0}$ to ${1}$</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Rebase" xml:space="preserve">Rebase ${0}$ on Here</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Reset" xml:space="preserve">Reset ${0}$ to Here</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Revert" xml:space="preserve">Revert Commit</x:String>
|
||||
|
@ -554,6 +555,8 @@
|
|||
<x:String x:Key="Text.Push.Force" xml:space="preserve">Force push</x:String>
|
||||
<x:String x:Key="Text.Push.Local" xml:space="preserve">Local Branch:</x:String>
|
||||
<x:String x:Key="Text.Push.Remote" xml:space="preserve">Remote:</x:String>
|
||||
<x:String x:Key="Text.Push.Revision" xml:space="preserve">Revision:</x:String>
|
||||
<x:String x:Key="Text.Push.Revision.Title" xml:space="preserve">Push Revision To Remote</x:String>
|
||||
<x:String x:Key="Text.Push.Title" xml:space="preserve">Push Changes To Remote</x:String>
|
||||
<x:String x:Key="Text.Push.To" xml:space="preserve">Remote Branch:</x:String>
|
||||
<x:String x:Key="Text.Push.Tracking" xml:space="preserve">Set as tracking branch</x:String>
|
||||
|
|
|
@ -124,6 +124,7 @@
|
|||
<x:String x:Key="Text.CommitCM.InteractiveRebase" xml:space="preserve">交互式变基(rebase -i) ${0}$ 到此处</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Merge" xml:space="preserve">合并(merge)此提交至 ${0}$</x:String>
|
||||
<x:String x:Key="Text.CommitCM.MergeMultiple" xml:space="preserve">合并(merge)...</x:String>
|
||||
<x:String x:Key="Text.CommitCM.PushRevision" xml:space="preserve">推送(push) ${0}$ 到 ${1}$</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Rebase" xml:space="preserve">变基(rebase) ${0}$ 到此处</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Reset" xml:space="preserve">重置(reset) ${0}$ 到此处</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Revert" xml:space="preserve">回滚此提交</x:String>
|
||||
|
@ -558,6 +559,8 @@
|
|||
<x:String x:Key="Text.Push.Force" xml:space="preserve">启用强制推送</x:String>
|
||||
<x:String x:Key="Text.Push.Local" xml:space="preserve">本地分支 :</x:String>
|
||||
<x:String x:Key="Text.Push.Remote" xml:space="preserve">远程仓库 :</x:String>
|
||||
<x:String x:Key="Text.Push.Revision" xml:space="preserve">修订 :</x:String>
|
||||
<x:String x:Key="Text.Push.Revision.Title" xml:space="preserve">推送指定修订到远程仓库</x:String>
|
||||
<x:String x:Key="Text.Push.Title" xml:space="preserve">推送到远程仓库</x:String>
|
||||
<x:String x:Key="Text.Push.To" xml:space="preserve">远程分支 :</x:String>
|
||||
<x:String x:Key="Text.Push.Tracking" xml:space="preserve">跟踪远程分支</x:String>
|
||||
|
|
|
@ -124,6 +124,7 @@
|
|||
<x:String x:Key="Text.CommitCM.InteractiveRebase" xml:space="preserve">互動式重定基底 (rebase -i) ${0}$ 到此處</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Merge" xml:space="preserve">合併 (merge) 此提交到 ${0}$</x:String>
|
||||
<x:String x:Key="Text.CommitCM.MergeMultiple" xml:space="preserve">合併 (merge)...</x:String>
|
||||
<x:String x:Key="Text.CommitCM.PushRevision" xml:space="preserve">推送(push) ${0}$ 至 ${1}$</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Rebase" xml:space="preserve">重定基底 (rebase) ${0}$ 到此處</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Reset" xml:space="preserve">重設 (reset) ${0}$ 到此處</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Revert" xml:space="preserve">復原此提交</x:String>
|
||||
|
@ -558,6 +559,8 @@
|
|||
<x:String x:Key="Text.Push.Force" xml:space="preserve">啟用強制推送</x:String>
|
||||
<x:String x:Key="Text.Push.Local" xml:space="preserve">本機分支:</x:String>
|
||||
<x:String x:Key="Text.Push.Remote" xml:space="preserve">遠端存放庫:</x:String>
|
||||
<x:String x:Key="Text.Push.Revision" xml:space="preserve">修訂:</x:String>
|
||||
<x:String x:Key="Text.Push.Revision.Title" xml:space="preserve">推送修訂到遠端存放庫</x:String>
|
||||
<x:String x:Key="Text.Push.Title" xml:space="preserve">推送到遠端存放庫</x:String>
|
||||
<x:String x:Key="Text.Push.To" xml:space="preserve">遠端分支:</x:String>
|
||||
<x:String x:Key="Text.Push.Tracking" xml:space="preserve">追蹤遠端分支</x:String>
|
||||
|
|
|
@ -666,6 +666,22 @@ namespace SourceGit.ViewModels
|
|||
|
||||
if (current.Head != commit.SHA)
|
||||
{
|
||||
if (current.TrackStatus.Ahead.Contains(commit.SHA))
|
||||
{
|
||||
var upstream = _repo.Branches.Find(x => x.FullName.Equals(current.Upstream, StringComparison.Ordinal));
|
||||
var pushRevision = new MenuItem();
|
||||
pushRevision.Header = App.Text("CommitCM.PushRevision", commit.SHA.Substring(0, 10), upstream.FriendlyName);
|
||||
pushRevision.Icon = App.CreateMenuIcon("Icons.Push");
|
||||
pushRevision.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new PushRevision(_repo, commit, upstream));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(pushRevision);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
|
||||
var compareWithHead = new MenuItem();
|
||||
compareWithHead.Header = App.Text("CommitCM.CompareWithHead");
|
||||
compareWithHead.Icon = App.CreateMenuIcon("Icons.Compare");
|
||||
|
|
59
src/ViewModels/PushRevision.cs
Normal file
59
src/ViewModels/PushRevision.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class PushRevision : Popup
|
||||
{
|
||||
public Models.Commit Revision
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public Models.Branch RemoteBranch
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public bool Force
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public PushRevision(Repository repo, Models.Commit revision, Models.Branch remoteBranch)
|
||||
{
|
||||
_repo = repo;
|
||||
Revision = revision;
|
||||
RemoteBranch = remoteBranch;
|
||||
Force = false;
|
||||
}
|
||||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
ProgressDescription = $"Push {Revision.SHA.Substring(0, 10)} -> {RemoteBranch.FriendlyName} ...";
|
||||
|
||||
var log = _repo.CreateLog("Push Revision");
|
||||
Use(log);
|
||||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var succ = new Commands.Push(
|
||||
_repo.FullPath,
|
||||
Revision.SHA,
|
||||
RemoteBranch.Remote,
|
||||
RemoteBranch.Name,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
Force).Use(log).Exec();
|
||||
|
||||
log.Complete();
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
return succ;
|
||||
});
|
||||
}
|
||||
|
||||
private readonly Repository _repo;
|
||||
}
|
||||
}
|
51
src/Views/PushRevision.axaml
Normal file
51
src/Views/PushRevision.axaml
Normal file
|
@ -0,0 +1,51 @@
|
|||
<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"
|
||||
xmlns:c="using:SourceGit.Converters"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SourceGit.Views.PushRevision"
|
||||
x:DataType="vm:PushRevision">
|
||||
<StackPanel Orientation="Vertical" Margin="8,0">
|
||||
<TextBlock FontSize="18"
|
||||
Classes="bold"
|
||||
Text="{DynamicResource Text.Push.Revision.Title}"/>
|
||||
|
||||
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32" ColumnDefinitions="130,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.Push.Revision}"/>
|
||||
<Grid Grid.Row="0" Grid.Column="1" ColumnDefinitions="Auto,Auto,*">
|
||||
<Path Grid.Column="0" Width="14" Height="14" Data="{StaticResource Icons.Commit}"/>
|
||||
<TextBlock Grid.Column="1"
|
||||
Classes="primary"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Revision.SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
|
||||
Foreground="DarkOrange"
|
||||
Margin="8,0,0,0"/>
|
||||
<TextBlock Grid.Column="2"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Revision.Subject}"
|
||||
Margin="4,0,0,0"
|
||||
TextTrimming="CharacterEllipsis"/>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.Push.To}"/>
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Branch}"/>
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding RemoteBranch.FriendlyName}" Margin="8,0,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<CheckBox Grid.Row="2" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Push.Force}"
|
||||
IsChecked="{Binding Force, Mode=TwoWay}"
|
||||
ToolTip.Tip="--force-with-lease"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</UserControl>
|
12
src/Views/PushRevision.axaml.cs
Normal file
12
src/Views/PushRevision.axaml.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using Avalonia.Controls;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class PushRevision : UserControl
|
||||
{
|
||||
public PushRevision()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue