cse190largecodebases / group-project-bit-converter

group-project-bit-converter created by GitHub Classroom
Other
0 stars 0 forks source link

Project Proposal #1: Git Configuration for Python IDLE #1

Open kencasimiro opened 1 year ago

kencasimiro commented 1 year ago

Project Title: Git Configuration for Python IDLE

Team Members: Eric Vu, A1400630 Kenneth Casimiro, A17132441 Michael Mao, A16038239

Project Summary: Our project aims to enhance the Python IDLE environment by implementing Git configurations. Git is a widely-used version control system that allows developers to track changes in their codebase, collaborate with others, and manage different versions of their projects. By integrating Git configurations into Python IDLE, users will have the ability to initialize and manage Git repositories directly within the IDLE environment.

With this implementation, users will be able to perform common Git operations, such as initializing a new repository, adding files, and committing changes, all from within the Python IDLE interface. This integration will streamline the development process and provide a convenient workflow for version control without needing to switch between the IDLE environment and a separate Git command-line interface.

By leveraging Git configurations within Python IDLE, developers will have access to the powerful features of Git while working on their Python projects, making it easier to collaborate, track changes, and manage their codebase effectively.

*Will be pursuing remote repository functionality after completing local repository functionality if there is time.

Project Outline:

  1. Setting up Development Team Environment
  1. Installation and understanding of GitPython library

  2. Integrating GitPython with Python IDLE (Back-End)

  3. Implementing Git Configurations Menu Option (Front-End)

  4. Implementing Git Features in Python IDLE with GitPython and their respective Menu Option(s) (Back-End)

  1. Testing and Validation
  2. Documentation and User Guide
  3. Possible future enhancements and expansion of the project
  4. Project Presentation and associated documents

Features:

Checkpoint Deliverables:

Checkpoint Deliverable 1: Project Setup and Git Configurations Menu Option Implementation Description: The first checkpoint deliverable focuses on setting up the development environment and implementing the Git configurations menu option in Python IDLE. It includes the installation of necessary libraries, integrating GitPython, and creating the menu option interface. Users will be able to access the menu option and navigate through the available sub-options, although the functionality of individual sub-options may not be fully implemented at this stage. Deliverable: At the first checkpoint, we will provide a working implementation of the Git Configurations menu option in Python IDLE. Users will be able to access the menu option, view the available sub-options, and navigate through them. However, the functionality of each sub-option may not be fully implemented at this stage.

Checkpoint Deliverable 2: Git Operations Description: The second checkpoint deliverable focuses on implementing core Git operations within the Git Configurations menu option and providing user feedback. This stage involves integrating Git commands, enabling users to perform common Git operations directly within Python IDLE. Additionally, error handling and informative user feedback will be incorporated to enhance the user experience during Git operations. Deliverable: At the second checkpoint, we will deliver a functional implementation of core Git operations within the Git Configurations menu option. Users will be able to perform operations such as repository initialization, file staging, committing changes, branching, pushing, pulling, and resolving conflicts directly within Python IDLE. Error handling and user feedback mechanisms will be in place to provide informative messages and guide users through the Git workflows. The implemented features will undergo comprehensive testing to ensure their reliability and robustness.

anshulshah99 commented 1 year ago

This one sounds good! Go ahead and do this one

anshulshah99 commented 1 year ago

Checkpoint 1: Great progress, looks like y'all are on a great track. Good management on the pull request.

Also just a generic reminder that we've giving to all groups about equal contributions!

kencasimiro commented 1 year ago

Progress Report: Source Control

I. Progress Update

We are making great progress into our implementation of source control using git for IDLE. The UI implementation has made progress on several features, including initializing/choosing a repository, adding a commit message, and displaying the repository status. However, there are two remaining UI features to be implemented: "git remove" and "git commit." With the back end development using GitPython, we only need to complete "git remove" and "git commit" as we were able to complete all of the other local git commands. Once that is finished, we will need to do quality of life improvements such as error checking, confirmation messages, unit testing, and demoing for bugs.


II. Challenges

Throughout the project, several challenges were encountered. One significant challenge was installing GitPython to work with the specific version of Python used in the project, rather than relying on the local Python installation. To overcome this, the solution involved downloading and using the get-pip.py file in the project directory to install pip for the respective Python version. Once pip was installed, GitPython could be installed using the command python -m pip install GitPython. After getting that to work, we were able to start implementing the back-end code for local git commands.

Another challenge involved understanding how to create UI objects using the tkinter library. To address this, the team explored the documentation and tutorials available for tkinter to gain a better understanding of its usage. By leveraging the resources provided, the team was able to learn how to create and customize UI elements such as windows, tabs, buttons, and text fields to match the desired design and functionality. Currently we have no more issues on developing the UI.

Utilizing GitPython effectively was another challenge faced during the project. The team had to familiarize themselves with the library's documentation and explore its features to understand how to interact with Git repositories programmatically. Through research, experimentation, and referencing the GitPython documentation, the team was able to leverage the library's capabilities to implement Git commands and manage repositories within the Python IDLE environment. Currently we only have two left to complete. These being git remove and git commit.

In addition to technical challenges, the team also faced scheduling conflicts and communication issues. These challenges were addressed by establishing clear communication channels and schedules for meetings and collaboration. Regular team meetings and effective communication helped ensure that everyone was on the same page, tasks were appropriately assigned and tracked, and any conflicts or issues were promptly addressed. We now have a set schedule per week to meet and to actively do a daily check in through our Discord server to talk about where we are at in our assigned tasks.

Due to the challenges faced during the project, we found it necessary to adjust the expectations outlined in the original proposal. Specifically, the scope of the project will be limited to local Git commands only, rather than incorporating advanced features like remote repository management or collaborative functionalities.

The local git commands that we will be implementing for our source control are the following:

By focusing on these local Git commands, the team can ensure a more achievable and successful implementation within the given constraints and time frame.


III. Remaining Work

To approach the remaining milestones, we will divide the tasks among team members and allocate dedicated time for each milestone. Here is our planned approach:

By allocating time and resources for each milestone and ensuring proper coordination among team members, we aim to complete the remaining tasks efficiently and deliver a functional and well-documented Source Control feature within the given project timeline.

kencasimiro commented 1 year ago

Design Document: Source Control

I. Project Description

Our project aims to enhance the Python IDLE environment by implementing local source control with Git. Git is a widely-used version control system that allows developers to track changes in their codebase, collaborate with others, and manage different versions of their projects. By integrating Git source control into Python IDLE, users will have the ability to initialize and manage Git repositories locally on their computers within the IDLE environment.

With this implementation, users will be able to perform common local Git operations, such as initializing a new repository, adding files, and committing changes, all from within the Python IDLE interface. This integration will streamline the development process and provide a convenient workflow for version control without needing to switch between the IDLE environment and a separate Git command-line interface.


II. Project UI

Before we started on the UI, we created wireframes of what our project would look like. Below, is our current wireframe of the Source Control. The design process for this menu was inspired by VSCode's implementation of Source Control. We wanted to have a main window which contained tabs for the following Git commands: Select Repository, Add, Remove, Commit and Status. For Select Repo., Add, and Remove, we decided to have new window open that prompts for the file path of the respective command when the user clicks on the button. As for the Commit command, we decided to have a new window open to prompt the user for a Commit Message. For the Status command, we chose to display the status within the same tab window for readability.

gitwireframe drawio

Source Control will be implemented as a tool in the menu options of Python IDLE. By opening IDLE and clicking on the Options menu, there will be an option for "Source Control". When the user clicks on this option, a new window will pop out that will allow the user to use Git as their source control.

Screenshot 2023-05-29 at 8 01 30 PM

In this window, there will be multiple tabs that will allow the user utilize the different "Git Commands" such as initializing their repository, staging their changes, and looking over their status. Currently we have set up the different tabs necessary for local Git command such as initializing a repository (selecting a repository), adding a change, committing the changes, and looking over the current status of your repository.

Screenshot 2023-05-29 at 6 56 45 PM

With our current progress, we have implemented what our UI will look like for initializing/choosing a repository and adding a commit message for their respective Git commands.

Screenshot 2023-05-29 at 2 36 15 AM Screenshot 2023-05-29 at 2 36 26 AM

Currently, we only have git remove and git commit left to do for UI side of things.


III. Project Implementation

There are two parts of our implementation. The first is to create a UI for the Source Control feature and the second being the backend code to implement the source control features using Git.

With the UI, we first looked at Project 2 and the code related to the feature of "Go To Line". We saw that this feature opened up a new window and was an option in the menu of PyShell. We wanted to recreate this for our projects UI. We created a separate python file called git.py where we will do all of our implementations. In this file, we created a class called SourceControlGUI that is a subclass of tkinter. This class when instantiated will create a new window. In the SourceControlGUI class, we created methods that will create the tab buttons for each respective git command, such as initialization, add, commit, etc. Within these methods, they also create the respective required UI features to do their commands. For example, git commit requires a text line in its tab window for a user to add their commit message.

Example of adding a tab to our UI: Screenshot 2023-05-29 at 3 25 35 AM

This is our current class diagram for SourceControlGUI: class_diagram

For the back-end implementation. We needed to figure out a way to use Git commands in Python code. Through our research, we found a library called GitPython that allows us to interact with git repositories, high-level like git-porcelain, or low-level like git-plumbing. Through this library we are able to create our project with pure python implementation for git commands.

More information about GitPython can be found here: GitPython

To install GitPython for our project. We first needed to download pip as we are not using our local python installation. To do this please do the following commands on terminal/command line.

Use the provided get-pip.py file in the same directory as ./python.exe in the project directory. Run ./.python.exe get-pip.py This will instal pip for our respective python version. Run ./python.exe -m pip install GitPython GitPython will be successfully installed and you can now do ./python.exe -m idlelib successfully.

Additionnaly you can do the following as well to download GitPython: ./python.exe -m ensurepip --upgrade ./python.exe -m pip install GitPython

After installing GitPython successfuly, we first implemented the git init command by creating a method in SourceControlGUI called perform_repo that will successfully do the command. As GitPython has a builtin method for initializing repositories, we instantiated an object of it and called its respective method. We first ask the user for the path to where their changes are being made to determine which repository to use for our source control. This will work with a bare repository or an already working one.

Code Implementation of git init: Screenshot 2023-05-29 at 3 33 56 AM

Git init examples with edge cases of an existing repo, initialize a new repo, and if given a file path rather than a folder/repository path:

Screenshot 2023-05-29 at 2 36 15 AM Screenshot 2023-05-30 at 12 17 14 AM Screenshot 2023-05-30 at 12 17 52 AM Screenshot 2023-05-30 at 12 30 21 AM

Our next implementation was git add, we did this by using the add method from GitPython. We added a text line in our UI that the user inputs for whatever file they wish to add to the staging area. Currently we are looking into how we can confirm their action/show an error if a file does not exist to our UI.

Here are a couple of screenshots of how our git add implementation looks. It is able to check if a file is not found, if a file has already been added to staging, and if a new/ old file has been added to the stage:

Screenshot 2023-05-29 at 11 50 28 PM Screenshot 2023-05-29 at 11 50 17 PM Screenshot 2023-05-29 at 11 55 48 PM Screenshot 2023-05-29 at 11 50 45 PM

Our next implementation was git remove, we did this by using the remove method from GitPython. We added a text line in the UI for user input for the file they wish to remove from staging area. The status of the remove function will appear in the source control menu in the respective tab.

Below are screenshots of our git remove implementation. The function is able to remove files that are in the staging area and check if a file does not exist.

Screen Shot 2023-05-30 at 4 22 24 PM Screen Shot 2023-06-01 at 9 01 13 PM

The final implementation we did for Checkpoint 2 is git status. We decided as a group to change how the UI works by including a built-in text window to display messages to our users rather than creating a new window. We did this by making the Source Control GUI create a text window at the start and then displaying messages whenever they do a git command. By pressing on Status, it will display the current repository status. If there is no repository selected, then it will display an error message in the text window.

Code Implementation of git status: Screenshot 2023-05-29 at 8 12 27 PM

UI of Git Status:

Screenshot 2023-05-29 at 7 36 52 PM Screenshot 2023-05-29 at 7 37 18 PM

For our final implementation we did git commit. We attempted to do this with GitPython like our previous implementations but for some reason it kept crashing tkinter windows when we did the GitPython commit method.

Screenshot 2023-06-07 at 1 57 27 PM

Therefore, rather than spending a tremendous amount of time debugging, we looked at a different approach by using subprocesses. By doing this, tkinter did not crash and we were able to implement the functionality of git commit.

Screenshot 2023-06-07 at 2 03 50 PM

Example of git commit being successful:

Screenshot 2023-06-07 at 3 12 53 PM

Example of git commit not having any commits to commit:

Screenshot 2023-06-07 at 3 13 05 PM

IV. Work In Progress (WIP)

Our next implementations will be revamping the unit tests.

anshulshah99 commented 1 year ago

Awesome progress so far. I mentioned this to Ken in OH but I think you can focus on making this useful to the user! Maybe have some way to automatically get the filename so that we don't have to input the entire path

kencasimiro commented 1 year ago

Final Progress Report: Source Control

I. Progress Update

After Checkpoint 2, we made significant progress in implementing the remaining features for source control using Git in IDLE. With the help of GitPython for the backend development, we successfully implemented the "git remove" and "git commit" functionalities, which were the final UI features pending completion. These additions allowed users to remove files from the repository and create commits with commit messages, enabling them to manage their project versions effectively.

With the UI implemented, we implemented and finalized their respective git commands. We made sure they all worked together and that we had a proper local source control system in IDLE. We then shifted our focus towards enhancing the user experience and ensuring the stability of the application. We started by implementing error checking mechanisms to handle various scenarios, such as invalid inputs or conflicts during operations. Additionally, we introduced confirmation messages to provide users with feedback and reduce the chances of accidental actions.

To ensure the reliability of our implementation, we conducted comprehensive unit testing on all the implemented features. This helped us identify and fix any issues or edge cases that might have arisen during the development process. By incorporating these unit tests, we were able to complete our project before the deadline.


II. Challenges

During our final push to meet the deadline, we encountered a couple of challenges that required creative problem-solving. One major hurdle was the implementation of the GitPython "git commit" functionality, which unexpectedly caused tkinter to crash. To overcome this issue, we decided to explore an alternative approach by utilizing the subprocess library to execute the "git commit" command externally. This involved invoking the Git command line interface (CLI) directly from within our application, bypassing the tkinter-related crashes. By leveraging subprocess, we were able to ensure the smooth execution of the "git commit" operation without compromising the stability of our UI.

image

Another challenge we tackled was the need to create temporary files and folders for our unit tests. Previously, we had hardcoded specific files and directories for testing purposes, which proved to be inefficient and cumbersome. To address this, we implemented a mechanism to dynamically generate temporary files and folders during the unit testing process. By automating this process, we improved the efficiency of our tests and made them more adaptable to different scenarios. This approach not only streamlined our testing workflow but also allowed for greater flexibility and maintainability of our codebase.

image

Overall, these challenges required us to think outside the box and explore alternative solutions. By leveraging subprocess for the "git commit" functionality and implementing dynamic generation of temporary files and folders, we were able to overcome these obstacles and ensure the successful completion of our project within the given deadline.


III. Remaining Work

Although there is no more remaining work, there is future work and improvements. Looking ahead, there are several exciting avenues for future work and improvements to our source control project. One key aspect is the implementation of additional Git commands, such as branching and logging. Branching allows users to work on multiple versions of their project concurrently, enabling parallel development and experimentation. Incorporating this feature would provide users with greater flexibility and control over their codebase. Similarly, implementing logging functionality would enable users to track and review the history of commits, facilitating better project management and collaboration.

Another crucial area for expansion is the integration of online repositories, particularly popular platforms like GitHub. By connecting our source control system to online repositories, we can empower users to seamlessly synchronize their local repositories with remote counterparts. This would enable features such as push and pull requests, facilitating efficient collaboration with teammates and leveraging the robust ecosystem of tools and services provided by online Git platforms.

Furthermore, to complement these new additions, we envision enhancing the UI to offer a more interactive and intuitive experience. Introducing visual representations of branches, commit history graphs, and merge operations would provide users with a clearer understanding of their project's structure and evolution. Additionally, incorporating features like pull-down menus, drag-and-drop functionality, and keyboard shortcuts can streamline user interactions, making the overall experience more efficient and user-friendly.

kencasimiro commented 1 year ago

Final Design Document: Source Control

I. Project Description

Our project aims to enhance the Python IDLE environment by implementing local source control with Git. Git is a widely-used version control system that allows developers to track changes in their codebase, collaborate with others, and manage different versions of their projects. By integrating Git source control into Python IDLE, users will have the ability to initialize and manage Git repositories locally on their computers within the IDLE environment.

With this implementation, users will be able to perform common local Git operations, such as initializing a new repository, adding files, and committing changes, all from within the Python IDLE interface. This integration will streamline the development process and provide a convenient workflow for version control without needing to switch between the IDLE environment and a separate Git command-line interface.


II. Project UI

Before we started on the UI, we created wireframes of what our project would look like. Below, is our current wireframe of the Source Control. The design process for this menu was inspired by VSCode's implementation of Source Control. We wanted to have a main window which contained tabs for the following Git commands: Select Repository, Add, Remove, Commit and Status. For Select Repo., Add, and Remove, we decided to have new window open that prompts for the file path of the respective command when the user clicks on the button. As for the Commit command, we decided to have a new window open to prompt the user for a Commit Message. For the Status command, we chose to display the status within the same tab window for readability.

gitwireframe drawio

Source Control will be implemented as a tool in the menu options of Python IDLE. By opening IDLE and clicking on the Options menu, there will be an option for "Source Control". When the user clicks on this option, a new window will pop out that will allow the user to use Git as their source control.

Screenshot 2023-05-29 at 8 01 30 PM

In this window, there will be multiple tabs that will allow the user utilize the different "Git Commands" such as initializing their repository, staging their changes, and looking over their status. Currently we have set up the different tabs necessary for local Git command such as initializing a repository (selecting a repository), adding a change, committing the changes, and looking over the current status of your repository.

Screenshot 2023-05-29 at 6 56 45 PM

With our current progress, we have implemented what our UI will look like for initializing/choosing a repository and adding a commit message for their respective Git commands.

Screenshot 2023-05-29 at 2 36 15 AM Screenshot 2023-05-29 at 2 36 26 AM

Currently, we only have git remove and git commit left to do for UI side of things.


III. Project Implementation

There are two parts of our implementation. The first is to create a UI for the Source Control feature and the second being the backend code to implement the source control features using Git.

With the UI, we first looked at Project 2 and the code related to the feature of "Go To Line". We saw that this feature opened up a new window and was an option in the menu of PyShell. We wanted to recreate this for our projects UI. We created a separate python file called git.py where we will do all of our implementations. In this file, we created a class called SourceControlGUI that is a subclass of tkinter. This class when instantiated will create a new window. In the SourceControlGUI class, we created methods that will create the tab buttons for each respective git command, such as initialization, add, commit, etc. Within these methods, they also create the respective required UI features to do their commands. For example, git commit requires a text line in its tab window for a user to add their commit message.

Example of adding a tab to our UI: Screenshot 2023-05-29 at 3 25 35 AM

This is our current class diagram for SourceControlGUI: class_diagram

For the back-end implementation. We needed to figure out a way to use Git commands in Python code. Through our research, we found a library called GitPython that allows us to interact with git repositories, high-level like git-porcelain, or low-level like git-plumbing. Through this library we are able to create our project with pure python implementation for git commands.

More information about GitPython can be found here: GitPython

To install GitPython for our project. We first needed to download pip as we are not using our local python installation. To do this please do the following commands on terminal/command line.

Use the provided get-pip.py file in the same directory as ./python.exe in the project directory. Run ./.python.exe get-pip.py This will instal pip for our respective python version. Run ./python.exe -m pip install GitPython GitPython will be successfully installed and you can now do ./python.exe -m idlelib successfully.

Additionnaly you can do the following as well to download GitPython: ./python.exe -m ensurepip --upgrade ./python.exe -m pip install GitPython

After installing GitPython successfuly, we first implemented the git init command by creating a method in SourceControlGUI called perform_repo that will successfully do the command. As GitPython has a builtin method for initializing repositories, we instantiated an object of it and called its respective method. We first ask the user for the path to where their changes are being made to determine which repository to use for our source control. This will work with a bare repository or an already working one.

Code Implementation of git init: Screenshot 2023-05-29 at 3 33 56 AM

Git init examples with edge cases of an existing repo, initialize a new repo, and if given a file path rather than a folder/repository path:

Screenshot 2023-05-29 at 2 36 15 AM Screenshot 2023-05-30 at 12 17 14 AM Screenshot 2023-05-30 at 12 17 52 AM Screenshot 2023-05-30 at 12 30 21 AM

Our next implementation was git add, we did this by using the add method from GitPython. We added a text line in our UI that the user inputs for whatever file they wish to add to the staging area. Currently we are looking into how we can confirm their action/show an error if a file does not exist to our UI.

Here are a couple of screenshots of how our git add implementation looks. It is able to check if a file is not found, if a file has already been added to staging, and if a new/ old file has been added to the stage:

Screenshot 2023-05-29 at 11 50 28 PM Screenshot 2023-05-29 at 11 50 17 PM Screenshot 2023-05-29 at 11 55 48 PM Screenshot 2023-05-29 at 11 50 45 PM

Our next implementation was git remove, we did this by using the remove method from GitPython. We added a text line in the UI for user input for the file they wish to remove from staging area. The status of the remove function will appear in the source control menu in the respective tab.

Below are screenshots of our git remove implementation. The function is able to remove files that are in the staging area and check if a file does not exist.

Screen Shot 2023-05-30 at 4 22 24 PM Screen Shot 2023-06-01 at 9 01 13 PM

The final implementation we did for Checkpoint 2 is git status. We decided as a group to change how the UI works by including a built-in text window to display messages to our users rather than creating a new window. We did this by making the Source Control GUI create a text window at the start and then displaying messages whenever they do a git command. By pressing on Status, it will display the current repository status. If there is no repository selected, then it will display an error message in the text window.

Code Implementation of git status: Screenshot 2023-05-29 at 8 12 27 PM

UI of Git Status:

Screenshot 2023-05-29 at 7 36 52 PM Screenshot 2023-05-29 at 7 37 18 PM

For our final implementation we did git commit. We attempted to do this with GitPython like our previous implementations but for some reason it kept crashing tkinter windows when we did the GitPython commit method.

Screenshot 2023-06-07 at 1 57 27 PM

Therefore, rather than spending a tremendous amount of time debugging, we looked at a different approach by using subprocesses. By doing this, tkinter did not crash and we were able to implement the functionality of git commit.

Screenshot 2023-06-07 at 2 03 50 PM

Example of git commit being successful:

Screenshot 2023-06-07 at 3 12 53 PM

Example of git commit not having any commits to commit:

Screenshot 2023-06-07 at 3 13 05 PM

Unit Tests

For our unit tests, we created a separate file called test_git.py and within this file contains the unit tests for each of the functions of our Source Control Menu. In the file, it contains comments for each test case and the expected behavior. Here is a screenshot of the unit tests successfully running. We used the Python library tempfile to create the temporary directories and files in order to prevent creating and deleting files from users' system.

Screenshot 2023-06-12 at 8 51 41 PM

We did encounter some issues with the coverage report therefore leading to the low coverage percentage. Here is a screenshot of the error we encountered. We did try some solutions such as including a __init__.py file in the project and test directory but encountered the same error. image