Mismatch between docs and source code on Repository's parameter "order"
stefanodallapalma opened this issue · comments
Describe the bug
Hi @ishepard,
According to the docs, the default value for the parameter order
is reverse, while in the Repository
class is None. Traversing commits with order=None
differs from order='reverse'
. That is, order=None
returns the commits in chronological order while order='reverse'
returns them from the newest to the oldest.
Is this the expected behavior and the docs outdated, or vice versa?
To Reproduce
from pydriller.repository import Repository
# FAILS
def test_order_default():
commits = list(
Repository('https://github.com/ishepard/pydriller',
from_commit='ec2ccc540c86e4ba18683a1efa7d367fc56a0150',
to_commit='80cc74a016f90469311d7c10ccacc978c71150fe',
order=None).traverse_commits()
)
assert commits[0].hash == 'ec2ccc540c86e4ba18683a1efa7d367fc56a0150'
assert commits[1].hash == '80cc74a016f90469311d7c10ccacc978c71150fe'
# PASSES
def test_order_reverse():
commits = list(
Repository('https://github.com/ishepard/pydriller',
from_commit='ec2ccc540c86e4ba18683a1efa7d367fc56a0150',
to_commit='80cc74a016f90469311d7c10ccacc978c71150fe',
order='reverse').traverse_commits()
)
assert commits[0].hash == 'ec2ccc540c86e4ba18683a1efa7d367fc56a0150'
assert commits[1].hash == '80cc74a016f90469311d7c10ccacc978c71150fe'
OS Version:
Linux; PyDriller2.1
Pydriller has the opposite behaviour of Git. So if we pass none
, we set reverse to True
, if we pass 'reverse', we set reverse to False
.
def test_order_default():
commits = list(
Repository('https://github.com/ishepard/pydriller',
from_commit='ec2ccc540c86e4ba18683a1efa7d367fc56a0150',
to_commit='80cc74a016f90469311d7c10ccacc978c71150fe',
order=None).traverse_commits()
)
assert commits[0].hash == '80cc74a016f90469311d7c10ccacc978c71150fe'
assert commits[1].hash == 'ec2ccc540c86e4ba18683a1efa7d367fc56a0150'
The doc is correct, as well as the behaviour 😄
Got it, I remember we discussed that at some point.
However, here I'm not questioning the semantic of the code, but the description of that parameter as I personally found the docs a bit misleading as it states "It can be one of: ‘date-order’, ‘author-date-order’, ‘topo-order’, or ‘reverse’. Default is reverse."
But as you said in the answer above, that means the default behavior acts similar to order='date-order'
. From the docs it seems like the default for order
is 'reverse'.
Shall we update the docs and specify "when order=None
commits are returned in chronological order?"