sphinx-contrib / sphinxcontrib-versioning

Sphinx extension that allows building versioned docs for self-hosting.
https://sphinxcontrib-versioning.readthedocs.io/en/latest/
MIT License
125 stars 81 forks source link

"IndexError: list index out of range" crash in case of big merge commits are in the git tree #71

Open aivus opened 4 years ago

aivus commented 4 years ago

Sometimes I'm getting errors like this:

Traceback (most recent call last):
  File "/Users/aivus/envs/oro-doc-version/bin/sphinx-versioning", line 11, in <module>
    load_entry_point('sphinxcontrib-versioning', 'console_scripts', 'sphinx-versioning')()
  File "/Users/aivus/envs/oro-doc-version/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/aivus/projects/sphinxcontrib-versioning2/sphinxcontrib/versioning/__main__.py", line 78, in main
    return super(ClickGroup, self).main(args=argv, *args, **kwargs)
  File "/Users/aivus/envs/oro-doc-version/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/aivus/projects/sphinxcontrib-versioning2/sphinxcontrib/versioning/__main__.py", line 89, in invoke
    return super(ClickGroup, self).invoke(ctx)
  File "/Users/aivus/envs/oro-doc-version/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/aivus/envs/oro-doc-version/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/aivus/envs/oro-doc-version/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/aivus/envs/oro-doc-version/lib/python2.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/aivus/envs/oro-doc-version/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/aivus/projects/sphinxcontrib-versioning2/sphinxcontrib/versioning/__main__.py", line 276, in build
    remotes = gather_git_info(config.git_root, conf_rel_paths, config.whitelist_branches, config.whitelist_tags)
  File "/Users/aivus/projects/sphinxcontrib-versioning2/sphinxcontrib/versioning/routines.py", line 66, in gather_git_info
    dates_paths = filter_and_date(root, conf_rel_paths, (i[0] for i in remotes))
  File "/Users/aivus/projects/sphinxcontrib-versioning2/sphinxcontrib/versioning/git.py", line 246, in filter_and_date
    dates_paths[commit][0] = timestamps[i]
IndexError: list index out of range

It's caused by the output of the git command https://github.com/sphinx-contrib/sphinxcontrib-versioning/blob/1ba415a5799cc95b803d37dce0f81a15cd9f3f64/sphinxcontrib/versioning/git.py#L240

and this command returns:

1469536315
1562067662
1564053167
1565885343warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renameLimit variable to at least 2904 and retry the command.

1534772109warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renameLimit variable to at least 2904 and retry the command.

1471512478warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renameLimit variable to at least 2904 and retry the command.

1512992270warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renameLimit variable to at least 2904 and retry the command.

1564866513warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renameLimit variable to at least 2904 and retry the command.

1558289348warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renameLimit variable to at least 2904 and retry the command.

1475080037
1458561908
1549283009
1471256827
1565886066
1466433308
1536179026
1472121849
1562321286
1565824289
1558624388
1562067501
1468573872
1563360646
1470395248
1539976798
1505294206
1565009621
1564058239
1565594111
1565888192
1565888350
1565888224
1564761073
1559229466

It can be fixed by removing $ from this regexp: https://github.com/sphinx-contrib/sphinxcontrib-versioning/blob/1ba415a5799cc95b803d37dce0f81a15cd9f3f64/sphinxcontrib/versioning/git.py#L18

Regexp verification: https://regex101.com/r/Lz0Y8I/1