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

'user' section of config exists for sections() but not items methods #1711

Open
pushfoo opened this issue Oct 16, 2023 · 3 comments
Open

'user' section of config exists for sections() but not items methods #1711

pushfoo opened this issue Oct 16, 2023 · 3 comments

Comments

@pushfoo
Copy link

pushfoo commented Oct 16, 2023

This appears to work fine:

>>> reader = repo_instance.config_reader()
>>> reader.sections()
['filter "lfs"', 'core', 'user']

However, these do not:

>>> reader.items('user')
NoSectionError: "No section: 'user'"

>>> reader.items_all('user')
KeyError: 'user'

I've confirmed the section exists in the repo's local .git/config as follows:

[user]
        name = pushfoo
        email = [email protected]

If this is due to misuse on my part, please let me know how. I'd be willing to try to make a PR to do the following:

  1. Make the exceptions more consistent
  2. Update relevant doc to be clearer
  3. Fix underlying bugs

Depending on how far down into git's internals I need to go, the last option may require some guidance from project leads.

EDIT: Version info:

Detail Value Comments
Python Version 3.9.2 Stock for Debian 11
Git version 2.30.2 Stock for Debian 11
OS / version Debian 11 No major customization have been applied
GitPthon version 3.1.37 default for pip install
gitdb version 4.0.10 default installed by above
@Byron
Copy link
Member

Byron commented Oct 16, 2023

Interesting! I'd also expect this to work particularly since its talking about section: 'user' not being present even though it is present.

I don't know what's expected though as it seems impossible to find items or items_all in the generated documentation, one would probably have to check in the source code or find tests for these. Thanks for considering to contribute!

@pushfoo
Copy link
Author

pushfoo commented Oct 16, 2023

Thank you for the quick initial response! I've added some version info to the issue.

  1. Can you confirm it as broken on your system?

  2. one would probably have to check in the source code

    Are there any specific directions you'd suggest investigating?

The first things that come to mind for me are:

  • Whether other repo-level sections work
  • Whether it's this specific project's repo or all of them
  • Whether changing git config values at other levels still gets picked up
  • Whether ConfigReader is broken in general, or just when attached to a repo object
  • Did any assumptions change since the code was written?
    • default location / name of the config files
    • default git config format

I'll try to look into the items over the coming hours / days.

or find tests for these.

If you need new tests or doc improvement help, I'd be willing to try as time allows. 👍

@Byron
Copy link
Member

Byron commented Oct 16, 2023

I can't confirm it as I didn't try. If it doesn't work for you it's a reason to look into the matter.

I'd check for config.py and test_config.py for hints on how the API is supposed to work, or what's tested. Maybe add a test and see if it reproduces there as well.

Good luck (even though you probably won't need it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants