Skip to content

Cannot bind new attribute to git.objects.commit.Commit #967

Description

@timblaktu

I am trying to add an attribute to a git.objects.commit.Commit object that I obtained from a repo.iter_commits call,

    commits = repo.iter_commits(args.from_commit_ref + ".." + args.to_commit_ref)
    for commit in commits:
        setattr(commit, "href", "<somestring>")) 

and I'm getting this error:

        setattr(commit, "href", os.path.join(diffhtmlpath, commit.binsha + ".html"))
AttributeError: 'Commit' object has no attribute 'href'

I understand these objects are wrappers, but can you provide some more info on whether what I'm trying to do is possible? I am trying to reuse these commit objects for a later purpose by inserting info in them. If this is not possible, I will have to make copies of the pertinent commit info I need into new objects and use those. I thought I'd check here is the former was possible using GitPython primitives.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions