diff --git a/src/core/OSTreeTUI.cpp b/src/core/OSTreeTUI.cpp index 2d1bc1e..6bfa158 100644 --- a/src/core/OSTreeTUI.cpp +++ b/src/core/OSTreeTUI.cpp @@ -271,7 +271,9 @@ bool OSTreeTUI::DropLastCommit(const cpplibostree::Commit& commit) { selectedCommit = 0; screen.PostEvent(ftxui::Event::AltR); notificationText = - "Removed commit " + commit.hash.substr(0, 8) + " from branch " + commit.branch; + "Dropped commit " + commit.hash.substr(0, 8) + " from branch " + commit.branch; + } else { + notificationText = "Failed to drop commit"; } return success; } diff --git a/src/util/cpplibostree.cpp b/src/util/cpplibostree.cpp index 79a1654..e632c35 100644 --- a/src/util/cpplibostree.cpp +++ b/src/util/cpplibostree.cpp @@ -1,6 +1,7 @@ #include "cpplibostree.hpp" // C++ +#include #include #include #include @@ -338,7 +339,13 @@ bool OSTreeRepo::PromoteCommit(const std::string& hash, /// TODO This implementation should not rely on the ostree CLI -> change to libostree usage. bool OSTreeRepo::DropLastCommit(const Commit& commit) { - // TODO check if it is last commit on branch + // check if it is last commit on branch + auto it = std::find_if( + commitList.begin(), commitList.end(), + [&](std::pair c) { return c.second.branch == commit.branch; }); + if (it == commitList.end() || commit.hash != it->second.hash) { + return false; + } // reset head std::string command = "ostree reset";