Skip to content

Commit

Permalink
add branch to delete-commit window
Browse files Browse the repository at this point in the history
  • Loading branch information
forgottosave committed Dec 3, 2024
1 parent 5c3c34e commit 10e376b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/core/OSTreeTUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ OSTreeTUI::OSTreeTUI(const std::string& repo, const std::vector<std::string>& 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) {
Expand Down
10 changes: 6 additions & 4 deletions src/core/commit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down

0 comments on commit 10e376b

Please sign in to comment.