Skip to content

Reading and writing global configuration parameters #775

Description

@andy-shev

There is no way to get global configuration parameters without Repo object.
config_reader() must be repository independent. So does config_writer() and accompanying methods.

Simplest (and ugly) hack is to allow path=None in Repo().

Activity

  1. Byron commented on Jul 15, 2018

    @Byron
    Member

    Thanks for letting us know! Out of the back of my head, no simpler solution comes to mind.

  2. andy-shev commented on Jul 5, 2019

    @andy-shev
    Author

    Better workaround if anybody is interested.

    import git
    import os
    
    class GitConfig(git.Repo):
        def __init__(self, *args, **kwargs):
            #
            # Work around the GitPython issue #775
            # https://github.com/gitpython-developers/GitPython/issues/775
            #
            self.git_dir = os.path.join(os.getcwd(), ".git")
            git.Repo.__init__(self, *args, **kwargs)
    

    Usage:

    r = GitConfig().config_reader()
    print (r.get_value('user', 'name'))
    
  3. benthayer commented on Oct 11, 2019

    @benthayer
    Contributor

    @andy-shev Thank you! Solution worked for me too.

    @Byron Are you open to PRs? It seems like this is mostly a matter of where to put the relevant code. If I figure out something logical, can I submit a PR and we discuss from there?

  4. Byron commented on Oct 15, 2019

    @Byron
    Member

    @bthayer2365 Absolutely, GitPython runs on PRs! Thanks for your participation :).

  5. added this to the v3.0.5 - Bugfixes milestone on Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions