DEV Community

Ajo George
Ajo George

Posted on

Git Rebase and DocBot Refactoring

Introduction

Well moving over to week 5 we updated our DocBot to release 0.3,This doesn't include any new addition but refactoring our old code, so that it easy to manage improve readability and so on.

The requirements for this week lab was to add three refactoring, which i will discuss in the blog later on, then we were asked to make use of git rebase so that all of our refactoring emerge as a single commit on the main.

Refactoring Code No 1

Added a new file called arg_parser.py this file will include all the necessary CLI argument's that the user gives in the CLI, for example -t,-h etc. It will allow us to clean up the main, and we can easily manage them from this separate file.

Refactoring Code No 2

For this i removed all the global variables from main, which was not that difficult so i included an another update in this same commit which included changing everything to functions. For example :

# Function to display the tool's version
def show_version(tool_name, tool_version):
    print(f"{tool_name}, version {tool_version}")
Enter fullscreen mode Exit fullscreen mode

Refactoring Code No 3

In this last addition i made a new file called file_handler.py, the main focus for this addition was to separate command-line argument parsing from file parsing from AI management from output.

GitRebase

We had clear instructions how to use GitRebase, i haven't used git rebase that much, this week topic provided ideas for that, also i never knew that git had an interactive mode, I guess everything has a first time right ?

Conclusion

Like i said this week was fun, learned lot of new things, importance of code clarity and new tools and command in GitHub, especially the squash and interactive menu.

AJO GEORGE 10-10-2024

Top comments (0)