From 10e376b4c0ecd5db2f4d7b7ae5979f692dfdd40b Mon Sep 17 00:00:00 2001 From: Timon Ensel Date: Tue, 26 Nov 2024 17:39:02 +0100 Subject: [PATCH] add branch to delete-commit window --- src/core/OSTreeTUI.cpp | 4 +++- src/core/commit.cpp | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/core/OSTreeTUI.cpp b/src/core/OSTreeTUI.cpp index ff92e8f..6db062f 100644 --- a/src/core/OSTreeTUI.cpp +++ b/src/core/OSTreeTUI.cpp @@ -119,7 +119,9 @@ OSTreeTUI::OSTreeTUI(const std::string& repo, const std::vector& st } // start commit deletion window if (event == Event::AltD) { - SetViewMode(ViewMode::COMMIT_DROP, visibleCommitViewMap.at(selectedCommit)); + std::string hashToDrop = visibleCommitViewMap.at(selectedCommit); + SetViewMode(ViewMode::COMMIT_DROP, hashToDrop); + SetModeBranch(GetOstreeRepo().getCommitList().at(hashToDrop).branch); } // copy commit id if (event == Event::AltC) { diff --git a/src/core/commit.cpp b/src/core/commit.cpp index 068da51..5456f02 100644 --- a/src/core/commit.cpp +++ b/src/core/commit.cpp @@ -268,6 +268,8 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions { // drop commit if (event.mouse().y > ostreetui.GetScreen().dimy() - 8) { ostreetui.SetViewMode(ViewMode::COMMIT_DROP, hash); + ostreetui.SetModeBranch( + ostreetui.GetOstreeRepo().getCommitList().at(hash).branch); top() = drag_initial_y; } // check if position matches branch & do something if it does @@ -405,7 +407,7 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions { // deletion view, commit is at head of branch Component deletionViewHead = Container::Vertical( {Renderer([&] { - return vbox({text(""), text(" Remove Commit...") | bold, text(""), + return vbox({text(" Remove Commit...") | bold, text(""), hbox({ text(" ✖ ") | color(Color::Red), text(hash.substr(0, 8)) | bold | color(Color::Red), @@ -422,14 +424,14 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions { Component deletionViewBody = Container::Vertical( {Renderer([&] { std::string parent = ostreetui.GetOstreeRepo().getCommitList().at(hash).parent; - return vbox({text(""), text(" Remove Commits...") | bold, text(""), + return vbox({text(" Remove Commit (and preceding)...") | bold, text(""), text(" ☐ " + ostreetui.GetModeBranch()) | dim, text(" │") | dim, hbox({ text(" ✖ ") | color(Color::Red), text(hash.substr(0, 8)) | bold | color(Color::Red), }), - parent.empty() - ? text(" ✖ ") | color(Color::Red) + parent == "(no parent)" + ? text("") : vbox({ text(" ✖ " + parent.substr(0, 8)) | color(Color::Red), text(" ✖ ...") | color(Color::Red),