From 619bbf71c7d177f23cfae4ee754d2ea0c5a8472f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C6=B0=C6=A1ng=20Duy=20Kh=C3=A1nh?= Date: Mon, 10 Aug 2026 10:56:01 +0700 Subject: [PATCH] Always confirm before pushing the selected branch (#3) The Branches panel's push keybinding pushed the highlighted branch immediately, with no confirmation - easy to misclick a different branch than intended since it targets whatever's selected, not the checked-out one. Add a confirmation dialog naming the branch before every push, regardless of upstream state. Co-authored-by: Khanh Truong --- docs-master/keybindings/Keybindings_en.md | 2 +- docs-master/keybindings/Keybindings_ja.md | 2 +- docs-master/keybindings/Keybindings_ko.md | 2 +- docs-master/keybindings/Keybindings_nl.md | 2 +- docs-master/keybindings/Keybindings_pl.md | 2 +- docs-master/keybindings/Keybindings_pt.md | 2 +- docs-master/keybindings/Keybindings_ru.md | 2 +- docs-master/keybindings/Keybindings_zh-CN.md | 2 +- docs-master/keybindings/Keybindings_zh-TW.md | 2 +- pkg/gui/controllers/branches_controller.go | 13 ++++++++++++- pkg/i18n/english.go | 4 +++- 11 files changed, 24 insertions(+), 11 deletions(-) diff --git a/docs-master/keybindings/Keybindings_en.md b/docs-master/keybindings/Keybindings_en.md index feaef33d1..02f59f4ee 100644 --- a/docs-master/keybindings/Keybindings_en.md +++ b/docs-master/keybindings/Keybindings_en.md @@ -198,7 +198,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` R `` | Rename branch | | | `` u `` | View upstream options | View options relating to the branch's upstream e.g. setting/unsetting the upstream and resetting to the upstream. | | `` `` | Open external diff tool (git difftool) | | -| `` P `` | Push selected branch | Push the selected branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` P `` | Push selected branch | Push the selected branch to its upstream branch, after confirming. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Pull selected branch | Pull the selected branch's upstream branch into it, via its linked worktree. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` 0 `` | Focus main view | | | `` `` | View commits | | diff --git a/docs-master/keybindings/Keybindings_ja.md b/docs-master/keybindings/Keybindings_ja.md index 4a2d68a1c..28b992b31 100644 --- a/docs-master/keybindings/Keybindings_ja.md +++ b/docs-master/keybindings/Keybindings_ja.md @@ -396,7 +396,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` R `` | ブランチ名を変更 | | | `` u `` | アップストリームオプションを表示 | ブランチのアップストリームに関連するオプションを表示します(例:アップストリームの設定/解除やアップストリームへのリセット)。 | | `` `` | 外部差分ツールを開く(git difftool) | | -| `` P `` | Push selected branch | Push the selected branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` P `` | Push selected branch | Push the selected branch to its upstream branch, after confirming. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Pull selected branch | Pull the selected branch's upstream branch into it, via its linked worktree. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` 0 `` | メインビューにフォーカス | | | `` `` | コミットを表示 | | diff --git a/docs-master/keybindings/Keybindings_ko.md b/docs-master/keybindings/Keybindings_ko.md index 8c2ca8398..b2a8bd33c 100644 --- a/docs-master/keybindings/Keybindings_ko.md +++ b/docs-master/keybindings/Keybindings_ko.md @@ -230,7 +230,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` R `` | 브랜치 이름 변경 | | | `` u `` | View upstream options | View options relating to the branch's upstream e.g. setting/unsetting the upstream and resetting to the upstream. | | `` `` | Open external diff tool (git difftool) | | -| `` P `` | Push selected branch | Push the selected branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` P `` | Push selected branch | Push the selected branch to its upstream branch, after confirming. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Pull selected branch | Pull the selected branch's upstream branch into it, via its linked worktree. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` 0 `` | Focus main view | | | `` `` | 커밋 보기 | | diff --git a/docs-master/keybindings/Keybindings_nl.md b/docs-master/keybindings/Keybindings_nl.md index cdd741145..3cb9fcb30 100644 --- a/docs-master/keybindings/Keybindings_nl.md +++ b/docs-master/keybindings/Keybindings_nl.md @@ -121,7 +121,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` R `` | Hernoem branch | | | `` u `` | View upstream options | View options relating to the branch's upstream e.g. setting/unsetting the upstream and resetting to the upstream. | | `` `` | Open externe diff applicatie (git difftool) | | -| `` P `` | Push selected branch | Push the selected branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` P `` | Push selected branch | Push the selected branch to its upstream branch, after confirming. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Pull selected branch | Pull the selected branch's upstream branch into it, via its linked worktree. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` 0 `` | Focus main view | | | `` `` | Bekijk commits | | diff --git a/docs-master/keybindings/Keybindings_pl.md b/docs-master/keybindings/Keybindings_pl.md index 01c13bfbb..809dd8a4d 100644 --- a/docs-master/keybindings/Keybindings_pl.md +++ b/docs-master/keybindings/Keybindings_pl.md @@ -182,7 +182,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` R `` | Zmień nazwę gałęzi | | | `` u `` | Pokaż opcje upstream | Pokaż opcje dotyczące upstream gałęzi, np. ustawianie/usuwanie upstream i resetowanie do upstream. | | `` `` | Otwórz zewnętrzne narzędzie różnic (git difftool) | | -| `` P `` | Push selected branch | Push the selected branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` P `` | Push selected branch | Push the selected branch to its upstream branch, after confirming. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Pull selected branch | Pull the selected branch's upstream branch into it, via its linked worktree. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` 0 `` | Focus main view | | | `` `` | Pokaż commity | | diff --git a/docs-master/keybindings/Keybindings_pt.md b/docs-master/keybindings/Keybindings_pt.md index d1ceb5908..7ebc3c17a 100644 --- a/docs-master/keybindings/Keybindings_pt.md +++ b/docs-master/keybindings/Keybindings_pt.md @@ -113,7 +113,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` R `` | Renomear branch | | | `` u `` | View upstream options | View options relating to the branch's upstream e.g. setting/unsetting the upstream and resetting to the upstream. | | `` `` | Abrir ferramenta de diff externa (git difftool) | | -| `` P `` | Push selected branch | Push the selected branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` P `` | Push selected branch | Push the selected branch to its upstream branch, after confirming. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Pull selected branch | Pull the selected branch's upstream branch into it, via its linked worktree. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` 0 `` | Focar visualização principal | | | `` `` | Ver commits | | diff --git a/docs-master/keybindings/Keybindings_ru.md b/docs-master/keybindings/Keybindings_ru.md index 8dac0f6fb..96455fa07 100644 --- a/docs-master/keybindings/Keybindings_ru.md +++ b/docs-master/keybindings/Keybindings_ru.md @@ -230,7 +230,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` R `` | Переименовать ветку | | | `` u `` | View upstream options | View options relating to the branch's upstream e.g. setting/unsetting the upstream and resetting to the upstream. | | `` `` | Open external diff tool (git difftool) | | -| `` P `` | Push selected branch | Push the selected branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` P `` | Push selected branch | Push the selected branch to its upstream branch, after confirming. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Pull selected branch | Pull the selected branch's upstream branch into it, via its linked worktree. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` 0 `` | Focus main view | | | `` `` | Просмотреть коммиты | | diff --git a/docs-master/keybindings/Keybindings_zh-CN.md b/docs-master/keybindings/Keybindings_zh-CN.md index d112e3cca..10647ec09 100644 --- a/docs-master/keybindings/Keybindings_zh-CN.md +++ b/docs-master/keybindings/Keybindings_zh-CN.md @@ -247,7 +247,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` R `` | 重命名分支 | | | `` u `` | 查看上游选项 | 查看与分支上游相关的选项,例如设置/取消设置上游和重置为上游。 | | `` `` | 使用外部差异比较工具(git difftool) | | -| `` P `` | Push selected branch | Push the selected branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` P `` | Push selected branch | Push the selected branch to its upstream branch, after confirming. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Pull selected branch | Pull the selected branch's upstream branch into it, via its linked worktree. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` 0 `` | 聚焦主视图 | | | `` `` | 查看提交 | | diff --git a/docs-master/keybindings/Keybindings_zh-TW.md b/docs-master/keybindings/Keybindings_zh-TW.md index 556ef2e49..99018bbea 100644 --- a/docs-master/keybindings/Keybindings_zh-TW.md +++ b/docs-master/keybindings/Keybindings_zh-TW.md @@ -306,7 +306,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` R `` | 重新命名分支 | | | `` u `` | 檢視遠端設定 | 檢視有關遠端分支的設定(例如重設至遠端) | | `` `` | 開啟外部差異工具 (git difftool) | | -| `` P `` | Push selected branch | Push the selected branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` P `` | Push selected branch | Push the selected branch to its upstream branch, after confirming. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Pull selected branch | Pull the selected branch's upstream branch into it, via its linked worktree. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` 0 `` | Focus main view | | | `` `` | 檢視提交 | | diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index 7d5ad9899..a58c84615 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -440,7 +440,18 @@ func (self *BranchesController) press(selectedBranch *models.Branch) error { } func (self *BranchesController) push(branch *models.Branch) error { - return self.pushBranch(branch) + self.c.Confirm(types.ConfirmOpts{ + Title: self.c.Tr.PushSelectedBranch, + Prompt: utils.ResolvePlaceholderString( + self.c.Tr.PushSelectedBranchPrompt, + map[string]string{"selectedBranchName": branch.Name}, + ), + HandleConfirm: func() error { + return self.pushBranch(branch) + }, + }) + + return nil } func (self *BranchesController) pull(branch *models.Branch) error { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 51363f45e..3a359806a 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -67,6 +67,7 @@ type TranslationSet struct { PullTooltip string PushSelectedBranch string PushSelectedBranchTooltip string + PushSelectedBranchPrompt string PullSelectedBranch string PullSelectedBranchTooltip string PullFailedInOtherWorktree string @@ -1227,7 +1228,8 @@ func EnglishTranslationSet() *TranslationSet { Push: "Push", PushTooltip: "Push the current branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch.", PushSelectedBranch: "Push selected branch", - PushSelectedBranchTooltip: "Push the selected branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch.", + PushSelectedBranchTooltip: "Push the selected branch to its upstream branch, after confirming. If no upstream is configured, you will be prompted to configure an upstream branch.", + PushSelectedBranchPrompt: "Push branch '{{.selectedBranchName}}' to its upstream?", PullSelectedBranch: "Pull selected branch", PullSelectedBranchTooltip: "Pull the selected branch's upstream branch into it, via its linked worktree. If no upstream is configured, you will be prompted to configure an upstream branch.", PullFailedInOtherWorktree: "Switch to this branch's worktree to resolve the problem.",