Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert check_ref_format to class method #283

Closed
wants to merge 2 commits into from

Conversation

amritghimire
Copy link

Refactored the check_ref_format function in dulwich/init.py to a class method for more flexibility and to allow calling it without instantiating the class. This simplifies the usage of this method while maintaining existing functionality.

More context for this is at https://github.com/iterative/studio/pull/8187#issuecomment-1804589654

Refactored the check_ref_format function in dulwich/__init__.py to a class method for more flexibility and to allow calling it without instantiating the class. This simplifies the usage of this method while maintaining existing functionality.

More context for this is at iterative/studio#8187 (comment)
@amritghimire amritghimire added the enhancement New feature or request label Nov 10, 2023
@amritghimire amritghimire self-assigned this Nov 10, 2023
@pmrowla
Copy link
Contributor

pmrowla commented Nov 10, 2023

If we want to make this a classmethod, it should be a classmethod in the base backend abstract class and in all of the implementations, and top level scmrepo.git.Git would really also need a way to call an appropriate backend classmethod (so the scmrepo user/caller should only need to do Git.check_ref_format and then it would pick an appropriate Backend.check_ref_format to use)

But honestly IMO it's not a problem for studio to just call dulwich.refs.check_ref_format directly in this situation

Adjusted the formatting and indentation of several blocks of code across the files git/backend/gitpython.py, git/backend/pygit2/__init__.py, and git/backend/base.py to increase readability and maintain code cleanliness. Also, refactored the 'check_ref_format' function in git/backend/gitpython.py and git/backend/base.py to be a class method, thus allowing it to be called without an instance of the class. This change allows for more flexibility when using this method, while still preserving its original functionality.
@amritghimire
Copy link
Author

Closing this for now. @shcheklein Feel free to takeover if you think this is necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants