From d2a005c53249843c66e85f03645dded4ffb829af Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 30 Sep 2024 11:34:09 +0800 Subject: [PATCH 01/18] feature: add a button in diff view to ignore all whitespace changes (--ignore-all-space) --- src/Commands/Diff.cs | 8 ++++++-- src/Resources/Icons.axaml | 3 ++- src/Resources/Locales/de_DE.axaml | 4 ++-- src/Resources/Locales/en_US.axaml | 5 +++-- src/Resources/Locales/pt_BR.axaml | 4 ++-- src/Resources/Locales/ru_RU.axaml | 4 ++-- src/Resources/Locales/zh_CN.axaml | 5 +++-- src/Resources/Locales/zh_TW.axaml | 5 +++-- src/ViewModels/DiffContext.cs | 14 +++++++++++++- src/Views/DiffView.axaml | 9 ++++++++- 10 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 0f2ee626..e3185781 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -12,7 +12,7 @@ namespace SourceGit.Commands private const string PREFIX_LFS_DEL = "-version https://git-lfs.github.com/spec/"; private const string PREFIX_LFS_MODIFY = " version https://git-lfs.github.com/spec/"; - public Diff(string repo, Models.DiffOption opt, int unified) + public Diff(string repo, Models.DiffOption opt, int unified, bool ignoreWhitespace) { _result.TextDiff = new Models.TextDiff() { @@ -22,7 +22,11 @@ namespace SourceGit.Commands WorkingDirectory = repo; Context = repo; - Args = $"diff --ignore-cr-at-eol --unified={unified} {opt}"; + + if (ignoreWhitespace) + Args = $"diff --ignore-cr-at-eol --ignore-all-space --unified={unified} {opt}"; + else + Args = $"diff --ignore-cr-at-eol --unified={unified} {opt}"; } public Models.DiffResult Result() diff --git a/src/Resources/Icons.axaml b/src/Resources/Icons.axaml index 8650e068..fab32275 100644 --- a/src/Resources/Icons.axaml +++ b/src/Resources/Icons.axaml @@ -50,6 +50,7 @@ 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 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 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 + M416 64H768v64h-64v704h64v64H448v-64h64V512H416a224 224 0 1 1 0-448zM576 832h64V128H576v704zM416 128H512v320H416a160 160 0 0 1 0-320z M24 512A488 488 0 01512 24A488 488 0 011000 512A488 488 0 01512 1000A488 488 0 0124 512zm447-325v327L243 619l51 111 300-138V187H471z 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 M512 0C229 0 0 229 0 512c0 283 229 512 512 512s512-229 512-512c0-283-229-512-512-512zm0 958C266 958 66 758 66 512S266 66 512 66 958 266 958 512 758 958 512 958zM192 416h96a32 32 0 0032-32v-32a32 32 0 00-32-32H192a32 32 0 00-32 32v32a32 32 0 0032 32zM384 416h96a32 32 0 0032-32v-32a32 32 0 00-32-32h-96a32 32 0 00-32 32v32a32 32 0 0032 32zM576 416h96a32 32 0 0032-32v-32a32 32 0 00-32-32h-96a32 32 0 00-32 32v32a32 32 0 0032 32zM832 320h-64a32 32 0 00-32 32v128h-160a32 32 0 00-32 32v32a32 32 0 0032 32h256a32 32 0 0032-32v-192a32 32 0 00-32-32zM320 544v-32a32 32 0 00-32-32H192a32 32 0 00-32 32v32a32 32 0 0032 32h96a32 32 0 0032-32zM384 576h96a32 32 0 0032-32v-32a32 32 0 00-32-32h-96a32 32 0 00-32 32v32a32 32 0 0032 32zM800 640H256a32 32 0 00-32 32v32a32 32 0 0032 32h544a32 32 0 0032-32v-32a32 32 0 00-32-32z @@ -118,7 +119,7 @@ M832 464H332V240c0-31 25-56 56-56h248c31 0 56 25 56 56v68c0 4 4 8 8 8h56c4 0 8-4 8-8v-68c0-71-57-128-128-128H388c-71 0-128 57-128 128v224h-68c-18 0-32 14-32 32v384c0 18 14 32 32 32h640c18 0 32-14 32-32V496c0-18-14-32-32-32zM540 701v53c0 4-4 8-8 8h-40c-4 0-8-4-8-8v-53c-12-9-20-23-20-39 0-27 22-48 48-48s48 22 48 48c0 16-8 30-20 39z M170 831l343-342L855 831l105-105-448-448L64 726 170 831z M812 864h-29V654c0-21-11-40-28-52l-133-88 134-89c18-12 28-31 28-52V164h28c18 0 32-14 32-32s-14-32-32-32H212c-18 0-32 14-32 32s14 32 32 32h30v210c0 21 11 40 28 52l133 88-134 89c-18 12-28 31-28 52V864H212c-18 0-32 14-32 32s14 32 32 32h600c18 0 32-14 32-32s-14-32-32-32zM441 566c18-12 28-31 28-52s-11-40-28-52L306 373V164h414v209l-136 90c-18 12-28 31-28 52 0 21 11 40 28 52l135 89V695c-9-7-20-13-32-19-30-15-93-41-176-41-63 0-125 14-175 38-12 6-22 12-31 18v-36l136-90z - M416 64H768v64h-64v704h64v64H448v-64h64V512H416a224 224 0 1 1 0-448zM576 832h64V128H576v704zM416 128H512v320H416a160 160 0 0 1 0-320z + M0 512M1024 512M512 0M512 1024M762 412v100h-500v-100h-150v200h800v-200h-150z M519 459 222 162a37 37 0 10-52 52l297 297L169 809a37 37 0 1052 52l297-297 297 297a37 37 0 1052-52l-297-297 297-297a37 37 0 10-52-52L519 459z M1024 565V459H0V565H1024ZM512 0M512 1024 M153 154h768v768h-768v-768zm64 64v640h640v-640h-640z diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index eac15bca..95c3f07f 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -210,17 +210,17 @@ Nächste Änderung KEINE ÄNDERUNG ODER NUR ZEILEN-ENDE ÄNDERUNGEN Vorherige Änderung + Zeige versteckte Symbole Nebeneinander SUBMODUL NEU + Seiten wechseln Syntax Hervorhebung Zeilenumbruch Öffne in Merge Tool Weniger Zeilen anzeigen Mehr Zeilen anzeigen WÄHLE EINE DATEI AUS UM ÄNDERUNGEN ANZUZEIGEN - Zeige versteckte Symbole - Seiten wechseln Öffne in Merge Tool Änderungen verwerfen Alle Änderungen in der Arbeitskopie. diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index ca320f4d..434b3b1a 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -203,21 +203,22 @@ OLD Copy File Mode Changed + Ignore Whitespace Change LFS OBJECT CHANGE Next Difference NO CHANGES OR ONLY EOL CHANGES Previous Difference + Show hidden symbols Side-By-Side Diff SUBMODULE NEW + Swap Syntax Highlighting Line Word Wrap Open in Merge Tool Decrease Number of Visible Lines Increase Number of Visible Lines SELECT FILE TO VIEW CHANGES - Show hidden symbols - Swap Open in Merge Tool Discard Changes All local changes in working copy. diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index 90341b44..b0505014 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -199,17 +199,17 @@ Próxima Diferença SEM MUDANÇAS OU APENAS MUDANÇAS DE EOL Diferença Anterior + Mostrar símbolos ocultos Diferença Lado a Lado SUBMÓDULO NOVO + Trocar Realce de Sintaxe Quebra de Linha Abrir na Ferramenta de Mesclagem Diminuir Número de Linhas Visíveis Aumentar Número de Linhas Visíveis SELECIONE O ARQUIVO PARA VISUALIZAR AS MUDANÇAS - Mostrar símbolos ocultos - Trocar Abrir na Ferramenta de Mesclagem Descartar Alterações Todas as alterações locais na cópia de trabalho. diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index edfc8b08..948905eb 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -206,6 +206,7 @@ СТАРЫЙ Копировать Режим файла изменён + Показать скрытые символы ИЗМЕНЕНИЕ ОБЪЕКТА ХБФ Следующее различие НИКАКИХ ИЗМЕНЕНИЙ ИЛИ МЕНЯЕТСЯ ТОЛЬКО EOL @@ -213,14 +214,13 @@ Различие бок о бок ПОДМОДУЛЬ НОВЫЙ + Обмен Подсветка синтаксиса Перенос слов в строке Открыть в инструменте слияния Уменьшить количество видимых линий Увеличить количество видимых линий ВЫБРАТЬ ФАЙЛ ДЛЯ ПРОСМОТРА ИЗМЕНЕНИЙ - Показать скрытые символы - Обмен Открыть в инструменте слияния Отклонить изменения Все локальные изменения в рабочей копии. diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 5b753a08..f26d3e3c 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -206,21 +206,22 @@ 原始大小 复制 文件权限已变化 + 忽略空白符号变化 LFS对象变更 下一个差异 没有变更或仅有换行符差异 上一个差异 + 显示隐藏符号 分列对比 子模块 新增 + 交换比对双方 语法高亮 自动换行 使用外部合并工具查看 减少可见的行数 增加可见的行数 请选择需要对比的文件 - 显示隐藏符号 - 交换比对双方 使用外部比对工具查看 放弃更改确认 所有本地址未提交的修改。 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 733b3f39..ffc46895 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -206,21 +206,22 @@ 原始大小 複製 檔案權限已變更 + 忽略空白符號變化 LFS 物件變更 下一個差異 沒有變更或僅有換行字元差異 上一個差異 + 顯示隱藏符號 並排對比 子模組 新增 + 交換比對雙方 語法上色 自動換行 使用外部合併工具檢視 減少可見的行數 增加可見的行數 請選擇需要對比的檔案 - 顯示隱藏符號 - 交換比對雙方 使用外部比對工具檢視 捨棄變更 所有本機未提交的變更。 diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index 08499d89..1a48c8e0 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -17,6 +17,16 @@ namespace SourceGit.ViewModels get => _title; } + public bool IgnoreWhitespace + { + get => _ignoreWhitespace; + set + { + if (SetProperty(ref _ignoreWhitespace, value)) + LoadDiffContent(); + } + } + public string FileModeChange { get => _fileModeChange; @@ -57,6 +67,7 @@ namespace SourceGit.ViewModels _isTextDiff = previous._isTextDiff; _content = previous._content; _unifiedLines = previous._unifiedLines; + _ignoreWhitespace = previous._ignoreWhitespace; } if (string.IsNullOrEmpty(_option.OrgPath) || _option.OrgPath == "/dev/null") @@ -98,7 +109,7 @@ namespace SourceGit.ViewModels Task.Run(() => { - var latest = new Commands.Diff(_repo, _option, _unifiedLines).Result(); + var latest = new Commands.Diff(_repo, _option, _unifiedLines, _ignoreWhitespace).Result(); var rs = null as object; if (latest.TextDiff != null) @@ -237,6 +248,7 @@ namespace SourceGit.ViewModels private int _unifiedLines = 4; private bool _isLoading = true; private bool _isTextDiff = false; + private bool _ignoreWhitespace = false; private object _content = null; } } diff --git a/src/Views/DiffView.axaml b/src/Views/DiffView.axaml index 07ed7a77..8ccc25bb 100644 --- a/src/Views/DiffView.axaml +++ b/src/Views/DiffView.axaml @@ -77,12 +77,19 @@ + + + + - + Date: Tue, 1 Oct 2024 08:55:43 +0800 Subject: [PATCH 02/18] ux: add icons for group --- src/Views/Preference.axaml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Views/Preference.axaml b/src/Views/Preference.axaml index 61b1a4ca..88d335e3 100644 --- a/src/Views/Preference.axaml +++ b/src/Views/Preference.axaml @@ -353,7 +353,10 @@ - + + + + @@ -399,7 +402,10 @@ - + + + + @@ -449,7 +455,10 @@ - + + + + From d3991c653591a33c2b40d374b9337788419feff8 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 1 Oct 2024 20:44:14 +0800 Subject: [PATCH 03/18] fix: use `--no-ff --no-commit` for `Don't Commit` option in merge popup to ensure branch is not changed or updated with fast-forward commits (#532) --- src/Models/MergeMode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/MergeMode.cs b/src/Models/MergeMode.cs index 23ace5c5..15e3f7e9 100644 --- a/src/Models/MergeMode.cs +++ b/src/Models/MergeMode.cs @@ -7,7 +7,7 @@ new MergeMode("Default", "Fast-forward if possible", ""), new MergeMode("No Fast-forward", "Always create a merge commit", "--no-ff"), new MergeMode("Squash", "Use '--squash'", "--squash"), - new MergeMode("Don't commit", "Merge without commit", "--no-commit"), + new MergeMode("Don't commit", "Merge without commit", "--no-ff --no-commit"), ]; public string Name { get; set; } From 2d24244ee2af51507c10e5ce9b2248990a9f0981 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 1 Oct 2024 21:01:56 +0800 Subject: [PATCH 04/18] enhance: auto-update submodules if possible after checking out a branch (#531) * add `--recurse-submodules` to checkout branch command * remove unused method `Commands.Checkout.Files` * code style --- src/Commands/Checkout.cs | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/Commands/Checkout.cs b/src/Commands/Checkout.cs index 25f93e89..306d62ff 100644 --- a/src/Commands/Checkout.cs +++ b/src/Commands/Checkout.cs @@ -14,7 +14,7 @@ namespace SourceGit.Commands public bool Branch(string branch, Action onProgress) { - Args = $"checkout --progress {branch}"; + Args = $"checkout --recurse-submodules --progress {branch}"; TraitErrorAsOutput = true; _outputHandler = onProgress; return Exec(); @@ -22,7 +22,7 @@ namespace SourceGit.Commands public bool Branch(string branch, string basedOn, Action onProgress) { - Args = $"checkout --progress -b {branch} {basedOn}"; + Args = $"checkout --recurse-submodules --progress -b {branch} {basedOn}"; TraitErrorAsOutput = true; _outputHandler = onProgress; return Exec(); @@ -30,7 +30,7 @@ namespace SourceGit.Commands public bool UseTheirs(List files) { - StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); builder.Append("checkout --theirs --"); foreach (var f in files) { @@ -44,7 +44,7 @@ namespace SourceGit.Commands public bool UseMine(List files) { - StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); builder.Append("checkout --ours --"); foreach (var f in files) { @@ -70,20 +70,6 @@ namespace SourceGit.Commands return Exec(); } - public bool Files(List files) - { - StringBuilder builder = new StringBuilder(); - builder.Append("checkout -f -q --"); - foreach (var f in files) - { - builder.Append(" \""); - builder.Append(f); - builder.Append("\""); - } - Args = builder.ToString(); - return Exec(); - } - protected override void OnReadline(string line) { _outputHandler?.Invoke(line); From 6d1dfad8a1dc98dc19e73a4321e2cc536e8121ef Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 1 Oct 2024 23:16:25 +0800 Subject: [PATCH 05/18] ux: changes view mode style (#533) * move changes view mode switch button to right button group * change the style for ChangeViewModeSwitcher * remove used code --- src/Converters/ChangeViewModeConverters.cs | 24 ---------------------- src/Resources/Icons.axaml | 2 +- src/Resources/Styles.axaml | 6 ------ src/ViewModels/Welcome.cs | 2 +- src/Views/ChangeViewModeSwitcher.axaml | 17 +++++++++++---- src/Views/CommitChanges.axaml | 6 +++--- src/Views/StashesPage.axaml | 4 ++-- src/Views/WorkingCopy.axaml | 20 ++++++++++++------ 8 files changed, 34 insertions(+), 47 deletions(-) delete mode 100644 src/Converters/ChangeViewModeConverters.cs diff --git a/src/Converters/ChangeViewModeConverters.cs b/src/Converters/ChangeViewModeConverters.cs deleted file mode 100644 index 59a5652c..00000000 --- a/src/Converters/ChangeViewModeConverters.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Avalonia; -using Avalonia.Controls; -using Avalonia.Data.Converters; -using Avalonia.Media; - -namespace SourceGit.Converters -{ - public static class ChangeViewModeConverters - { - public static readonly FuncValueConverter ToIcon = - new FuncValueConverter(v => - { - switch (v) - { - case Models.ChangeViewMode.List: - return Application.Current?.FindResource("Icons.List") as StreamGeometry; - case Models.ChangeViewMode.Grid: - return Application.Current?.FindResource("Icons.Grid") as StreamGeometry; - default: - return Application.Current?.FindResource("Icons.Tree") as StreamGeometry; - } - }); - } -} diff --git a/src/Resources/Icons.axaml b/src/Resources/Icons.axaml index fab32275..737b7fef 100644 --- a/src/Resources/Icons.axaml +++ b/src/Resources/Icons.axaml @@ -76,7 +76,7 @@ M824 645V307c0-56-46-102-102-102h-102V102l-154 154 154 154V307h102v338c-46 20-82 67-82 123 0 72 61 133 133 133 72 0 133-61 133-133 0-56-36-102-82-123zm-51 195c-41 0-72-31-72-72s31-72 72-72c41 0 72 31 72 72s-31 72-72 72zM384 256c0-72-61-133-133-133-72 0-133 61-133 133 0 56 36 102 82 123v266C154 666 118 712 118 768c0 72 61 133 133 133 72 0 133-61 133-133 0-56-36-102-82-123V379C348 358 384 312 384 256zM323 768c0 41-31 72-72 72-41 0-72-31-72-72s31-72 72-72c41 0 72 31 72 72zM251 328c-41 0-72-31-72-72s31-72 72-72c41 0 72 31 72 72s-31 72-72 72z M896 64H128C96 64 64 96 64 128v768c0 32 32 64 64 64h768c32 0 64-32 64-64V128c0-32-32-64-64-64z m-64 736c0 16-17 32-32 32H224c-18 0-32-12-32-32V224c0-16 16-32 32-32h576c15 0 32 16 32 32v576zM512 384c-71 0-128 57-128 128s57 128 128 128 128-57 128-128-57-128-128-128z M299 811 299 725 384 725 384 811 299 811M469 811 469 725 555 725 555 811 469 811M640 811 640 725 725 725 725 811 640 811M299 640 299 555 384 555 384 640 299 640M469 640 469 555 555 555 555 640 469 640M640 640 640 555 725 555 725 640 640 640M299 469 299 384 384 384 384 469 299 469M469 469 469 384 555 384 555 469 469 469M640 469 640 384 725 384 725 469 640 469M299 299 299 213 384 213 384 299 299 299M469 299 469 213 555 213 555 299 469 299M640 299 640 213 725 213 725 299 640 299Z - M64 363l0 204 265 0L329 460c0-11 6-18 14-20C349 437 355 437 362 441c93 60 226 149 226 149 33 22 34 60 0 82 0 0-133 89-226 149-14 9-32-3-32-18l-1-110L64 693l0 117c0 41 34 75 75 75l746 0c41 0 75-34 75-74L960 364c0-0 0-1 0-1L64 363zM64 214l0 75 650 0-33-80c-16-38-62-69-103-69l-440 0C97 139 64 173 64 214z + M64 363l0 204 265 0L329 460c0-11 6-18 14-20C349 437 355 437 362 441c93 60 226 149 226 149 33 22 34 60 0 82 0 0-133 89-226 149-14 9-32-3-32-18l-1-110L64 693l0 117c0 41 34 75 75 75l746 0c41 0 75-34 75-74L960 364c0-0 0-1 0-1L64 363zM64 214l0 75 650 0-33-80c-16-38-62-69-103-69l-440 0C97 139 64 173 64 214z M683 409v204L1024 308 683 0v191c-413 0-427 526-427 526c117-229 203-307 427-307zm85 492H102V327h153s38-63 114-122H51c-28 0-51 27-51 61v697c0 34 23 61 51 61h768c28 0 51-27 51-61V614l-102 100v187z M640 96c-158 0-288 130-288 288 0 17 3 31 5 46L105 681 96 691V928h224v-96h96v-96h96v-95c38 18 82 31 128 31 158 0 288-130 288-288s-130-288-288-288zm0 64c123 0 224 101 224 224s-101 224-224 224a235 235 0 01-109-28l-8-4H448v96h-96v96H256v96H160v-146l253-254 12-11-3-17C419 417 416 400 416 384c0-123 101-224 224-224zm64 96a64 64 0 100 128 64 64 0 100-128z M544 85c49 0 90 37 95 85h75a96 96 0 0196 89L811 267a32 32 0 01-28 32L779 299a32 32 0 01-32-28L747 267a32 32 0 00-28-32L715 235h-91a96 96 0 01-80 42H395c-33 0-62-17-80-42L224 235a32 32 0 00-32 28L192 267v576c0 16 12 30 28 32l4 0h128a32 32 0 0132 28l0 4a32 32 0 01-32 32h-128a96 96 0 01-96-89L128 843V267a96 96 0 0189-96L224 171h75a96 96 0 0195-85h150zm256 256a96 96 0 0196 89l0 7v405a96 96 0 01-89 96L800 939h-277a96 96 0 01-96-89L427 843v-405a96 96 0 0189-96L523 341h277zm-256-192H395a32 32 0 000 64h150a32 32 0 100-64z diff --git a/src/Resources/Styles.axaml b/src/Resources/Styles.axaml index f0743baf..50f4d830 100644 --- a/src/Resources/Styles.axaml +++ b/src/Resources/Styles.axaml @@ -265,12 +265,6 @@ - - diff --git a/src/ViewModels/Welcome.cs b/src/ViewModels/Welcome.cs index f9761e02..04ffef87 100644 --- a/src/ViewModels/Welcome.cs +++ b/src/ViewModels/Welcome.cs @@ -221,7 +221,7 @@ namespace SourceGit.ViewModels var move = new MenuItem(); move.Header = App.Text("Welcome.Move"); - move.Icon = App.CreateMenuIcon("Icons.MoveToAnthorGroup"); + move.Icon = App.CreateMenuIcon("Icons.MoveToAnotherGroup"); move.Click += (_, e) => { if (PopupHost.CanCreatePopup()) diff --git a/src/Views/ChangeViewModeSwitcher.axaml b/src/Views/ChangeViewModeSwitcher.axaml index 3e1cbfed..4ded60c7 100644 --- a/src/Views/ChangeViewModeSwitcher.axaml +++ b/src/Views/ChangeViewModeSwitcher.axaml @@ -4,11 +4,10 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="using:SourceGit.Models" xmlns:v="using:SourceGit.Views" - xmlns:c="using:SourceGit.Converters" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="SourceGit.Views.ChangeViewModeSwitcher" x:DataType="v:ChangeViewModeSwitcher"> - diff --git a/src/Views/CommitChanges.axaml b/src/Views/CommitChanges.axaml index 41e0e29d..1c7b34bd 100644 --- a/src/Views/CommitChanges.axaml +++ b/src/Views/CommitChanges.axaml @@ -16,7 +16,7 @@ - + diff --git a/src/Views/StashesPage.axaml b/src/Views/StashesPage.axaml index d0d257c1..5bdb75f2 100644 --- a/src/Views/StashesPage.axaml +++ b/src/Views/StashesPage.axaml @@ -21,7 +21,7 @@ - + + @@ -78,9 +82,9 @@ - - - + + + + From d746e352a7911d791dcf727d917ae00d7b3bf8bd Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 2 Oct 2024 15:13:27 +0800 Subject: [PATCH 06/18] feature: supports to set default remote to push local branches without any tracking remotes (#534) --- src/Models/RepositorySettings.cs | 6 +++++ src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/Resources/Locales/zh_TW.axaml | 1 + src/ViewModels/Push.cs | 10 ++++++-- src/ViewModels/RepositoryConfigure.cs | 22 +++++++++++++++++ src/Views/RepositoryConfigure.axaml | 35 +++++++++++++++++++++------ 7 files changed, 66 insertions(+), 10 deletions(-) diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs index 244fc673..4fb96efa 100644 --- a/src/Models/RepositorySettings.cs +++ b/src/Models/RepositorySettings.cs @@ -4,6 +4,12 @@ namespace SourceGit.Models { public class RepositorySettings { + public string DefaultRemote + { + get; + set; + } = string.Empty; + public DealWithLocalChanges DealWithLocalChangesOnCheckoutBranch { get; diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 434b3b1a..8f6fac9f 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -138,6 +138,7 @@ GIT Fetch remotes automatically Minute(s) + Default Remote ISSUE TRACKER Add Sample Github Rule Add Sample Jira Rule diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index f26d3e3c..bb39f0f3 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -141,6 +141,7 @@ GIT配置 启用定时自动拉取远程更新 分钟 + 默认远程 ISSUE追踪 新增匹配Github Issue规则 新增匹配Jira规则 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index ffc46895..ad8f7746 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -141,6 +141,7 @@ Git 設定 啟用定時自動提取 (fetch) 遠端更新 分鐘 + 預設遠端存放庫 Issue 追蹤 新增符合 GitHub Issue 規則 新增符合 Jira 規則 diff --git a/src/ViewModels/Push.cs b/src/ViewModels/Push.cs index b3ef694b..acbb1b1d 100644 --- a/src/ViewModels/Push.cs +++ b/src/ViewModels/Push.cs @@ -137,9 +137,15 @@ namespace SourceGit.ViewModels } } - // Set default remote to the first if haven't been set. + // Set default remote to the first if it has not been set. if (_selectedRemote == null) - _selectedRemote = repo.Remotes[0]; + { + var remote = null as Models.Remote; + if (!string.IsNullOrEmpty(_repo.Settings.DefaultRemote)) + remote = repo.Remotes.Find(x => x.Name == _repo.Settings.DefaultRemote); + + _selectedRemote = remote ?? repo.Remotes[0]; + } // Auto select preferred remote branch. AutoSelectBranchByRemote(); diff --git a/src/ViewModels/RepositoryConfigure.cs b/src/ViewModels/RepositoryConfigure.cs index fe5b1a2f..1f490316 100644 --- a/src/ViewModels/RepositoryConfigure.cs +++ b/src/ViewModels/RepositoryConfigure.cs @@ -18,6 +18,24 @@ namespace SourceGit.ViewModels set; } + public List Remotes + { + get; + } + + public string DefaultRemote + { + get => _repo.Settings.DefaultRemote; + set + { + if (_repo.Settings.DefaultRemote != value) + { + _repo.Settings.DefaultRemote = value; + OnPropertyChanged(); + } + } + } + public bool GPGCommitSigningEnabled { get; @@ -88,6 +106,10 @@ namespace SourceGit.ViewModels { _repo = repo; + Remotes = new List(); + foreach (var remote in _repo.Remotes) + Remotes.Add(remote.Name); + _cached = new Commands.Config(repo.FullPath).ListAll(); if (_cached.TryGetValue("user.name", out var name)) UserName = name; diff --git a/src/Views/RepositoryConfigure.axaml b/src/Views/RepositoryConfigure.axaml index 8d03c0bb..df2ad414 100644 --- a/src/Views/RepositoryConfigure.axaml +++ b/src/Views/RepositoryConfigure.axaml @@ -51,7 +51,7 @@ - + - + + + + + + + + + + + + + - - - - - - + From a59600ce18bd9e8c620beb7be51543d86f6cb640 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 2 Oct 2024 15:27:09 +0800 Subject: [PATCH 07/18] enhance: supports default remote in `Pull` if current branch has no upstream (#534) --- src/ViewModels/Pull.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index 49c3cb19..03a72753 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -95,7 +95,18 @@ namespace SourceGit.ViewModels } } - _selectedRemote = autoSelectedRemote ?? repo.Remotes[0]; + if (autoSelectedRemote == null) + { + var remote = null as Models.Remote; + if (!string.IsNullOrEmpty(_repo.Settings.DefaultRemote)) + remote = _repo.Remotes.Find(x => x.Name == _repo.Settings.DefaultRemote); + _selectedRemote = remote ?? _repo.Remotes[0]; + } + else + { + _selectedRemote = autoSelectedRemote; + } + PostRemoteSelected(); HasSpecifiedRemoteBranch = false; } @@ -132,7 +143,7 @@ namespace SourceGit.ViewModels } } - var rs = false; + bool rs; if (FetchAllBranches) { SetProgressDescription($"Fetching remote: {_selectedRemote.Name}..."); From 4e57cd50cd53c773f5d1261eed88482381a45bee Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 2 Oct 2024 21:17:44 +0800 Subject: [PATCH 08/18] feature: add an option to clean up ignored files when discard all changes in repo (#531) --- src/Commands/Clean.cs | 6 +-- src/Commands/Discard.cs | 4 +- src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/Resources/Locales/zh_TW.axaml | 1 + src/ViewModels/Checkout.cs | 3 +- src/ViewModels/CheckoutCommit.cs | 3 +- src/ViewModels/CreateBranch.cs | 3 +- src/ViewModels/Discard.cs | 40 ++++++++++++--- src/ViewModels/Pull.cs | 2 +- src/ViewModels/Repository.cs | 1 - src/Views/Discard.axaml | 85 +++++++++++++++++++++---------- 12 files changed, 104 insertions(+), 46 deletions(-) diff --git a/src/Commands/Clean.cs b/src/Commands/Clean.cs index 900a7f93..a10e5873 100644 --- a/src/Commands/Clean.cs +++ b/src/Commands/Clean.cs @@ -5,16 +5,16 @@ namespace SourceGit.Commands { public class Clean : Command { - public Clean(string repo) + public Clean(string repo, bool includeIgnored) { WorkingDirectory = repo; Context = repo; - Args = "clean -qfd"; + Args = includeIgnored ? "clean -qfdx" : "clean -qfd"; } public Clean(string repo, List files) { - StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); builder.Append("clean -qfd --"); foreach (var f in files) { diff --git a/src/Commands/Discard.cs b/src/Commands/Discard.cs index 63fcaa8e..a279bb84 100644 --- a/src/Commands/Discard.cs +++ b/src/Commands/Discard.cs @@ -5,10 +5,10 @@ namespace SourceGit.Commands { public static class Discard { - public static void All(string repo) + public static void All(string repo, bool includeIgnored) { new Restore(repo).Exec(); - new Clean(repo).Exec(); + new Clean(repo, includeIgnored).Exec(); } public static void Changes(string repo, List changes) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 8f6fac9f..b4f52b55 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -224,6 +224,7 @@ Discard Changes All local changes in working copy. Changes: + Include ignored files Total {0} changes will be discard You can't undo this action!!! Bookmark: diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index bb39f0f3..57712fa5 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -227,6 +227,7 @@ 放弃更改确认 所有本地址未提交的修改。 变更 : + 包括所有已忽略的文件 总计{0}项选中更改 本操作不支持回退,请确认后继续!!! 书签 : diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index ad8f7746..7abfb36a 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -227,6 +227,7 @@ 捨棄變更 所有本機未提交的變更。 變更: + 包括所有已忽略的檔案 將捨棄總計 {0} 項已選取的變更 您無法復原此操作,請確認後再繼續! 書籤: diff --git a/src/ViewModels/Checkout.cs b/src/ViewModels/Checkout.cs index 5661e2ed..26858b4f 100644 --- a/src/ViewModels/Checkout.cs +++ b/src/ViewModels/Checkout.cs @@ -7,7 +7,6 @@ namespace SourceGit.ViewModels public string Branch { get; - private set; } public Models.DealWithLocalChanges PreAction @@ -49,7 +48,7 @@ namespace SourceGit.ViewModels else if (PreAction == Models.DealWithLocalChanges.Discard) { SetProgressDescription("Discard local changes ..."); - Commands.Discard.All(_repo.FullPath); + Commands.Discard.All(_repo.FullPath, false); } } diff --git a/src/ViewModels/CheckoutCommit.cs b/src/ViewModels/CheckoutCommit.cs index 54cdbccd..ddc0a0c6 100644 --- a/src/ViewModels/CheckoutCommit.cs +++ b/src/ViewModels/CheckoutCommit.cs @@ -7,7 +7,6 @@ namespace SourceGit.ViewModels public Models.Commit Commit { get; - private set; } public bool AutoStash @@ -49,7 +48,7 @@ namespace SourceGit.ViewModels else { SetProgressDescription("Discard local changes ..."); - Commands.Discard.All(_repo.FullPath); + Commands.Discard.All(_repo.FullPath, false); } } diff --git a/src/ViewModels/CreateBranch.cs b/src/ViewModels/CreateBranch.cs index 2c925c03..a22a6871 100644 --- a/src/ViewModels/CreateBranch.cs +++ b/src/ViewModels/CreateBranch.cs @@ -17,7 +17,6 @@ namespace SourceGit.ViewModels public object BasedOn { get; - private set; } public Models.DealWithLocalChanges PreAction @@ -105,7 +104,7 @@ namespace SourceGit.ViewModels else if (PreAction == Models.DealWithLocalChanges.Discard) { SetProgressDescription("Discard local changes..."); - Commands.Discard.All(_repo.FullPath); + Commands.Discard.All(_repo.FullPath, false); } } diff --git a/src/ViewModels/Discard.cs b/src/ViewModels/Discard.cs index 916c3b86..e6653d02 100644 --- a/src/ViewModels/Discard.cs +++ b/src/ViewModels/Discard.cs @@ -3,19 +3,45 @@ using System.Threading.Tasks; namespace SourceGit.ViewModels { + public class DiscardAllMode + { + public bool IncludeIgnored + { + get; + set; + } = false; + } + + public class DiscardSingleFile + { + public string Path + { + get; + set; + } = string.Empty; + } + + public class DiscardMultipleFiles + { + public int Count + { + get; + set; + } = 0; + } + public class Discard : Popup { public object Mode { get; - private set; } public Discard(Repository repo) { _repo = repo; - Mode = new Models.Null(); + Mode = new DiscardAllMode(); View = new Views.Discard { DataContext = this }; } @@ -25,11 +51,11 @@ namespace SourceGit.ViewModels _changes = changes; if (_changes == null) - Mode = new Models.Null(); + Mode = new DiscardAllMode(); else if (_changes.Count == 1) - Mode = _changes[0].Path; + Mode = new DiscardSingleFile() { Path = _changes[0].Path }; else - Mode = _changes.Count; + Mode = new DiscardMultipleFiles() { Count = _changes.Count }; View = new Views.Discard() { DataContext = this }; } @@ -41,8 +67,8 @@ namespace SourceGit.ViewModels return Task.Run(() => { - if (_changes == null) - Commands.Discard.All(_repo.FullPath); + if (Mode is DiscardAllMode all) + Commands.Discard.All(_repo.FullPath, all.IncludeIgnored); else Commands.Discard.Changes(_repo.FullPath, _changes); diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index 03a72753..b37e8817 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -139,7 +139,7 @@ namespace SourceGit.ViewModels else if (PreAction == Models.DealWithLocalChanges.Discard) { SetProgressDescription("Discard local changes ..."); - Commands.Discard.All(_repo.FullPath); + Commands.Discard.All(_repo.FullPath, false); } } diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 0667c546..414a135b 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -1271,7 +1271,6 @@ namespace SourceGit.ViewModels var discard = new MenuItem(); discard.Header = App.Text("BranchCM.DiscardAll"); discard.Icon = App.CreateMenuIcon("Icons.Undo"); - discard.IsEnabled = _localChangesCount > 0; discard.Click += (_, e) => { if (PopupHost.CanCreatePopup()) diff --git a/src/Views/Discard.axaml b/src/Views/Discard.axaml index e67600d7..52668213 100644 --- a/src/Views/Discard.axaml +++ b/src/Views/Discard.axaml @@ -2,7 +2,6 @@ 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="500" d:DesignHeight="450" @@ -12,35 +11,69 @@ - - - - - - - - - + + + + + + + + + + + + + - - - - + + + + + + + - + - - - - + + + + + + + + + - + - - - - - - + + + + + + From 6fe7dfad7fb993485138e8bef67e37fde7910c52 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 3 Oct 2024 09:25:56 +0800 Subject: [PATCH 09/18] enhance: update filters after a filtered branch renamed (#536) --- src/ViewModels/RenameBranch.cs | 14 ++++++++++++-- src/ViewModels/Repository.cs | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/ViewModels/RenameBranch.cs b/src/ViewModels/RenameBranch.cs index acd38ced..9b387f9d 100644 --- a/src/ViewModels/RenameBranch.cs +++ b/src/ViewModels/RenameBranch.cs @@ -8,7 +8,6 @@ namespace SourceGit.ViewModels public Models.Branch Target { get; - private set; } [Required(ErrorMessage = "Branch name is required!!!")] @@ -54,8 +53,19 @@ namespace SourceGit.ViewModels return Task.Run(() => { + var oldName = Target.FullName; var succ = Commands.Branch.Rename(_repo.FullPath, Target.Name, _name); - CallUIThread(() => _repo.SetWatcherEnabled(true)); + CallUIThread(() => + { + if (succ && _repo.Settings.Filters.Contains(oldName)) + { + _repo.Settings.Filters.Remove(oldName); + _repo.Settings.Filters.Add($"refs/heads/{_name}"); + } + + _repo.MarkBranchesDirtyManually(); + _repo.SetWatcherEnabled(true); + }); return succ; }); } diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 414a135b..8038f333 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -841,7 +841,7 @@ namespace SourceGit.ViewModels if (_settings.Filters.Count != validFilters.Count) { - Dispatcher.UIThread.Post(() => + Dispatcher.UIThread.Invoke(() => { _settings.Filters.Clear(); _settings.Filters.AddRange(validFilters); @@ -850,6 +850,9 @@ namespace SourceGit.ViewModels } else { + if (_settings.Filters.Count != 0) + Dispatcher.UIThread.Invoke(() => _settings.Filters.Clear()); + limits += "--exclude=refs/stash --all"; } From ad3eec99cf9d90e22050de0af12881f6f2b7ebff Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 3 Oct 2024 17:49:02 +0800 Subject: [PATCH 10/18] project: remove file that not exists any more --- SourceGit.sln | 5 ----- 1 file changed, 5 deletions(-) diff --git a/SourceGit.sln b/SourceGit.sln index 06bd75b3..5ec28938 100644 --- a/SourceGit.sln +++ b/SourceGit.sln @@ -41,11 +41,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_common", "_common", "{04FD EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "usr", "usr", "{76639799-54BC-45E8-BD90-F45F63ACD11D}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bin", "bin", "{2E27E952-846B-4D75-A426-D22151277864}" - ProjectSection(SolutionItems) = preProject - build\resources\_common\usr\bin\sourcegit = build\resources\_common\usr\bin\sourcegit - EndProjectSection -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "share", "share", "{A3ABAA7C-EE14-4448-B466-6E69C1347E7D}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "applications", "applications", "{2AF28D3B-14A8-46A8-B828-157FAAB1B06F}" From af099af4d02d028a382b1cce94ced391d019f56d Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 3 Oct 2024 18:28:01 +0800 Subject: [PATCH 11/18] refactor: stash selected changes in staged group will apply `--staged` paramter for `git stash push` (#535) --- src/Commands/Stash.cs | 49 +++++++++++++++++++++------------- src/ViewModels/StashChanges.cs | 9 ++++--- src/ViewModels/WorkingCopy.cs | 30 +++++++++------------ 3 files changed, 49 insertions(+), 39 deletions(-) diff --git a/src/Commands/Stash.cs b/src/Commands/Stash.cs index cf7d84d1..1eb7d03d 100644 --- a/src/Commands/Stash.cs +++ b/src/Commands/Stash.cs @@ -17,32 +17,45 @@ namespace SourceGit.Commands return Exec(); } - public bool Push(List changes, string message) + public bool Push(List changes, string message, bool onlyStaged) { var pathsBuilder = new StringBuilder(); - var needAdd = new List(); - foreach (var c in changes) - { - pathsBuilder.Append($"\"{c.Path}\" "); - if (c.WorkTree == Models.ChangeState.Added || c.WorkTree == Models.ChangeState.Untracked) + if (onlyStaged) + { + foreach (var c in changes) + pathsBuilder.Append($"\"{c.Path}\" "); + + var paths = pathsBuilder.ToString(); + Args = $"stash push --staged -m \"{message}\" -- {paths}"; + } + else + { + var needAdd = new List(); + foreach (var c in changes) { - needAdd.Add(c); - if (needAdd.Count > 10) + pathsBuilder.Append($"\"{c.Path}\" "); + + if (c.WorkTree == Models.ChangeState.Added || c.WorkTree == Models.ChangeState.Untracked) { - new Add(WorkingDirectory, needAdd).Exec(); - needAdd.Clear(); + needAdd.Add(c); + if (needAdd.Count > 10) + { + new Add(WorkingDirectory, needAdd).Exec(); + needAdd.Clear(); + } } } + if (needAdd.Count > 0) + { + new Add(WorkingDirectory, needAdd).Exec(); + needAdd.Clear(); + } + + var paths = pathsBuilder.ToString(); + Args = $"stash push -m \"{message}\" -- {paths}"; } - if (needAdd.Count > 0) - { - new Add(WorkingDirectory, needAdd).Exec(); - needAdd.Clear(); - } - - var paths = pathsBuilder.ToString(); - Args = $"stash push -m \"{message}\" -- {paths}"; + return Exec(); } diff --git a/src/ViewModels/StashChanges.cs b/src/ViewModels/StashChanges.cs index 9a06ff9a..abc45492 100644 --- a/src/ViewModels/StashChanges.cs +++ b/src/ViewModels/StashChanges.cs @@ -14,7 +14,6 @@ namespace SourceGit.ViewModels public bool CanIgnoreUntracked { get; - private set; } public bool IncludeUntracked @@ -23,10 +22,11 @@ namespace SourceGit.ViewModels set; } - public StashChanges(Repository repo, List changes, bool canIgnoreUntracked) + public StashChanges(Repository repo, List changes, bool onlyStaged, bool canIgnoreUntracked) { _repo = repo; _changes = changes; + _onlyStaged = onlyStaged; CanIgnoreUntracked = canIgnoreUntracked; IncludeUntracked = true; @@ -56,17 +56,18 @@ namespace SourceGit.ViewModels return Task.Run(() => { - new Commands.Stash(_repo.FullPath).Push(jobs, Message); + var succ = new Commands.Stash(_repo.FullPath).Push(jobs, Message, _onlyStaged); CallUIThread(() => { _repo.MarkWorkingCopyDirtyManually(); _repo.SetWatcherEnabled(true); }); - return true; + return succ; }); } private readonly Repository _repo = null; private readonly List _changes = null; + private readonly bool _onlyStaged = false; } } diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 74ff3e0e..4bfb10bc 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -318,9 +318,9 @@ namespace SourceGit.ViewModels return; if (autoStart) - PopupHost.ShowAndStartPopup(new StashChanges(_repo, _cached, true)); + PopupHost.ShowAndStartPopup(new StashChanges(_repo, _cached, false, true)); else - PopupHost.ShowPopup(new StashChanges(_repo, _cached, true)); + PopupHost.ShowPopup(new StashChanges(_repo, _cached, false, true)); } public void StageSelected(Models.Change next) @@ -524,7 +524,7 @@ namespace SourceGit.ViewModels { if (PopupHost.CanCreatePopup()) { - PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false)); + PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false, false)); } e.Handled = true; }; @@ -843,7 +843,7 @@ namespace SourceGit.ViewModels stash.Click += (_, e) => { if (PopupHost.CanCreatePopup()) - PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false)); + PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false, false)); e.Handled = true; }; @@ -928,7 +928,7 @@ namespace SourceGit.ViewModels stash.Click += (_, e) => { if (PopupHost.CanCreatePopup()) - PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, false)); + PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true, false)); e.Handled = true; }; @@ -1097,7 +1097,7 @@ namespace SourceGit.ViewModels stash.Click += (_, e) => { if (PopupHost.CanCreatePopup()) - PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, false)); + PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true, false)); e.Handled = true; }; @@ -1202,20 +1202,16 @@ namespace SourceGit.ViewModels private List GetStagedChanges() { if (_useAmend) - { return new Commands.QueryStagedChangesWithAmend(_repo.FullPath).Result(); - } - else + + var rs = new List(); + foreach (var c in _cached) { - var rs = new List(); - foreach (var c in _cached) - { - if (c.Index != Models.ChangeState.None && - c.Index != Models.ChangeState.Untracked) - rs.Add(c); - } - return rs; + if (c.Index != Models.ChangeState.None && + c.Index != Models.ChangeState.Untracked) + rs.Add(c); } + return rs; } private void SetDetail(Models.Change change, bool isUnstaged) From 5005b62eea0e00e81989730a14d9f48f5573c074 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 3 Oct 2024 18:32:13 +0800 Subject: [PATCH 12/18] project: remove unused folder --- SourceGit.sln | 1 - 1 file changed, 1 deletion(-) diff --git a/SourceGit.sln b/SourceGit.sln index 5ec28938..10c94e36 100644 --- a/SourceGit.sln +++ b/SourceGit.sln @@ -101,7 +101,6 @@ Global {ABC98884-F023-4EF4-A9C9-5DE9452BE955} = {FD384607-ED99-47B7-AF31-FB245841BC92} {04FD74B1-FBDB-496E-A48F-3D59D71FF952} = {FD384607-ED99-47B7-AF31-FB245841BC92} {76639799-54BC-45E8-BD90-F45F63ACD11D} = {04FD74B1-FBDB-496E-A48F-3D59D71FF952} - {2E27E952-846B-4D75-A426-D22151277864} = {76639799-54BC-45E8-BD90-F45F63ACD11D} {A3ABAA7C-EE14-4448-B466-6E69C1347E7D} = {76639799-54BC-45E8-BD90-F45F63ACD11D} {2AF28D3B-14A8-46A8-B828-157FAAB1B06F} = {A3ABAA7C-EE14-4448-B466-6E69C1347E7D} {7166EC6C-17F5-4B5E-B38E-1E53C81EACF6} = {A3ABAA7C-EE14-4448-B466-6E69C1347E7D} From 3ce06cc6b5133a5ecdd6b61eba0ca3f72d35de26 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 3 Oct 2024 19:01:49 +0800 Subject: [PATCH 13/18] ux: add tooltip for change status icon (#537) --- src/Views/ChangeStatusIcon.cs | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/Views/ChangeStatusIcon.cs b/src/Views/ChangeStatusIcon.cs index 06508638..d11a504a 100644 --- a/src/Views/ChangeStatusIcon.cs +++ b/src/Views/ChangeStatusIcon.cs @@ -62,6 +62,7 @@ namespace SourceGit.Views ]; private static readonly string[] INDICATOR = ["?", "±", "T", "+", "−", "➜", "❏", "U", "★"]; + private static readonly string[] TIPS = ["Unknown", "Modified", "Type Changed", "Added", "Deleted", "Renamed", "Copied", "Unmerged", "Untracked" ]; public static readonly StyledProperty IsUnstagedChangeProperty = AvaloniaProperty.Register(nameof(IsUnstagedChange)); @@ -81,11 +82,6 @@ namespace SourceGit.Views set => SetValue(ChangeProperty, value); } - static ChangeStatusIcon() - { - AffectsRender(IsUnstagedChangeProperty, ChangeProperty); - } - public override void Render(DrawingContext context) { if (Change == null || Bounds.Width <= 0) @@ -122,10 +118,33 @@ namespace SourceGit.Views Bounds.Width * 0.8, Brushes.White); - float corner = (float)Math.Max(2, Bounds.Width / 16); - Point textOrigin = new Point((Bounds.Width - txt.Width) * 0.5, (Bounds.Height - txt.Height) * 0.5); + var corner = (float)Math.Max(2, Bounds.Width / 16); + var textOrigin = new Point((Bounds.Width - txt.Width) * 0.5, (Bounds.Height - txt.Height) * 0.5); context.DrawRectangle(background, null, new Rect(0, 0, Bounds.Width, Bounds.Height), corner, corner); context.DrawText(txt, textOrigin); } + + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + + if (change.Property == IsUnstagedChangeProperty || change.Property == ChangeProperty) + { + var isUnstaged = IsUnstagedChange; + var c = Change; + if (c == null) + { + ToolTip.SetTip(this, null); + return; + } + + if (isUnstaged) + ToolTip.SetTip(this, c.IsConflit ? "Conflict" : TIPS[(int)c.WorkTree]); + else + ToolTip.SetTip(this, TIPS[(int)c.Index]); + + InvalidateVisual(); + } + } } } From 9d3a87469ff0236bdff60f554d33c534646ed120 Mon Sep 17 00:00:00 2001 From: AquariusStar <48148723+AquariusStar@users.noreply.github.com> Date: Sat, 5 Oct 2024 05:44:55 +0300 Subject: [PATCH 14/18] Work on the translation (#541) --- src/Resources/Locales/ru_RU.axaml | 65 ++++++++++++++++--------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index 948905eb..ceda8a9f 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -56,7 +56,7 @@ Удалить ${0}$... Удалить выбранные {0} ветки Отклонить все изменения. - Быстрая перемотка вперёд к ${0}$ + Перемотать вперёд к ${0}$ Поток Git - Завершение ${0}$ Слить ${0}$ в ${1}$... Забрать ${0}$ @@ -141,6 +141,7 @@ GIT Автоматическое извлечение внешних хранилищ Минут(а/ы) + Удалённое хранилище по-умолчанию ОТСЛЕЖИВАНИЕ ПРОБЛЕМ Добавить пример правила для Git Добавить пример правила Jira @@ -171,15 +172,15 @@ Имя новой ветки: Ввести имя ветки. Создать локальную ветку - Создать тег... - Новый тег у: + Создать метку... + Новая метка у: Подпись GPG - Сообщение с тегом: + Сообщение с меткой: Необязательно. - Имя тега: + Имя метки: Рекомендуемый формат: v1.0.0-alpha Выложить на все внешние хранилища после создания - Создать новый тег + Создать новую метку Добрый: Аннотированный Лёгкий @@ -198,14 +199,15 @@ Подтвердите удаление хранилища Удалить подмодуль Путь подмодуля: - Удалить тег - Тег: + Удалить метку + Метка: Удалить из внешнего хранилища РАЗНИЦА БИНАРНИКОВ НОВЫЙ СТАРЫЙ Копировать Режим файла изменён + Игнорировать изменение пробелов Показать скрытые символы ИЗМЕНЕНИЕ ОБЪЕКТА ХБФ Следующее различие @@ -225,6 +227,7 @@ Отклонить изменения Все локальные изменения в рабочей копии. Изменения: + Включить игнорируемые файлы Всего {0} изменений будут отменены Вы не можете отменить это действие!!! Закладка: @@ -235,7 +238,7 @@ Быстрая перемотка вперёд (без проверки) Извлечь Извлечь все внешние хранилища - Извлечь без тегов + Извлечь без меток Удалить внешние мёртвые ветки Внешнее хранилище: Извлечь внешние изменения @@ -281,7 +284,7 @@ Ввести имя Запуск выпуска... ПОТОК - Запуск выпуска - Префикс тега версии: + Префикс метки версии: Git хранилища больших файлов Добавить шаблон отслеживания... Шаблон — это имя файла @@ -328,17 +331,17 @@ Создать новую страницу Открыть диалоговое окно настроек ХРАНИЛИЩЕ - Фиксация подготовленных изменений - Фиксировать и выложить подготовленные изменения + Зафиксировать подготовленные изменения + Зафиксировать и выложить подготовленные изменения Подготовить все изменения и зафиксировать Отклонить выбранные изменения Режим доски (по-умолчанию) - Принудительно перезагрузить этот репозиторий - Подгтовленные/Неподготовленные выбранные изменения + Принудительно перезагрузить этот хранилище + Подготовленные/Неподготовленные выбранные изменения Режим поиска фиксаций - Перекключить на 'Изменения' - Перекключить на 'Истории' - Перекключить на 'Отложенные' + Переключить на 'Изменения' + Переключить на 'Истории' + Переключить на 'Отложенные' ТЕКСТОВЫЙ РЕДАКТОР Закрыть панель поиска Найти следующее совпадение @@ -354,7 +357,7 @@ Выполняется перенос. Нажмите 'Отказ' для восстановления заголовка. Выполняется возврат. Нажмите 'Отказ' для восстановления заголовка. Интерактивное перемещение - целевая ветка: + Целевая ветка: На: Вверх Вниз @@ -393,7 +396,7 @@ В пролому году {0} лет назад Параметры - ОТКРЫТЬ ВИ + ОТКРЫТЬ ИИ Сервер Ключ API Модель @@ -427,7 +430,7 @@ Git (>= 2.23.0) требуется для этого приложения ПОДПИСЬ GPG Фиксация подписи GPG - Тег подписи GPG + Метка подписи GPG Формат GPG Путь установки программы Введите путь для установленной программы GPG @@ -449,7 +452,7 @@ Отклонить Ничего не делать Отложить и применить повторно - Забрать без тегов + Забрать без меток Внешнее хранилище: Забрать (Получить и слить) Использовать перемещение вместо слияния @@ -461,11 +464,11 @@ Выложить изменения на внешнее хранилище Ветка внешнего хранилища: Установить в качестве ветки отслеживания - Выложить все теги - Выложить тег на внешнее хранилище + Выложить все метки + Выложить метку на внешнее хранилище Выложить на все внешние хранилища Внешнее хранилище: - Тег: + Метка: Выйти Перемещение текущей ветки Отложить и применить повторно локальные изменения @@ -494,13 +497,13 @@ Ветка: Отказ Автоматическое извлечение изменений с внешних хранилищ... - Очистка (Сбор мусора и удаление) + Очистить (Сбор мусора и удаление) Запустить команду `git gc` для данного хранилища. Очистить всё Настройка этого хранилища ПРОДОЛЖИТЬ Открыть в файловом менеджере - Поиск веток, тегов и подмодулей + Поиск веток, меток и подмодулей ОТФИЛЬТРОВАНО ОТ: ЛОКАЛЬНЫЕ ВЕТКИ Навигация по заголовку @@ -518,13 +521,13 @@ SHA Автор и исполнитель Текущая ветка - Показать теги как дерево + Показать метки как дерево Статистики ПОДМОДУЛИ ДОБАВИТЬ ПОДМОДУЛЬ ОБНОВИТЬ ПОДМОДУЛЬ - ТЕГИ - НОВЫЙ ТЕГ + МЕТКИ + НОВАЯ МЕТКА Открыть в терминале РАБОЧИЕ ДЕРЕВЬЯ ДОБАВИТЬ РАБОЧЕЕ ДЕРЕВО @@ -588,7 +591,7 @@ Относительный каталог для хранения подмодуля. Удалить подмодуль ОК - Копировать имя тега + Копировать имя метки Удалить ${0}$... Выложить ${0}$... Сетевой адрес: @@ -625,7 +628,7 @@ ЗАФИКСИРОВАТЬ ЗАФИКСИРОВАТЬ и ОТПРАВИТЬ Шаблон/Истории - Запуск события щелчка + Запустить событие щелчка Подготовить все изменения и зафиксировать ОБНАРУЖЕНЫ КОНФЛИКТЫ КОНФЛИКТЫ ФАЙЛОВ РАЗРЕШЕНЫ From 7262437385a3f8043d31873f66ddfacc796c6282 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 6 Oct 2024 21:48:26 +0800 Subject: [PATCH 15/18] ux: new style for pushing a new branch to remote --- src/ViewModels/Push.cs | 11 +++++------ src/Views/Push.axaml | 10 +++++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/ViewModels/Push.cs b/src/ViewModels/Push.cs index acbb1b1d..004ae7b6 100644 --- a/src/ViewModels/Push.cs +++ b/src/ViewModels/Push.cs @@ -26,7 +26,6 @@ namespace SourceGit.ViewModels public List LocalBranches { get; - private set; } public List Remotes @@ -157,7 +156,7 @@ namespace SourceGit.ViewModels { _repo.SetWatcherEnabled(false); - var remoteBranchName = _selectedRemoteBranch.Name.Replace(" (new)", ""); + var remoteBranchName = _selectedRemoteBranch.Name; ProgressDescription = $"Push {_selectedLocalBranch.Name} -> {_selectedRemote.Name}/{remoteBranchName} ..."; return Task.Run(() => @@ -187,7 +186,7 @@ namespace SourceGit.ViewModels branches.Add(branch); } - // If selected local branch has upstream branch. Try to find it in current remote branches. + // If selected local branch has upstream. Try to find it in current remote branches. if (!string.IsNullOrEmpty(_selectedLocalBranch.Upstream)) { foreach (var branch in branches) @@ -201,7 +200,7 @@ namespace SourceGit.ViewModels } } - // Find best remote branch by name. + // Try to find a remote branch with the same name of selected local branch. foreach (var branch in branches) { if (_selectedLocalBranch.Name == branch.Name) @@ -215,7 +214,7 @@ namespace SourceGit.ViewModels // Add a fake new branch. var fake = new Models.Branch() { - Name = $"{_selectedLocalBranch.Name} (new)", + Name = _selectedLocalBranch.Name, Remote = _selectedRemote.Name, }; branches.Add(fake); @@ -226,7 +225,7 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; private Models.Branch _selectedLocalBranch = null; private Models.Remote _selectedRemote = null; - private List _remoteBranches = new List(); + private List _remoteBranches = []; private Models.Branch _selectedRemoteBranch = null; private bool _isSetTrackOptionVisible = false; } diff --git a/src/Views/Push.axaml b/src/Views/Push.axaml index 2d1e9232..5abb08c0 100644 --- a/src/Views/Push.axaml +++ b/src/Views/Push.axaml @@ -65,7 +65,15 @@ - + + + + From 029f56cb2880e0687eaf0db9e4e574f1b4fb7610 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 6 Oct 2024 22:21:18 +0800 Subject: [PATCH 16/18] feature: the default merge option supports reading `branch..mergeoptions` configuration (#540) --- src/ViewModels/Merge.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ViewModels/Merge.cs b/src/ViewModels/Merge.cs index 48af8722..fb1dccab 100644 --- a/src/ViewModels/Merge.cs +++ b/src/ViewModels/Merge.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; namespace SourceGit.ViewModels { @@ -7,13 +8,11 @@ namespace SourceGit.ViewModels public string Source { get; - private set; } public string Into { get; - private set; } public Models.MergeMode SelectedMode @@ -27,7 +26,7 @@ namespace SourceGit.ViewModels _repo = repo; Source = source; Into = into; - SelectedMode = Models.MergeMode.Supported[0]; + SelectedMode = AutoSelectMergeMode(); View = new Views.Merge() { DataContext = this }; } @@ -44,6 +43,21 @@ namespace SourceGit.ViewModels }); } + private Models.MergeMode AutoSelectMergeMode() + { + var config = new Commands.Config(_repo.FullPath).Get($"branch.{Into}.mergeoptions"); + if (string.IsNullOrEmpty(config)) + return Models.MergeMode.Supported[0]; + if (config.Equals("--no-ff", StringComparison.Ordinal)) + return Models.MergeMode.Supported[1]; + if (config.Equals("--squash", StringComparison.Ordinal)) + return Models.MergeMode.Supported[2]; + if (config.Equals("--no-commit", StringComparison.Ordinal) || config.Equals("--no-ff --no-commit", StringComparison.Ordinal)) + return Models.MergeMode.Supported[3]; + + return Models.MergeMode.Supported[0]; + } + private readonly Repository _repo = null; } } From 3dcb32aec98cddce317314b9909980bf57310184 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 6 Oct 2024 22:38:13 +0800 Subject: [PATCH 17/18] ux: new style for discard confirm popup --- src/Views/Discard.axaml | 45 +++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/src/Views/Discard.axaml b/src/Views/Discard.axaml index 52668213..d37662b0 100644 --- a/src/Views/Discard.axaml +++ b/src/Views/Discard.axaml @@ -12,10 +12,19 @@ Classes="bold" Text="{DynamicResource Text.Discard}"/> + + + + + - + - - - - - - - + - + - - - - + - + - + - - From 6ccdf47f99921856875c58e6634fff058e1a138a Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 8 Oct 2024 09:24:25 +0800 Subject: [PATCH 18/18] version: Release 8.33 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index eed4bd77..7230dc00 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.32 \ No newline at end of file +8.33 \ No newline at end of file