Skip to content

not enough lines in _set_cache method #842

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

Closed
ret2libc opened this issue Feb 13, 2019 · 1 comment
Closed

not enough lines in _set_cache method #842

ret2libc opened this issue Feb 13, 2019 · 1 comment

Comments

@ret2libc
Copy link

There is a list index out of range when printing the tag message of systemd repository

Reproducer:
clone systemd repository with `git clone https://github.com/systemd/systemd.git'

from git import Repo
r = Repo('./systemd')
t = r.tags['060']
if t.tag is not None:
    print(t.tag.message)
IndexError                                Traceback (most recent call last)
<ipython-input-15-462f7dbfed04> in <module>()
----> 1 t.tag.message

/usr/lib/python3.7/site-packages/gitdb/util.py in __getattr__(self, attr)
    254         to be created and set. Next time the same attribute is reqeusted, it is simply
    255         returned from our dict/slots. """
--> 256         self._set_cache_(attr)
    257         # will raise in case the cache was not created
    258         return object.__getattribute__(self, attr)

/usr/lib/python3.7/site-packages/git/objects/tag.py in _set_cache_(self, attr)
     60             self.tag = lines[2][4:]  # tag <tag name>
     61 
---> 62             tagger_info = lines[3]  # tagger <actor> <date>
     63             self.tagger, self.tagged_date, self.tagger_tz_offset = parse_actor_and_date(tagger_info)
     64 

IndexError: list index out of range
@Byron
Copy link
Member

Byron commented Jul 6, 2019

Thanks for this fantastic issue! I could easily reproduce it!
And I hope someone will have some time to dig deeper and figure out what this particular tag message is all about.

Here is the output of git cat-file which is what GitPython would see and parse:

➜  systemd git:(master) git cat-file tag 060
object 281c368b8f00fbe70ea45c3c5f8d152ae7f1e077
type commit
tag 060

And I think this shows the root of the issue - there simply is no tagger information, which is supposed to be on the next line.

@ghost ghost closed this as completed in c73b239 Jul 6, 2019
@Byron Byron added this to the v2.1.12 - Bugfixes milestone Jul 6, 2019
This issue was closed.
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