mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-26 21:17:20 -08:00
Compare commits
11 commits
95a63eb98d
...
6908216de5
Author | SHA1 | Date | |
---|---|---|---|
|
6908216de5 | ||
|
207bcf0fbf | ||
|
010eb65edb | ||
|
a232f50755 | ||
|
1a4055ee97 | ||
|
cc66afe5e2 | ||
|
5fef6e93b9 | ||
|
688f10e02f | ||
|
efc14fed36 | ||
|
49e769b025 | ||
|
84e724f014 |
21 changed files with 250 additions and 156 deletions
|
@ -81,7 +81,6 @@ For **macOS** users:
|
|||
* Make sure your mac trusts all software from anywhere. For more information, search `spctl --master-disable`.
|
||||
* Make sure [git-credential-manager](https://github.com/git-ecosystem/git-credential-manager/releases) is installed on your mac.
|
||||
* You may need to run `sudo xattr -cr /Applications/SourceGit.app` to make sure the software works.
|
||||
* You may need to start this app from commandline by using `open -a SourceGit` to introduce the `PATH` environment variable from your shell.
|
||||
|
||||
For **Linux** users:
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
8.33
|
||||
8.34
|
|
@ -2,12 +2,19 @@
|
|||
{
|
||||
public class CherryPick : Command
|
||||
{
|
||||
public CherryPick(string repo, string commits, bool noCommit)
|
||||
public CherryPick(string repo, string commits, bool noCommit, bool appendSourceToMessage, string extraParams)
|
||||
{
|
||||
var mode = noCommit ? "-n" : "--ff";
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = $"cherry-pick {mode} {commits}";
|
||||
|
||||
Args = "cherry-pick ";
|
||||
if (noCommit)
|
||||
Args += "-n ";
|
||||
if (appendSourceToMessage)
|
||||
Args += "-x ";
|
||||
if (!string.IsNullOrEmpty(extraParams))
|
||||
Args += $"{extraParams} ";
|
||||
Args += commits;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,15 +195,6 @@ namespace SourceGit.Commands
|
|||
if (OperatingSystem.IsLinux())
|
||||
start.Environment.Add("LANG", "en_US.UTF-8");
|
||||
|
||||
// Fix sometimes `LSEnvironment` not working on macOS
|
||||
if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
if (start.Environment.TryGetValue("PATH", out var path))
|
||||
start.Environment.Add("PATH", $"/opt/homebrew/bin:/opt/homebrew/sbin:{path}");
|
||||
else
|
||||
start.Environment.Add("PATH", "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");
|
||||
}
|
||||
|
||||
// Force using this app as git editor.
|
||||
switch (Editor)
|
||||
{
|
||||
|
|
|
@ -31,18 +31,19 @@ namespace SourceGit.Models
|
|||
public List<Decorator> Decorators { get; set; } = new List<Decorator>();
|
||||
public bool HasDecorators => Decorators.Count > 0;
|
||||
|
||||
public bool IsMerged { get; set; } = false;
|
||||
public Thickness Margin { get; set; } = new Thickness(0);
|
||||
|
||||
public string AuthorTimeStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||||
public string CommitterTimeStr => DateTime.UnixEpoch.AddSeconds(CommitterTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||||
public string AuthorTimeShortStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString("yyyy/MM/dd");
|
||||
|
||||
public bool IsMerged { get; set; } = false;
|
||||
public bool IsCommitterVisible => !Author.Equals(Committer) || AuthorTime != CommitterTime;
|
||||
public bool IsCurrentHead => Decorators.Find(x => x.Type is DecoratorType.CurrentBranchHead or DecoratorType.CurrentCommitHead) != null;
|
||||
|
||||
public int Color { get; set; } = 0;
|
||||
public double Opacity => IsMerged ? 1 : OpacityForNotMerged;
|
||||
public FontWeight FontWeight => IsCurrentHead ? FontWeight.Bold : FontWeight.Regular;
|
||||
public Thickness Margin { get; set; } = new Thickness(0);
|
||||
public IBrush Brush => CommitGraph.Pens[Color].Brush;
|
||||
|
||||
public void ParseDecorators(string data)
|
||||
{
|
||||
|
|
|
@ -186,6 +186,7 @@ namespace SourceGit.Models
|
|||
// Margins & merge state (used by Views.Histories).
|
||||
commit.IsMerged = isMerged;
|
||||
commit.Margin = new Thickness(Math.Max(offsetX, maxOffsetOld) + halfWidth + 2, 0, 0, 0);
|
||||
commit.Color = dotColor;
|
||||
}
|
||||
|
||||
// Deal with curves haven't ended yet.
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace SourceGit.Models
|
|||
{
|
||||
var count = Math.Min(int.Parse(countStr.Substring(1)), changes.Count);
|
||||
for (int j = 0; j < count; j++)
|
||||
paths.Add(changes[i].Path);
|
||||
paths.Add(changes[j].Path);
|
||||
|
||||
if (count < changes.Count)
|
||||
more = $" and {changes.Count - count} other files";
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text;
|
||||
|
||||
using Avalonia;
|
||||
|
||||
|
@ -17,6 +18,31 @@ namespace SourceGit.Native
|
|||
{
|
||||
DisableDefaultApplicationMenuItems = true,
|
||||
});
|
||||
|
||||
{
|
||||
var startInfo = new ProcessStartInfo();
|
||||
startInfo.FileName = "zsh";
|
||||
startInfo.Arguments = "--login -c \"echo $PATH\"";
|
||||
startInfo.UseShellExecute = false;
|
||||
startInfo.CreateNoWindow = true;
|
||||
startInfo.RedirectStandardOutput = true;
|
||||
startInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
|
||||
try
|
||||
{
|
||||
var proc = new Process() { StartInfo = startInfo };
|
||||
proc.Start();
|
||||
var pathData = proc.StandardOutput.ReadToEnd();
|
||||
proc.WaitForExit();
|
||||
if (proc.ExitCode == 0)
|
||||
Environment.SetEnvironmentVariable("PATH", pathData);
|
||||
proc.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore error.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string FindGitExecutable()
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
<StreamGeometry x:Key="Icons.GitFlow.Release">M884 159l-18-18a43 43 0 00-38-12l-235 43a166 166 0 00-101 60L400 349a128 128 0 00-148 47l-120 171a21 21 0 005 29l17 12a128 128 0 00178-32l27-38 124 124-38 27a128 128 0 00-32 178l12 17a21 21 0 0029 5l171-120a128 128 0 0047-148l117-92A166 166 0 00853 431l43-235a43 43 0 00-12-38zm-177 249a64 64 0 110-90 64 64 0 010 90zm-373 312a21 21 0 010 30l-139 139a21 21 0 01-30 0l-30-30a21 21 0 010-30l139-139a21 21 0 0130 0z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.GitIgnore">M590 74 859 342V876c0 38-31 68-68 68H233c-38 0-68-31-68-68V142c0-38 31-68 68-68h357zm-12 28H233a40 40 0 00-40 38L193 142v734a40 40 0 0038 40L233 916h558a40 40 0 0040-38L831 876V354L578 102zM855 371h-215c-46 0-83-36-84-82l0-2V74h28v213c0 30 24 54 54 55l2 0h215v28zM57 489m28 0 853 0q28 0 28 28l0 284q0 28-28 28l-853 0q-28 0-28-28l0-284q0-28 28-28ZM157 717c15 0 29-6 37-13v-51h-41v22h17v18c-2 2-6 3-10 3-21 0-30-13-30-34 0-21 12-34 28-34 9 0 15 4 20 9l14-17C184 610 172 603 156 603c-29 0-54 21-54 57 0 37 24 56 54 56zM245 711v-108h-34v108h34zm69 0v-86H341V603H262v22h28V711h24zM393 711v-108h-34v108h34zm66 6c15 0 29-6 37-13v-51h-41v22h17v18c-2 2-6 3-10 3-21 0-30-13-30-34 0-21 12-34 28-34 9 0 15 4 20 9l14-17C485 610 474 603 458 603c-29 0-54 21-54 57 0 37 24 56 54 56zm88-6v-36c0-13-2-28-3-40h1l10 24 25 52H603v-108h-23v36c0 13 2 28 3 40h-1l-10-24L548 603H523v108h23zM677 717c30 0 51-22 51-57 0-36-21-56-51-56-30 0-51 20-51 56 0 36 21 57 51 57zm3-23c-16 0-26-12-26-32 0-19 10-31 26-31 16 0 26 11 26 31S696 694 680 694zm93 17v-38h13l21 38H836l-25-43c12-5 19-15 19-31 0-26-20-34-44-34H745v108h27zm16-51H774v-34h15c16 0 25 4 25 16s-9 18-25 18zM922 711v-22h-43v-23h35v-22h-35V625h41V603H853v108h68z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Grid">M30 271l241 0 0-241-241 0 0 241zM392 271l241 0 0-241-241 0 0 241zM753 30l0 241 241 0 0-241-241 0zM30 632l241 0 0-241-241 0 0 241zM392 632l241 0 0-241-241 0 0 241zM753 632l241 0 0-241-241 0 0 241zM30 994l241 0 0-241-241 0 0 241zM392 994l241 0 0-241-241 0 0 241zM753 994l241 0 0-241-241 0 0 241z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Head">M0 512M1024 512M512 0M512 1024M955 323q0 23-16 39l-414 414-78 78q-16 16-39 16t-39-16l-78-78-207-207q-16-16-16-39t16-39l78-78q16-16 39-16t39 16l168 169 375-375q16-16 39-16t39 16l78 78q16 16 16 39z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.HiddenSymbol">M416 64H768v64h-64v704h64v64H448v-64h64V512H416a224 224 0 1 1 0-448zM576 832h64V128H576v704zM416 128H512v320H416a160 160 0 0 1 0-320z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Histories">M24 512A488 488 0 01512 24A488 488 0 011000 512A488 488 0 01512 1000A488 488 0 0124 512zm447-325v327L243 619l51 111 300-138V187H471z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Home">M832 64h128v278l-128-146V64zm64 448L512 73 128 512H0L448 0h128l448 512h-128zm0 83V1024H640V704c0-35-29-64-64-64h-128a64 64 0 00-64 64v320H128V595l384-424 384 424z</StreamGeometry>
|
||||
|
|
|
@ -83,8 +83,11 @@
|
|||
<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</x:String>
|
||||
<x:String x:Key="Text.CherryPick.AppendSourceToMessage" xml:space="preserve">Append source to commit message</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Commit" xml:space="preserve">Commit(s):</x:String>
|
||||
<x:String x:Key="Text.CherryPick.CommitChanges" xml:space="preserve">Commit all changes</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Mainline" xml:space="preserve">Mainline:</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Mainline.Tips" xml:space="preserve">Usually you cannot cherry-pick a merge because you do not know which side of the merge should be considered the mainline. This option allows cherry-pick to replay the change relative to the specified parent.</x:String>
|
||||
<x:String x:Key="Text.ClearStashes" xml:space="preserve">Clear Stashes</x:String>
|
||||
<x:String x:Key="Text.ClearStashes.Message" xml:space="preserve">You are trying to clear all stashes. Are you sure to continue?</x:String>
|
||||
<x:String x:Key="Text.Clone" xml:space="preserve">Clone Remote Repository</x:String>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<x:String x:Key="Text.About" xml:space="preserve">О программе</x:String>
|
||||
<x:String x:Key="Text.About.Menu" xml:space="preserve">О SourceGit</x:String>
|
||||
<x:String x:Key="Text.About.BuildWith" xml:space="preserve">• Сборка с </x:String>
|
||||
<x:String x:Key="Text.About.Chart" xml:space="preserve">• Диаграмма отображается с помощью</x:String>
|
||||
<x:String x:Key="Text.About.Copyright" xml:space="preserve">© 2024 sourcegit-scm</x:String>
|
||||
<x:String x:Key="Text.About.Editor" xml:space="preserve">• Текстовый редактор от </x:String>
|
||||
<x:String x:Key="Text.About.Fonts" xml:space="preserve">• Моноширинные шрифты взяты из </x:String>
|
||||
|
@ -316,6 +317,7 @@
|
|||
<x:String x:Key="Text.Histories.DisplayMode" xml:space="preserve">Переключение горизонтального/вертикального расположения</x:String>
|
||||
<x:String x:Key="Text.Histories.GraphMode" xml:space="preserve">Переключение режима построения кривой/полилинии</x:String>
|
||||
<x:String x:Key="Text.Histories.Header.Author" xml:space="preserve">АВТОР</x:String>
|
||||
<x:String x:Key="Text.Histories.Header.AuthorTime" xml:space="preserve">ВРЕМЯ АВТОРА</x:String>
|
||||
<x:String x:Key="Text.Histories.Header.GraphAndSubject" xml:space="preserve">ГРАФ И СУБЪЕКТ</x:String>
|
||||
<x:String x:Key="Text.Histories.Header.SHA" xml:space="preserve">SHA</x:String>
|
||||
<x:String x:Key="Text.Histories.Header.Time" xml:space="preserve">ВРЕМЯ ФИКСАЦИИ</x:String>
|
||||
|
@ -415,6 +417,7 @@
|
|||
<x:String x:Key="Text.Preference.General.Check4UpdatesOnStartup" xml:space="preserve">Проверить обновления при старте</x:String>
|
||||
<x:String x:Key="Text.Preference.General.Locale" xml:space="preserve">Язык</x:String>
|
||||
<x:String x:Key="Text.Preference.General.MaxHistoryCommits" xml:space="preserve">История фиксаций</x:String>
|
||||
<x:String x:Key="Text.Preference.General.ShowAuthorTime" xml:space="preserve">Показать время автора вместо времени фиксации на графике</x:String>
|
||||
<x:String x:Key="Text.Preference.General.SubjectGuideLength" xml:space="preserve">Длина темы фиксации</x:String>
|
||||
<x:String x:Key="Text.Preference.Git" xml:space="preserve">GIT</x:String>
|
||||
<x:String x:Key="Text.Preference.Git.CRLF" xml:space="preserve">Включить автозавершение CRLF</x:String>
|
||||
|
|
|
@ -86,8 +86,11 @@
|
|||
<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">挑选提交</x:String>
|
||||
<x:String x:Key="Text.CherryPick.AppendSourceToMessage" xml:space="preserve">提交信息中追加来源信息</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Commit" xml:space="preserve">提交列表 :</x:String>
|
||||
<x:String x:Key="Text.CherryPick.CommitChanges" xml:space="preserve">提交变化</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Mainline" xml:space="preserve">对比的父提交 :</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Mainline.Tips" xml:space="preserve">通常你不能对一个合并进行挑选,因为你不知道合并的哪一边应该被视为主线。这个选项指定了作为主线的父提交,允许挑选相对于该提交的修改。</x:String>
|
||||
<x:String x:Key="Text.ClearStashes" xml:space="preserve">丢弃贮藏确认</x:String>
|
||||
<x:String x:Key="Text.ClearStashes.Message" xml:space="preserve">您正在丢弃所有的贮藏,一经操作,无法回退,是否继续?</x:String>
|
||||
<x:String x:Key="Text.Clone" xml:space="preserve">克隆远程仓库</x:String>
|
||||
|
|
|
@ -86,8 +86,11 @@
|
|||
<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">揀選提交</x:String>
|
||||
<x:String x:Key="Text.CherryPick.AppendSourceToMessage" xml:space="preserve">提交資訊中追加來源資訊</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Commit" xml:space="preserve">提交列表:</x:String>
|
||||
<x:String x:Key="Text.CherryPick.CommitChanges" xml:space="preserve">提交變更</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Mainline" xml:space="preserve">對比的父提交:</x:String>
|
||||
<x:String x:Key="Text.CherryPick.Mainline.Tips" xml:space="preserve">通常你不能對一個合併進行揀選,因為你不知道合併的哪一邊應該被視為主線。這個選項指定了作為主線的父提交,允許揀選相對於該提交的修改。</x:String>
|
||||
<x:String x:Key="Text.ClearStashes" xml:space="preserve">捨棄擱置變更確認</x:String>
|
||||
<x:String x:Key="Text.ClearStashes.Message" xml:space="preserve">您正在捨棄所有的擱置變更,一經操作便無法復原,是否繼續?</x:String>
|
||||
<x:String x:Key="Text.Clone" xml:space="preserve">複製 (clone) 遠端存放庫</x:String>
|
||||
|
|
|
@ -10,12 +10,7 @@
|
|||
<Color x:Key="Color.Contents">#FFFAFAFA</Color>
|
||||
<Color x:Key="Color.Badge">#FFB0CEE8</Color>
|
||||
<Color x:Key="Color.BadgeFG">#FF1F1F1F</Color>
|
||||
<Color x:Key="Color.DecoratorIconBG">#A0A0A0</Color>
|
||||
<Color x:Key="Color.DecoratorIcon">White</Color>
|
||||
<Color x:Key="Color.DecoratorBranch">#008585</Color>
|
||||
<Color x:Key="Color.DecoratorHead">#0C0E21</Color>
|
||||
<Color x:Key="Color.DecoratorTag">#79855f</Color>
|
||||
<Color x:Key="Color.DecoratorFG">White</Color>
|
||||
<Color x:Key="Color.Conflict">#FF836C2E</Color>
|
||||
<Color x:Key="Color.ConflictForeground">#FFFFFFFF</Color>
|
||||
<Color x:Key="Color.Border0">#FFCFCFCF</Color>
|
||||
|
@ -42,12 +37,7 @@
|
|||
<Color x:Key="Color.Contents">#FF1C1C1C</Color>
|
||||
<Color x:Key="Color.Badge">#FF8F8F8F</Color>
|
||||
<Color x:Key="Color.BadgeFG">#FFDDDDDD</Color>
|
||||
<Color x:Key="Color.DecoratorIconBG">#FF505050</Color>
|
||||
<Color x:Key="Color.DecoratorIcon">#FFF8F8F8</Color>
|
||||
<Color x:Key="Color.DecoratorBranch">#FFFFB835</Color>
|
||||
<Color x:Key="Color.DecoratorHead">#f4f1de</Color>
|
||||
<Color x:Key="Color.DecoratorTag">#84c88a</Color>
|
||||
<Color x:Key="Color.DecoratorFG">Black</Color>
|
||||
<Color x:Key="Color.Conflict">#FFFAFAD2</Color>
|
||||
<Color x:Key="Color.ConflictForeground">#FF252525</Color>
|
||||
<Color x:Key="Color.Border0">#FF181818</Color>
|
||||
|
@ -74,12 +64,7 @@
|
|||
<SolidColorBrush x:Key="Brush.Contents" Color="{DynamicResource Color.Contents}"/>
|
||||
<SolidColorBrush x:Key="Brush.Badge" Color="{DynamicResource Color.Badge}"/>
|
||||
<SolidColorBrush x:Key="Brush.BadgeFG" Color="{DynamicResource Color.BadgeFG}"/>
|
||||
<SolidColorBrush x:Key="Brush.DecoratorIconBG" Color="{DynamicResource Color.DecoratorIconBG}"/>
|
||||
<SolidColorBrush x:Key="Brush.DecoratorIcon" Color="{DynamicResource Color.DecoratorIcon}"/>
|
||||
<SolidColorBrush x:Key="Brush.DecoratorBranch" Color="{DynamicResource Color.DecoratorBranch}"/>
|
||||
<SolidColorBrush x:Key="Brush.DecoratorHead" Color="{DynamicResource Color.DecoratorHead}"/>
|
||||
<SolidColorBrush x:Key="Brush.DecoratorTag" Color="{DynamicResource Color.DecoratorTag}"/>
|
||||
<SolidColorBrush x:Key="Brush.DecoratorFG" Color="{DynamicResource Color.DecoratorFG}"/>
|
||||
<SolidColorBrush x:Key="Brush.Conflict" Color="{DynamicResource Color.Conflict}"/>
|
||||
<SolidColorBrush x:Key="Brush.ConflictForeground" Color="{DynamicResource Color.ConflictForeground}"/>
|
||||
<SolidColorBrush x:Key="Brush.Border0" Color="{DynamicResource Color.Border0}"/>
|
||||
|
|
|
@ -12,6 +12,30 @@ namespace SourceGit.ViewModels
|
|||
private set;
|
||||
}
|
||||
|
||||
public bool IsMergeCommit
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public List<Models.Commit> ParentsForMergeCommit
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public int MainlineForMergeCommit
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool AppendSourceToMessage
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool AutoCommit
|
||||
{
|
||||
get;
|
||||
|
@ -22,6 +46,22 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
_repo = repo;
|
||||
Targets = targets;
|
||||
IsMergeCommit = false;
|
||||
ParentsForMergeCommit = [];
|
||||
MainlineForMergeCommit = 0;
|
||||
AppendSourceToMessage = true;
|
||||
AutoCommit = true;
|
||||
View = new Views.CherryPick() { DataContext = this };
|
||||
}
|
||||
|
||||
public CherryPick(Repository repo, Models.Commit merge, List<Models.Commit> parents)
|
||||
{
|
||||
_repo = repo;
|
||||
Targets = [merge];
|
||||
IsMergeCommit = true;
|
||||
ParentsForMergeCommit = parents;
|
||||
MainlineForMergeCommit = 0;
|
||||
AppendSourceToMessage = true;
|
||||
AutoCommit = true;
|
||||
View = new Views.CherryPick() { DataContext = this };
|
||||
}
|
||||
|
@ -33,12 +73,30 @@ namespace SourceGit.ViewModels
|
|||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
// Get commit SHAs reverted
|
||||
var builder = new StringBuilder();
|
||||
for (int i = Targets.Count - 1; i >= 0; i--)
|
||||
builder.Append($"{Targets[i].SHA} ");
|
||||
var succ = false;
|
||||
if (IsMergeCommit)
|
||||
{
|
||||
succ = new Commands.CherryPick(
|
||||
_repo.FullPath,
|
||||
Targets[0].SHA,
|
||||
!AutoCommit,
|
||||
AppendSourceToMessage,
|
||||
$"-m {MainlineForMergeCommit+1}").Exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
for (int i = Targets.Count - 1; i >= 0; i--)
|
||||
builder.Append($"{Targets[i].SHA} ");
|
||||
|
||||
succ = new Commands.CherryPick(
|
||||
_repo.FullPath,
|
||||
builder.ToString(),
|
||||
!AutoCommit,
|
||||
AppendSourceToMessage,
|
||||
string.Empty).Exec();
|
||||
}
|
||||
|
||||
var succ = new Commands.CherryPick(_repo.FullPath, builder.ToString(), !AutoCommit).Exec();
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
return succ;
|
||||
});
|
||||
|
|
|
@ -424,7 +424,28 @@ namespace SourceGit.ViewModels
|
|||
cherryPick.Click += (_, e) =>
|
||||
{
|
||||
if (PopupHost.CanCreatePopup())
|
||||
PopupHost.ShowPopup(new CherryPick(_repo, [commit]));
|
||||
{
|
||||
if (commit.Parents.Count <= 1)
|
||||
{
|
||||
PopupHost.ShowPopup(new CherryPick(_repo, [commit]));
|
||||
}
|
||||
else
|
||||
{
|
||||
var parents = new List<Models.Commit>();
|
||||
foreach (var sha in commit.Parents)
|
||||
{
|
||||
var parent = _commits.Find(x => x.SHA == sha);
|
||||
if (parent == null)
|
||||
parent = new Commands.QuerySingleCommit(_repo.FullPath, sha).Result();
|
||||
|
||||
if (parent != null)
|
||||
parents.Add(parent);
|
||||
}
|
||||
|
||||
PopupHost.ShowPopup(new CherryPick(_repo, commit, parents));
|
||||
}
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(cherryPick);
|
||||
|
|
|
@ -12,17 +12,11 @@
|
|||
<TextBlock FontSize="18"
|
||||
Classes="bold"
|
||||
Text="{DynamicResource Text.CherryPick}"/>
|
||||
<Grid Margin="0,16,0,0" ColumnDefinitions="100,*">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="32"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Margin="0,16,0,0" RowDefinitions="Auto,Auto,32,32" ColumnDefinitions="100,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Top"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.CherryPick.Commit}"/>
|
||||
|
||||
<ListBox Grid.Row="0" Grid.Column="1"
|
||||
MinHeight="32" MaxHeight="100"
|
||||
ItemsSource="{Binding Targets}"
|
||||
|
@ -58,9 +52,45 @@
|
|||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<CheckBox Grid.Row="1" Grid.Column="1"
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.CherryPick.Mainline}"
|
||||
IsVisible="{Binding IsMergeCommit}"/>
|
||||
<Grid Grid.Row="1" Grid.Column="1" Height="32" ColumnDefinitions="*,24" IsVisible="{Binding IsMergeCommit}">
|
||||
<ComboBox Grid.Column="0"
|
||||
Height="28" Padding="4,0"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Stretch"
|
||||
ItemsSource="{Binding ParentsForMergeCommit}"
|
||||
SelectedIndex="{Binding MainlineForMergeCommit, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="{x:Type m:Commit}">
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<TextBlock Grid.Column="0" FontFamily="{DynamicResource Fonts.Monospace}" VerticalAlignment="Center" Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" Foreground="DarkOrange" Margin="6,0,4,0"/>
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center" Text="{Binding Subject}" TextTrimming="CharacterEllipsis"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<Border Grid.Column="1"
|
||||
Background="Transparent"
|
||||
ToolTip.Tip="{DynamicResource Text.CherryPick.Mainline.Tips}">
|
||||
<Path Grid.Column="1"
|
||||
Width="14" Height="14"
|
||||
Data="{StaticResource Icons.Info}"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<CheckBox Grid.Row="2" Grid.Column="1"
|
||||
Content="{DynamicResource Text.CherryPick.CommitChanges}"
|
||||
IsChecked="{Binding AutoCommit, Mode=TwoWay}"/>
|
||||
|
||||
<CheckBox Grid.Row="3" Grid.Column="1"
|
||||
Content="{DynamicResource Text.CherryPick.AppendSourceToMessage}"
|
||||
IsChecked="{Binding AppendSourceToMessage, Mode=TwoWay}"
|
||||
IsEnabled="{Binding AutoCommit}"
|
||||
ToolTip.Tip="-x"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
|
|
@ -98,16 +98,11 @@
|
|||
<!-- REFS -->
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Refs}" IsVisible="{Binding HasDecorators}"/>
|
||||
<Border Grid.Row="2" Grid.Column="1" Margin="12,0,0,0" Height="24" IsVisible="{Binding HasDecorators}">
|
||||
<v:CommitRefsPresenter IconBackground="{DynamicResource Brush.DecoratorIconBG}"
|
||||
IconForeground="{DynamicResource Brush.DecoratorIcon}"
|
||||
BranchNameBackground="{DynamicResource Brush.DecoratorBranch}"
|
||||
HeadBranchNameBackground="{DynamicResource Brush.DecoratorHead}"
|
||||
TagNameBackground="{DynamicResource Brush.DecoratorTag}"
|
||||
LabelForeground="{DynamicResource Brush.DecoratorFG}"
|
||||
<v:CommitRefsPresenter TagBackground="{DynamicResource Brush.DecoratorTag}"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
FontFamily="{DynamicResource Fonts.Primary}"
|
||||
FontSize="11"
|
||||
VerticalAlignment="Center"
|
||||
Refs="{Binding Decorators}"/>
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<!-- Messages -->
|
||||
|
|
|
@ -14,16 +14,9 @@ namespace SourceGit.Views
|
|||
{
|
||||
public Geometry Icon { get; set; } = null;
|
||||
public FormattedText Label { get; set; } = null;
|
||||
public IBrush LabelBG { get; set; } = null;
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<List<Models.Decorator>> RefsProperty =
|
||||
AvaloniaProperty.Register<CommitRefsPresenter, List<Models.Decorator>>(nameof(Refs));
|
||||
|
||||
public List<Models.Decorator> Refs
|
||||
{
|
||||
get => GetValue(RefsProperty);
|
||||
set => SetValue(RefsProperty, value);
|
||||
public IBrush Brush { get; set; } = null;
|
||||
public bool IsHead { get; set; } = false;
|
||||
public double Width { get; set; } = 0.0;
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<FontFamily> FontFamilyProperty =
|
||||
|
@ -44,73 +37,32 @@ namespace SourceGit.Views
|
|||
set => SetValue(FontSizeProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> IconBackgroundProperty =
|
||||
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(IconBackground), Brushes.White);
|
||||
public static readonly StyledProperty<IBrush> ForegroundProperty =
|
||||
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(Foreground), Brushes.White);
|
||||
|
||||
public IBrush IconBackground
|
||||
public IBrush Foreground
|
||||
{
|
||||
get => GetValue(IconBackgroundProperty);
|
||||
set => SetValue(IconBackgroundProperty, value);
|
||||
get => GetValue(ForegroundProperty);
|
||||
set => SetValue(ForegroundProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> IconForegroundProperty =
|
||||
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(IconForeground), Brushes.White);
|
||||
public static readonly StyledProperty<IBrush> TagBackgroundProperty =
|
||||
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(TagBackground), Brushes.White);
|
||||
|
||||
public IBrush IconForeground
|
||||
public IBrush TagBackground
|
||||
{
|
||||
get => GetValue(IconForegroundProperty);
|
||||
set => SetValue(IconForegroundProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> LabelForegroundProperty =
|
||||
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(LabelForeground), Brushes.White);
|
||||
|
||||
public IBrush LabelForeground
|
||||
{
|
||||
get => GetValue(LabelForegroundProperty);
|
||||
set => SetValue(LabelForegroundProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> BranchNameBackgroundProperty =
|
||||
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(BranchNameBackground), Brushes.White);
|
||||
|
||||
public IBrush BranchNameBackground
|
||||
{
|
||||
get => GetValue(BranchNameBackgroundProperty);
|
||||
set => SetValue(BranchNameBackgroundProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> HeadBranchNameBackgroundProperty =
|
||||
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(HeadBranchNameBackground), Brushes.White);
|
||||
|
||||
public IBrush HeadBranchNameBackground
|
||||
{
|
||||
get => GetValue(HeadBranchNameBackgroundProperty);
|
||||
set => SetValue(HeadBranchNameBackgroundProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> TagNameBackgroundProperty =
|
||||
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(TagNameBackground), Brushes.White);
|
||||
|
||||
public IBrush TagNameBackground
|
||||
{
|
||||
get => GetValue(TagNameBackgroundProperty);
|
||||
set => SetValue(TagNameBackgroundProperty, value);
|
||||
get => GetValue(TagBackgroundProperty);
|
||||
set => SetValue(TagBackgroundProperty, value);
|
||||
}
|
||||
|
||||
static CommitRefsPresenter()
|
||||
{
|
||||
AffectsMeasure<CommitRefsPresenter>(
|
||||
FontFamilyProperty,
|
||||
FontSizeProperty,
|
||||
LabelForegroundProperty,
|
||||
RefsProperty);
|
||||
FontSizeProperty);
|
||||
|
||||
AffectsRender<CommitRefsPresenter>(
|
||||
IconBackgroundProperty,
|
||||
IconForegroundProperty,
|
||||
BranchNameBackgroundProperty,
|
||||
TagNameBackgroundProperty);
|
||||
TagBackgroundProperty);
|
||||
}
|
||||
|
||||
public override void Render(DrawingContext context)
|
||||
|
@ -118,39 +70,60 @@ namespace SourceGit.Views
|
|||
if (_items.Count == 0)
|
||||
return;
|
||||
|
||||
var iconFG = IconForeground;
|
||||
var iconBG = IconBackground;
|
||||
var x = 0.0;
|
||||
|
||||
var fg = Foreground;
|
||||
var x = 1.0;
|
||||
foreach (var item in _items)
|
||||
{
|
||||
var iconRect = new RoundedRect(new Rect(x, 0, 16, 16), new CornerRadius(2, 0, 0, 2));
|
||||
var labelRect = new RoundedRect(new Rect(x + 16, 0, item.Label.Width + 8, 16), new CornerRadius(0, 2, 2, 0));
|
||||
var entireRect = new RoundedRect(new Rect(x, 0, item.Width, 16), new CornerRadius(2));
|
||||
|
||||
context.DrawRectangle(iconBG, null, iconRect);
|
||||
context.DrawRectangle(item.LabelBG, null, labelRect);
|
||||
context.DrawText(item.Label, new Point(x + 20, 8.0 - item.Label.Height * 0.5));
|
||||
using (context.PushTransform(Matrix.CreateTranslation(x + 3, 3)))
|
||||
context.DrawGeometry(fg, null, item.Icon);
|
||||
|
||||
using (context.PushTransform(Matrix.CreateTranslation(x + 4, 4)))
|
||||
context.DrawGeometry(iconFG, null, item.Icon);
|
||||
if (item.IsHead)
|
||||
{
|
||||
using (context.PushOpacity(.4))
|
||||
context.DrawRectangle(item.Brush, null, entireRect);
|
||||
|
||||
x += item.Label.Width + 16 + 8 + 4;
|
||||
context.DrawText(item.Label, new Point(x + 16, 8.0 - item.Label.Height * 0.5));
|
||||
context.DrawRectangle(null, new Pen(item.Brush), entireRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
var labelRect = new RoundedRect(new Rect(x + 16, 0, item.Label.Width + 8, 16), new CornerRadius(0, 2, 2, 0));
|
||||
using (context.PushOpacity(.2))
|
||||
context.DrawRectangle(item.Brush, null, labelRect);
|
||||
|
||||
context.DrawLine(new Pen(item.Brush), new Point(x + 16, 0), new Point(x + 16, 16));
|
||||
context.DrawText(item.Label, new Point(x + 20, 8.0 - item.Label.Height * 0.5));
|
||||
context.DrawRectangle(null, new Pen(item.Brush), entireRect);
|
||||
}
|
||||
|
||||
x += item.Width + 4;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDataContextChanged(EventArgs e)
|
||||
{
|
||||
base.OnDataContextChanged(e);
|
||||
InvalidateMeasure();
|
||||
}
|
||||
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
_items.Clear();
|
||||
|
||||
var refs = Refs;
|
||||
var commit = DataContext as Models.Commit;
|
||||
if (commit == null)
|
||||
return new Size(0, 0);
|
||||
|
||||
var refs = commit.Decorators;
|
||||
if (refs != null && refs.Count > 0)
|
||||
{
|
||||
var typeface = new Typeface(FontFamily);
|
||||
var typefaceBold = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Bold);
|
||||
var labelFG = LabelForeground;
|
||||
var branchBG = BranchNameBackground;
|
||||
var headBG = HeadBranchNameBackground;
|
||||
var tagBG = TagNameBackground;
|
||||
var fg = Foreground;
|
||||
var tagBG = TagBackground;
|
||||
var labelSize = FontSize;
|
||||
var requiredWidth = 0.0;
|
||||
|
||||
|
@ -164,28 +137,25 @@ namespace SourceGit.Views
|
|||
CultureInfo.CurrentCulture,
|
||||
FlowDirection.LeftToRight,
|
||||
isHead ? typefaceBold : typeface,
|
||||
labelSize,
|
||||
labelFG);
|
||||
isHead ? labelSize + 1 : labelSize,
|
||||
fg);
|
||||
|
||||
var item = new RenderItem() { Label = label };
|
||||
var item = new RenderItem() { Label = label, Brush = commit.Brush, IsHead = isHead };
|
||||
StreamGeometry geo;
|
||||
switch (decorator.Type)
|
||||
{
|
||||
case Models.DecoratorType.CurrentBranchHead:
|
||||
case Models.DecoratorType.CurrentCommitHead:
|
||||
item.LabelBG = headBG;
|
||||
geo = this.FindResource("Icons.Check") as StreamGeometry;
|
||||
geo = this.FindResource("Icons.Head") as StreamGeometry;
|
||||
break;
|
||||
case Models.DecoratorType.RemoteBranchHead:
|
||||
item.LabelBG = branchBG;
|
||||
geo = this.FindResource("Icons.Remote") as StreamGeometry;
|
||||
break;
|
||||
case Models.DecoratorType.Tag:
|
||||
item.LabelBG = tagBG;
|
||||
item.Brush = tagBG;
|
||||
geo = this.FindResource("Icons.Tag") as StreamGeometry;
|
||||
break;
|
||||
default:
|
||||
item.LabelBG = branchBG;
|
||||
geo = this.FindResource("Icons.Branch") as StreamGeometry;
|
||||
break;
|
||||
}
|
||||
|
@ -193,7 +163,7 @@ namespace SourceGit.Views
|
|||
var drawGeo = geo!.Clone();
|
||||
var iconBounds = drawGeo.Bounds;
|
||||
var translation = Matrix.CreateTranslation(-(Vector)iconBounds.Position);
|
||||
var scale = Math.Min(8.0 / iconBounds.Width, 8.0 / iconBounds.Height);
|
||||
var scale = Math.Min(10.0 / iconBounds.Width, 10.0 / iconBounds.Height);
|
||||
var transform = translation * Matrix.CreateScale(scale, scale);
|
||||
if (drawGeo.Transform == null || drawGeo.Transform.Value == Matrix.Identity)
|
||||
drawGeo.Transform = new MatrixTransform(transform);
|
||||
|
@ -201,12 +171,14 @@ namespace SourceGit.Views
|
|||
drawGeo.Transform = new MatrixTransform(drawGeo.Transform.Value * transform);
|
||||
|
||||
item.Icon = drawGeo;
|
||||
item.Width = 16 + (isHead ? 0 : 4) + label.Width + 4;
|
||||
_items.Add(item);
|
||||
requiredWidth += label.Width + 16 /* icon */ + 8 /* label margin */ + 4 /* item right margin */;
|
||||
|
||||
requiredWidth += item.Width + 4;
|
||||
}
|
||||
|
||||
InvalidateVisual();
|
||||
return new Size(requiredWidth, 16);
|
||||
return new Size(requiredWidth + 2, 16);
|
||||
}
|
||||
|
||||
InvalidateVisual();
|
||||
|
|
|
@ -138,16 +138,11 @@
|
|||
VerticalAlignment="Center"/>
|
||||
|
||||
<v:CommitRefsPresenter Grid.Column="1"
|
||||
IconBackground="{DynamicResource Brush.DecoratorIconBG}"
|
||||
IconForeground="{DynamicResource Brush.DecoratorIcon}"
|
||||
BranchNameBackground="{DynamicResource Brush.DecoratorBranch}"
|
||||
HeadBranchNameBackground="{DynamicResource Brush.DecoratorHead}"
|
||||
TagNameBackground="{DynamicResource Brush.DecoratorTag}"
|
||||
LabelForeground="{DynamicResource Brush.DecoratorFG}"
|
||||
TagBackground="{DynamicResource Brush.DecoratorTag}"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
FontFamily="{DynamicResource Fonts.Primary}"
|
||||
FontSize="11"
|
||||
VerticalAlignment="Center"
|
||||
Refs="{Binding Decorators}"/>
|
||||
VerticalAlignment="Center"/>
|
||||
|
||||
<v:CommitSubjectPresenter Grid.Column="2"
|
||||
Classes="primary"
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="12" Height="12" Data="{StaticResource Icons.Pull}"/>
|
||||
<Path Width="12" Height="12" Data="{StaticResource Icons.Pull}" Fill="White"/>
|
||||
<TextBlock Text="{DynamicResource Text.SelfUpdate.GotoDownload}" Margin="8,0,0,0"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
|
Loading…
Reference in a new issue