Skip to content

orc update crashes with AttributeError if ~/.gitconfig contains an includeIf directive with hasconfig:remote.*.url:... #64

Description

@frereit

When executing orc update, an AttributeError: 'NoneType' object has no attribute 'group' is thrown here:

base_url = os.path.dirname(match.group("url"))

when the user git configuration contains something like this:

[includeIf "hasconfig:remote.*.url:https://example.com*/**"]
        path = .gitconfig-example

in their ~/.gitconfig file. This happens, because orchestra runs git -C .orchestra config --get-regexp 'remote\.[^.]*\.url', which outputs these configuration directives, because they match the remote\.[^.]*\.url regex:

includeif.hasconfig:remote.*.url:https://example.com*/**.path .gitconfig-example
remote.origin.url https://github.com/revng/orchestra

Subsequently, the regex mactch of remote\.(?P<name>[^.]*)\.url (?P<url>.*)$ on the first line fails, causing match to become None.

remotes_re = re.compile(r"remote\.(?P<name>[^.]*)\.url (?P<url>.*)$")
remotes = {}
for line in git_output.splitlines(keepends=False):
match = remotes_re.match(line)

A quick-fix would be to just discard lines that don't match:

if match is None:
    continue

But imho the general approach should be reconsidered. This seems very britle, as it relies on multiple regular expressions and a subprocess invocation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions