drewdeponte / git-ps-rs

Official git-ps Rust implementation - the future of git-ps
https://git-ps.sh
MIT License
78 stars 8 forks source link

Add support for in rebase gps listing #279

Closed drewdeponte closed 9 months ago

drewdeponte commented 9 months ago

The intention with this is to facilitate users running gps list while in the middle of a rebase and being presented with useful information about the current state that they are in. For example it should show which patches have been played and which ones are planned to be played, and their associated statuses.

To accomplish this there is a decent amount of work that was needed. We effectively had to implement our own functionality to read the file system state that Git manages during rebases and interpret it so that we can have the necessary information to be able to present to the user about the rebase underway.

This included adding the git::in_rebase function to determine if the user is currently in the middle of a rebase. Adding the RebaseTodoCommand enum to represent rebase todo items. Rebase todo items are line items that Git keeps track of during the rebase to keep track of which patches have been played already and which ones are still to be played. Hence, the name todo.

It also included adding the line_to_rebase_todo() function and the str_to_rebase_todos() function to facilitate parsing the lines of these todo file content into a Vec.

Beyond that it includes the addition of the in_rebase_head_name() function to obtain the head reference name currently being rebased. As well as the in_rebase_done_todos() function to obtain the already played commits in the current rebase, and the in_rebase_todos() function to obtain the not yet played commits in the current rebase.