Skip to content

Conversation

@viswajith-ks
Copy link
Contributor

@viswajith-ks viswajith-ks commented Oct 3, 2025

Closes #19

Hi! This PR is ready for review and implements the command history and logging feature.

Changes Implemented

  • File-Based Logging: A new logger package now writes all executed git commands and errors to ~/.gitx.log for debugging.
  • Command History Panel: User-initiated git commands are now displayed in real-time in the [6] Command History panel. The history is session-based and clears on restart.
  • Centralized Command Execution: A significant part of this work involved refactoring all git operations in the internal/git package to use a single, central executeCommand method. This was done to ensure all commands could be logged consistently and to make the code more maintainable going forward.

A Note on the Refactor

As this is my first major contribution to the project, I wanted to be thorough. I noticed that logging would require touching every git command, so I opted to centralize the command execution logic first. This ended up touching most of the files in the internal/git directory.

My goal was to follow the existing patterns in the codebase while making the new feature robust. I'm especially eager for any feedback you have on this approach, and I'm happy to make any changes or discuss it further.

Thanks for the opportunity to contribute!

Replaced all direct calls to 'exec.Command' throughout the 'internal/git'
package with a single, central 'executeCommand' method.

This ensures all git operations are now consistently logged to the
application log file for easier debugging.

Signed-off-by: Viswaijth K S <[email protected]>
Adds a file-based logger for debugging and displays a real-time, session-based command history in the secondary panel.
@viswajith-ks viswajith-ks marked this pull request as ready for review October 4, 2025 05:31
@viswajith-ks viswajith-ks marked this pull request as draft October 4, 2025 05:34
@bakayu
Copy link
Member

bakayu commented Oct 5, 2025

Please mark the PR as ready for review when you think you are done with the implementation, if you feel stuck feel free to reach out.

@viswajith-ks viswajith-ks marked this pull request as ready for review October 6, 2025 17:40
@bakayu
Copy link
Member

bakayu commented Oct 7, 2025

Hello @viswajith-ks
While testing your changes, I noticed a few things:

  1. The history was recorded for staging/unstaging files but it did not record the history when a "commit" was made
image
  1. It recorded the history for checking out to a branch but not for deleting or creating a new branch.
image
  1. History does not record any commands from the Commits Panel.

@bakayu
Copy link
Member

bakayu commented Oct 7, 2025

I will mark this PR as a draft, you can mark it as ready for review when the issues I raised above have been addressed.

@bakayu bakayu marked this pull request as draft October 7, 2025 11:08
@viswajith-ks
Copy link
Contributor Author

thanks for the reply! will work on it

@viswajith-ks
Copy link
Contributor Author

image image

branch related commands, commits and commit panel related commands now correctly logs into the command history panel. if the commands fail errors are also logged into the same panel.

@viswajith-ks viswajith-ks marked this pull request as ready for review October 7, 2025 17:34
@bakayu
Copy link
Member

bakayu commented Oct 9, 2025

Hi, sorry for the late response, I will check the changes out and update you soon.

Copy link
Member

@bakayu bakayu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one change I would like you to address, right now as indicated by your screenshot if there is an error it logs the full error in a long line that goes out of scope, make it so that only the useful part of the error is logged and not the whole trace.

For Example, Instead of:

Error: stash operation failed: exit status 128: fatal: log for 'stash' only has 1 entries

It could say something like:

[ERROR - 128] fatal: log for 'stash' only has 1 entries

Things to note:

  • The error block [ERROR - 128] should be colored, add a field for that in the themes struct in themes.go and probably use red or bright red as the color, it should stand out in the logs.

Follow any such pattern so that its easier to read the error output and the history does not become cluttered,


Some Other changes:

  • There should be a newline between each command log.
  • In your implementation the history logs goes from top to bottom, that is a new log is added at the bottom, it would be easier for the user to follow if it were the opposite, new logs should be added to the top.

@viswajith-ks viswajith-ks force-pushed the feature/command-history branch from b13345e to 8b83f65 Compare October 9, 2025 17:37
@viswajith-ks
Copy link
Contributor Author

the requested changes: error formatting, newline separator and history order have been made. thanks for being patient with me

@bakayu bakayu merged commit 1a7bdcf into gitxtui:master Oct 9, 2025
2 checks passed
@bakayu bakayu added the hacktoberfest-accepted This PR is accepted under the hacktoberfest challenge label Oct 9, 2025
@bakayu
Copy link
Member

bakayu commented Oct 9, 2025

@viswajith-ks Thank you for the contribution! ^^

@bakayu bakayu mentioned this pull request Oct 9, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted This PR is accepted under the hacktoberfest challenge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] - Command History and Logging

2 participants