mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
code_review: review for PR (#147)
* code style * localizations for zh_CN
This commit is contained in:
parent
e00bc4e630
commit
66f2aab6a7
11 changed files with 43 additions and 51 deletions
|
@ -8,6 +8,7 @@ namespace SourceGit.Commands
|
|||
{
|
||||
private const string PREFIX_LOCAL = "refs/heads/";
|
||||
private const string PREFIX_REMOTE = "refs/remotes/";
|
||||
private const string PREFIX_DETACHED = "(HEAD detached at";
|
||||
|
||||
[GeneratedRegex(@"^(\d+)\s(\d+)$")]
|
||||
private static partial Regex REG_AHEAD_BEHIND();
|
||||
|
@ -52,9 +53,9 @@ namespace SourceGit.Commands
|
|||
if (refName.EndsWith("/HEAD", StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
if (refName.StartsWith("(HEAD detached at"))
|
||||
if (refName.StartsWith(PREFIX_DETACHED, StringComparison.Ordinal))
|
||||
{
|
||||
branch.isHead = true;
|
||||
branch.IsHead = true;
|
||||
}
|
||||
|
||||
if (refName.StartsWith(PREFIX_LOCAL, StringComparison.Ordinal))
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
public string Upstream { get; set; }
|
||||
public string UpstreamTrackStatus { get; set; }
|
||||
public string Remote { get; set; }
|
||||
public bool isHead { get; set; }
|
||||
public bool IsHead { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,9 +56,8 @@
|
|||
<x:String x:Key="Text.Checkout" xml:space="preserve">Checkout Branch</x:String>
|
||||
<x:String x:Key="Text.Checkout.Commit" xml:space="preserve">Checkout Commit</x:String>
|
||||
<x:String x:Key="Text.Checkout.Commit.Warning" xml:space="preserve">Warning: By doing a commit checkout, your Head will be detached</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.CommitTarget.Sha" xml:space="preserve">Commit SHA :</x:String>
|
||||
<x:String x:Key="Text.Checkout.CommitTarget.ShortSha" xml:space="preserve">Commit Short SHA :</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>
|
||||
|
|
|
@ -54,6 +54,9 @@
|
|||
<x:String x:Key="Text.ChangeDisplayMode.List" xml:space="preserve">列表模式</x:String>
|
||||
<x:String x:Key="Text.ChangeDisplayMode.Tree" xml:space="preserve">树形模式</x:String>
|
||||
<x:String x:Key="Text.Checkout" xml:space="preserve">检出(checkout)分支</x:String>
|
||||
<x:String x:Key="Text.Checkout.Commit" xml:space="preserve">检出(checkout)提交</x:String>
|
||||
<x:String x:Key="Text.Checkout.Commit.Warning" xml:space="preserve">注意:执行该操作后,当前HEAD会变为游离(detached)状态!</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.LocalChanges" xml:space="preserve">未提交更改 :</x:String>
|
||||
<x:String x:Key="Text.Checkout.LocalChanges.StashAndReply" xml:space="preserve">贮藏(stash)并自动恢复</x:String>
|
||||
|
@ -73,6 +76,7 @@
|
|||
<x:String x:Key="Text.Clone.RemoteURL" xml:space="preserve">远程仓库 :</x:String>
|
||||
<x:String x:Key="Text.Close" xml:space="preserve">关闭</x:String>
|
||||
<x:String x:Key="Text.CommitCM.CherryPick" xml:space="preserve">挑选(cherry-pick)此提交</x:String>
|
||||
<x:String x:Key="Text.CommitCM.Checkout" xml:space="preserve">检出提交${0}</x:String>
|
||||
<x:String x:Key="Text.CommitCM.CopySHA" xml:space="preserve">复制提交指纹</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>
|
||||
|
|
|
@ -44,11 +44,4 @@
|
|||
<TrimmerRootAssembly Include="SourceGit" />
|
||||
<TrimmerRootAssembly Include="Avalonia.Themes.Fluent" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Views\CheckoutCommit.axaml.cs">
|
||||
<DependentUpon>CheckoutCommit.axaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -223,7 +223,7 @@ namespace SourceGit.ViewModels
|
|||
lastFolder.Children.Add(new BranchTreeNode()
|
||||
{
|
||||
Name = Path.GetFileName(branch.Name),
|
||||
Type = branch.isHead ? BranchTreeNodeType.DetachedHead : BranchTreeNodeType.Branch,
|
||||
Type = branch.IsHead ? BranchTreeNodeType.DetachedHead : BranchTreeNodeType.Branch,
|
||||
Backend = branch,
|
||||
IsExpanded = false,
|
||||
IsFiltered = isFiltered,
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
public class CheckoutCommit: Popup
|
||||
{
|
||||
public string Commit
|
||||
public Models.Commit Commit
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
|
@ -21,7 +21,7 @@ namespace SourceGit.ViewModels
|
|||
set => SetProperty(ref _autoStash, value);
|
||||
}
|
||||
|
||||
public CheckoutCommit(Repository repo, string commit)
|
||||
public CheckoutCommit(Repository repo, Models.Commit commit)
|
||||
{
|
||||
_repo = repo;
|
||||
Commit = commit;
|
||||
|
@ -31,7 +31,7 @@ namespace SourceGit.ViewModels
|
|||
public override Task<bool> Sure()
|
||||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
ProgressDescription = $"Checkout Commit '{Commit}' ...";
|
||||
ProgressDescription = $"Checkout Commit '{Commit.SHA}' ...";
|
||||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
|
||||
SetProgressDescription("Checkout commit ...");
|
||||
var rs = new Commands.Checkout(_repo.FullPath).Commit(Commit, SetProgressDescription);
|
||||
var rs = new Commands.Checkout(_repo.FullPath).Commit(Commit.SHA, SetProgressDescription);
|
||||
|
||||
if (needPopStash)
|
||||
{
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
|
||||
|
@ -238,15 +236,11 @@ namespace SourceGit.ViewModels
|
|||
menu.Items.Add(reset);
|
||||
|
||||
var checkoutCommit = new MenuItem();
|
||||
|
||||
var shortSha = Converters.StringConverters.ToShortSHA
|
||||
.Convert(commit.SHA, typeof(string), null, CultureInfo.CurrentCulture);
|
||||
|
||||
checkoutCommit.Header = new Views.NameHighlightedTextBlock("CommitCM.Checkout", shortSha);
|
||||
checkoutCommit.Header = new Views.NameHighlightedTextBlock("CommitCM.Checkout", commit.SHA.Substring(0, 10));
|
||||
checkoutCommit.Icon = App.CreateMenuIcon("Icons.Check");
|
||||
checkoutCommit.Click += (o, e) =>
|
||||
{
|
||||
_repo.CheckoutCommit(commit.SHA);
|
||||
_repo.CheckoutCommit(commit);
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(checkoutCommit);
|
||||
|
|
|
@ -722,7 +722,7 @@ namespace SourceGit.ViewModels
|
|||
PopupHost.ShowAndStartPopup(new Checkout(this, branch));
|
||||
}
|
||||
|
||||
public void CheckoutCommit(string commit)
|
||||
public void CheckoutCommit(Models.Commit commit)
|
||||
{
|
||||
if (!PopupHost.CanCreatePopup())
|
||||
return;
|
||||
|
|
|
@ -10,36 +10,38 @@
|
|||
<StackPanel Orientation="Vertical" Margin="8,0">
|
||||
<TextBlock FontSize="18"
|
||||
Classes="bold"
|
||||
Text="{DynamicResource Text.Checkout.Commit}"/>
|
||||
Text="{DynamicResource Text.Checkout.Commit}" />
|
||||
|
||||
<TextBlock FontSize="14"
|
||||
TextWrapping="Wrap"
|
||||
Classes="italic"
|
||||
Text="{DynamicResource Text.Checkout.Commit.Warning}"/>
|
||||
<TextBlock Margin="0,8,0,16"
|
||||
Text="{DynamicResource Text.Checkout.Commit.Warning}"
|
||||
TextWrapping="Wrap"
|
||||
Foreground="{DynamicResource Brush.FG2}"
|
||||
FontStyle="Italic"/>
|
||||
|
||||
<TextBlock TextWrapping="Wrap" Margin="0,16,0,0">
|
||||
<TextBlock Classes="bold" Grid.Row="0" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Checkout.CommitTarget.Sha}"/>
|
||||
<TextBlock TextWrapping="Wrap" Text="{Binding Commit}"/>
|
||||
(<TextBlock Classes="italic" TextWrapping="Wrap" Text="{Binding Commit, Converter={x:Static c:StringConverters.ToShortSHA}}"/>)
|
||||
</TextBlock>
|
||||
|
||||
<StackPanel Margin="0, 26, 0, 0" Grid.Row="1" Grid.Column="1" Orientation="Vertical" IsVisible="{Binding HasLocalChanges}">
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
<Grid RowDefinitions="32,Auto" ColumnDefinitions="120,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.Checkout.LocalChanges}"/>
|
||||
Text="{DynamicResource Text.Checkout.Commit.Target}" />
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
|
||||
<Path Width="14" Height="14" Margin="0,8,0,0" Data="{StaticResource Icons.Commit}" />
|
||||
<TextBlock Classes="monospace" Foreground="DarkOrange" VerticalAlignment="Center" Margin="8,0" Text="{Binding Commit.SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" />
|
||||
<TextBlock Text="{Binding Commit.Subject}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Margin="0, 13, 0, 0" Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.Checkout.LocalChanges}"
|
||||
IsVisible="{Binding HasLocalChanges}"/>
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Height="32" Orientation="Horizontal" IsVisible="{Binding HasLocalChanges}">
|
||||
<RadioButton Content="{DynamicResource Text.Checkout.LocalChanges.StashAndReply}"
|
||||
GroupName="LocalChanges"
|
||||
IsChecked="{Binding AutoStash, Mode=TwoWay}"/>
|
||||
IsChecked="{Binding AutoStash, Mode=TwoWay}" />
|
||||
<RadioButton Content="{DynamicResource Text.Checkout.LocalChanges.Discard}"
|
||||
GroupName="LocalChanges"
|
||||
Margin="8,0,0,0"/>
|
||||
Margin="8,0,0,0" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace SourceGit.Views
|
|||
{
|
||||
public partial class CheckoutCommit : UserControl
|
||||
{
|
||||
public bool HasLocalChanges;
|
||||
public CheckoutCommit()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
|
Loading…
Reference in a new issue