From aee3abfffbda5e1c13f6a6232f1d44ad141c0e4c Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 10 Dec 2024 11:17:30 +0800 Subject: [PATCH] enhance: redesign in-progress banner (#790) * show head for cherry-pick * show stopped at for rebase * supports `--skip` for cherry-pick and rebase --- src/Resources/Locales/de_DE.axaml | 9 ++-- src/Resources/Locales/en_US.axaml | 12 +++--- src/Resources/Locales/es_ES.axaml | 9 ++-- src/Resources/Locales/fr_FR.axaml | 9 ++-- src/Resources/Locales/it_IT.axaml | 9 ++-- src/Resources/Locales/pt_BR.axaml | 9 ++-- src/Resources/Locales/ru_RU.axaml | 9 ++-- src/Resources/Locales/zh_CN.axaml | 12 +++--- src/Resources/Locales/zh_TW.axaml | 12 +++--- src/ViewModels/InProgressContexts.cs | 49 +++++++++++++++++++--- src/ViewModels/WorkingCopy.cs | 4 +- src/Views/Repository.axaml | 61 ++++++++++++++++++++-------- 12 files changed, 135 insertions(+), 69 deletions(-) diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index bb31fa8f..4461ede5 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -389,10 +389,10 @@ Verwerfen Initialisiere Repository Pfad: - Cherry-Pick wird durchgeführt. Drücke 'Abbrechen' um den originalen HEAD wiederherzustellen. - Merge request wird durchgeführt. Drücke 'Abbrechen' um den originalen HEAD wiederherzustellen. - Rebase wird durchgeführt. Drücke 'Abbrechen' um den originalen HEAD wiederherzustellen. - Revert wird durchgeführt. Drücke 'Abbrechen' um den originalen HEAD wiederherzustellen. + Cherry-Pick wird durchgeführt. + Merge request wird durchgeführt. + Rebase wird durchgeführt. + Revert wird durchgeführt. Interaktiver Rebase Ziel Branch: Auf: @@ -562,7 +562,6 @@ Aktualisiern REMOTES REMOTE HINZUFÜGEN - KONFLIKTE BEHEBEN Commit suchen Dateiname Commit-Nachricht diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 2369c3a6..9a721100 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -391,10 +391,12 @@ Discard Initialize Repository Path: - Cherry-Pick in progress. Press 'Abort' to restore original HEAD. - Merge request in progress. Press 'Abort' to restore original HEAD. - Rebase in progress. Press 'Abort' to restore original HEAD. - Revert in progress. Press 'Abort' to restore original HEAD. + Cherry-Pick in progress. + Current commit + Merge request in progress. + Rebase in progress. + Stopped at + Revert in progress. Interactive Rebase Target Branch: On: @@ -568,7 +570,6 @@ Refresh REMOTES ADD REMOTE - RESOLVE Search Commit File Message @@ -576,6 +577,7 @@ Author & Committer Current Branch Show Tags as Tree + SKIP Statistics SUBMODULES ADD SUBMODULE diff --git a/src/Resources/Locales/es_ES.axaml b/src/Resources/Locales/es_ES.axaml index 7c7f8d7c..abdc9367 100644 --- a/src/Resources/Locales/es_ES.axaml +++ b/src/Resources/Locales/es_ES.axaml @@ -392,10 +392,10 @@ Descartar Inicializar Repositorio Ruta: - Cherry-Pick en progreso. Presiona 'Abort' para restaurar el HEAD original. - Merge en progreso. Presiona 'Abort' para restaurar el HEAD original. - Rebase en progreso. Presiona 'Abort' para restaurar el HEAD original. - Revert en progreso. Presiona 'Abort' para restaurar el HEAD original. + Cherry-Pick en progreso. + Merge en progreso. + Rebase en progreso. + Revert en progreso. Rebase Interactivo Rama Objetivo: En: @@ -564,7 +564,6 @@ Refrescar REMOTOS AÑADIR REMOTO - RESOLVER Buscar Commit Archivo Mensaje diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index a9a18be3..c6c2b39d 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -386,10 +386,10 @@ Rejeter Initialiser le repository Chemin : - Cherry-Pick en cours. Appuyer sur 'Abort' pour restaurer le HEAD d'origine. - Merge request in progress. Appuyer sur 'Abort' pour restaurer le HEAD d'origine. - Rebase in progress. Appuyer sur 'Abort' pour restaurer le HEAD d'origine. - Revert in progress. Appuyer sur 'Abort' pour restaurer le HEAD d'origine. + Cherry-Pick en cours. + Merge request in progress. + Rebase in progress. + Revert in progress. Rebase interactif Branche cible : Sur : @@ -549,7 +549,6 @@ Rafraîchir DEPOTS DISTANTS AJOUTER DEPOT DISTANT - RESOUDRE Rechercher un commit Fichier Message diff --git a/src/Resources/Locales/it_IT.axaml b/src/Resources/Locales/it_IT.axaml index fbf918b8..9a504677 100644 --- a/src/Resources/Locales/it_IT.axaml +++ b/src/Resources/Locales/it_IT.axaml @@ -389,10 +389,10 @@ Scarta Inizializza Repository Percorso: - Cherry-Pick in corso. Premi 'Annulla' per ripristinare l'HEAD originale. - Richiesta di merge in corso. Premi 'Annulla' per ripristinare l'HEAD originale. - Rebase in corso. Premi 'Annulla' per ripristinare l'HEAD originale. - Revert in corso. Premi 'Annulla' per ripristinare l'HEAD originale. + Cherry-Pick in corso. + Richiesta di merge in corso. + Rebase in corso. + Revert in corso. Rebase Interattivo Branch di destinazione: Su: @@ -555,7 +555,6 @@ Aggiorna REMOTI AGGIUNGI REMOTO - RISOLVI Cerca Commit File Messaggio diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index 4d011b32..1b7ac39d 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -412,10 +412,10 @@ Descartar Inicializar Repositório Caminho: - Cherry-Pick em andamento. Pressione 'Abort' para restaurar o HEAD original. - Merge em andamento. Pressione 'Abort' para restaurar o HEAD original. - Rebase em andamento. Pressione 'Abort' para restaurar o HEAD original. - Revert em andamento. Pressione 'Abort' para restaurar o HEAD original. + Cherry-Pick em andamento. + Merge em andamento. + Rebase em andamento. + Revert em andamento. Rebase Interativo Ramo Alvo: Em: @@ -583,7 +583,6 @@ Atualizar REMOTOS ADICIONAR REMOTO - RESOLVER Pesquisar Commit Arquivo Mensagem diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index 5b2cf129..fe8cb02f 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -392,10 +392,10 @@ Отклонить Инициализировать хранилище Путь: - Выполняется частичный забор. Нажмите «Отказ» для восстановления заголовка. - Выполняет запрос слияния. Нажмите «Отказ» для восстановления заголовка. - Выполняется перенос. Нажмите «Отказ» для восстановления заголовка. - Выполняется возврат. Нажмите «Отказ» для восстановления заголовка. + Выполняется частичный забор. + Выполняет запрос слияния. + Выполняется перенос. + Выполняется возврат. Интерактивное перемещение Целевая ветка: На: @@ -566,7 +566,6 @@ Обновить ВНЕШНИЕ ХРАНИЛИЩА ДОБАВИТЬ ВНЕШНЕЕ ХРАНИЛИЩЕ - РАЗРЕШИТЬ Поиск фиксации Файл Сообщение diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 95224ec2..4527b4c4 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -394,10 +394,12 @@ 丢弃 初始化新仓库 路径 : - 挑选(Cherry-Pick)操作进行中。点击【终止】回滚到操作前的状态。 - 合并操作进行中。点击【终止】回滚到操作前的状态。 - 变基(Rebase)操作进行中。点击【终止】回滚到操作前的状态。 - 回滚提交操作进行中。点击【终止】回滚到操作前的状态。 + 挑选(Cherry-Pick)操作进行中。 + 当前提交 + 合并操作进行中。 + 变基(Rebase)操作进行中。 + 当前停止于 + 回滚提交操作进行中。 交互式变基 目标分支 : 起始提交 : @@ -572,7 +574,6 @@ 重新加载 远程列表 添加远程 - 解决冲突 查找提交 文件 提交信息 @@ -580,6 +581,7 @@ 作者及提交者 仅在当前分支中查找 以树型结构展示 + 跳过此提交 提交统计 子模块列表 添加子模块 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 6eb31d6b..bb2a3733 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -394,10 +394,12 @@ 捨棄 初始化存放庫 路徑: - 揀選 (cherry-pick) 操作進行中。點選 [中止] 復原到操作前的狀態。 - 合併操作進行中。點選 [中止] 復原到操作前的狀態。 - 重定基底 (rebase) 操作進行中。點選 [中止] 復原到操作前的狀態。 - 復原提交操作進行中。點選 [中止] 復原到操作前的狀態。 + 揀選 (cherry-pick) 操作進行中。 + 当前提交 + 合併操作進行中。 + 重定基底 (rebase) 操作進行中。 + 当前停止于 + 復原提交操作進行中。 互動式重定基底 目標分支: 起始提交: @@ -571,7 +573,6 @@ 重新載入 遠端列表 新增遠端 - 解決衝突 搜尋提交 檔案 提交訊息 @@ -579,6 +580,7 @@ 作者及提交者 僅搜尋目前分支 以樹型結構展示 + 跳過此提交 提交統計 子模組列表 新增子模組 diff --git a/src/ViewModels/InProgressContexts.cs b/src/ViewModels/InProgressContexts.cs index f7b85032..06417e9e 100644 --- a/src/ViewModels/InProgressContexts.cs +++ b/src/ViewModels/InProgressContexts.cs @@ -16,10 +16,17 @@ namespace SourceGit.ViewModels set; } - public InProgressContext(string repo, string cmd) + public bool CanSkip + { + get; + protected set; + } + + public InProgressContext(string repo, string cmd, bool canSkip) { Repository = repo; Cmd = cmd; + CanSkip = canSkip; } public bool Abort() @@ -32,6 +39,19 @@ namespace SourceGit.ViewModels }.Exec(); } + public bool Skip() + { + if (!CanSkip) + return true; + + return new Commands.Command() + { + WorkingDirectory = Repository, + Context = Repository, + Args = $"{Cmd} --skip", + }.Exec(); + } + public virtual bool Continue() { return new Commands.Command() @@ -46,14 +66,33 @@ namespace SourceGit.ViewModels public class CherryPickInProgress : InProgressContext { - public CherryPickInProgress(string repo) : base(repo, "cherry-pick") { } + public Models.Commit Head + { + get; + private set; + } + + public CherryPickInProgress(Repository repo) : base(repo.FullPath, "cherry-pick", true) + { + var headSHA = File.ReadAllText(Path.Combine(repo.GitDir, "CHERRY_PICK_HEAD")).Trim(); + Head = new Commands.QuerySingleCommit(repo.FullPath, headSHA).Result(); + } } public class RebaseInProgress : InProgressContext { - public RebaseInProgress(Repository repo) : base(repo.FullPath, "rebase") + public Models.Commit StoppedAt + { + get; + private set; + } + + public RebaseInProgress(Repository repo) : base(repo.FullPath, "rebase", true) { _gitDir = repo.GitDir; + + var stoppedSHA = File.ReadAllText(Path.Combine(repo.GitDir, "rebase-merge", "stopped-sha")).Trim(); + StoppedAt = new Commands.QuerySingleCommit(repo.FullPath, stoppedSHA).Result(); } public override bool Continue() @@ -90,11 +129,11 @@ namespace SourceGit.ViewModels public class RevertInProgress : InProgressContext { - public RevertInProgress(string repo) : base(repo, "revert") { } + public RevertInProgress(string repo) : base(repo, "revert", false) { } } public class MergeInProgress : InProgressContext { - public MergeInProgress(string repo) : base(repo, "merge") { } + public MergeInProgress(string repo) : base(repo, "merge", false) { } } } diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 4a6e5a01..f708306c 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -237,7 +237,7 @@ namespace SourceGit.ViewModels var inProgress = null as InProgressContext; if (File.Exists(Path.Combine(_repo.GitDir, "CHERRY_PICK_HEAD"))) - inProgress = new CherryPickInProgress(_repo.FullPath); + inProgress = new CherryPickInProgress(_repo); else if (File.Exists(Path.Combine(_repo.GitDir, "REBASE_HEAD")) && Directory.Exists(Path.Combine(_repo.GitDir, "rebase-merge"))) inProgress = new RebaseInProgress(_repo); else if (File.Exists(Path.Combine(_repo.GitDir, "REVERT_HEAD"))) @@ -310,7 +310,7 @@ namespace SourceGit.ViewModels var inProgress = null as InProgressContext; if (File.Exists(Path.Combine(_repo.GitDir, "CHERRY_PICK_HEAD"))) - inProgress = new CherryPickInProgress(_repo.FullPath); + inProgress = new CherryPickInProgress(_repo); else if (File.Exists(Path.Combine(_repo.GitDir, "REBASE_HEAD")) && Directory.Exists(Path.Combine(_repo.GitDir, "rebase-merge"))) inProgress = new RebaseInProgress(_repo); else if (File.Exists(Path.Combine(_repo.GitDir, "REVERT_HEAD"))) diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index a0e83046..186bbb7d 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -550,12 +550,32 @@ + + + + + + + + + + + + - + + + + + - + + + + + @@ -568,23 +588,30 @@ - -