Skip to content
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

Fix issue #1137 #1139

Merged
merged 10 commits into from
Apr 17, 2023
2 changes: 2 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,5 @@ Contributors
- Petter Kvalvaag (@pettermk)

- Peter Küffner (@kuepe-sl)

- Andrew MacCormack (@amaccormack-lumira)
36 changes: 27 additions & 9 deletions src/github3/repos/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class Comparison(models.GitHubCore):

The number of commits the head commit is behind the base.

.. attribute:: commits
.. attribute:: original_commits
amaccormack-lumira marked this conversation as resolved.
Show resolved Hide resolved

A list of :class:`~github3.repos.commit.ShortCommit` objects
representing the commits in the comparison.
representing the first commits in the comparison.
amaccormack-lumira marked this conversation as resolved.
Show resolved Hide resolved

.. attribute:: diff_url

Expand Down Expand Up @@ -64,19 +64,17 @@ def _update_attributes(self, compare):
self.ahead_by = compare["ahead_by"]
self.base_commit = commit.ShortCommit(compare["base_commit"], self)
self.behind_by = compare["behind_by"]
self.commits = compare["commits"]
if self.commits:
self.commits = [
commit.ShortCommit(com, self) for com in self.commits
]
self.total_commits = compare["total_commits"]
self.original_commits = [
commit.ShortCommit(com, self) for com in compare["commits"]
]
self.diff_url = compare["diff_url"]
self.files = compare["files"]
self.html_url = compare["html_url"]
self.patch_url = compare["patch_url"]
self.permalink_url = compare["permalink_url"]
self.status = compare["status"]
self.total_commits = compare["total_commits"]
self._uniq = self.commits
self._uniq = self.original_commits

def _repr(self):
return f"<Comparison of {self.total_commits} commits>"
Expand Down Expand Up @@ -106,3 +104,23 @@ def patch(self):
self._api, headers={"Accept": "application/vnd.github.patch"}
)
return resp.content if self._boolean(resp, 200, 404) else b""

def commits(self, number=-1, etag=None):
"""Iterate over the commits available for this comparison.

:param int number:
(optional), Number of assets to return
:param str etag:
(optional), last ETag header sent
:returns:
generator of asset objects
:rtype:
:class:`~github3.repos.commit.ShortCommit`
"""
return self._iter(
number,
self._api,
commit.ShortCommit,
list_key="commits",
etag=etag,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"http_interactions": [{"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["github3.py/3.2.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.v3.full+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"]}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA62YbW/bNhDHv4qgN31R27Ij58lA0HVr0WZYu65Nt6LLIFASbbGhRI2k7NpCvvv+FGVLMlA7ifYiicTwfjwe707HK10WuzP/fDI+n0wGbiZiGpgR992r16vf+a88enO5IV8+LqPsbvN+83qFn+8uJpKUYtaC6aQI/VG+xti84Dyo/6HYIiVLJgt1MvU6s3LJlkRDeE64ogNXrDIq3VnpcrFgGZhtUVCNNifT8YU/7qr3x9mfX97z6Nv1+N2rxebdy6srTCZAExkUkgOUaJ2rmefZQTWyahSKykhkmmZ6FInUKzxLf7G8moKwkDWjsgIG9lg5qzlWGDDl7Wmc6JTvqWCXrkT2Js8F52IFyr7SxxbydpLG9BWFZYsnUiBZekInFLbDlu6NIZjSj1eqkipx4krDjwxH4UAkjR+tWC0HtYyD3JeepLmogEWoIslyzUT2eAU70qAJuSAZ25Cn0SCtADGqPV6VSgrSdAlffLy4FSu9KqCitTGNpBFlSxj7icg9eRD1Ojdx/hlOYUzPNA1InJo4rcL3foAoe6i3d/NATHeniAWct2zgXD9LHeJwFkoi185cSIchTiWJNPzTWSHXOG+u9dsifKacj68/3TgvP1xjCmQQ0DAigx0dksUOlQuRiZRFzoqsR861sxLyzhGZ82GtE/zxR2fPR9gPlrjbJaKDgV6dVSd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DRbkzEVaJrmvN1TXNEQGzf1UGDuVWI+DyT9t2DoQ+2spkXOIhj+77qJaSMK3cwhyRle8qpVsHvwz5rH8+bxonm8xKNEGq//1BgzAhOb1oT7z8CFAVnIONPG/nkRwhCYby//s+rAW4fnImc0Lrt14ZjOScF1YG9jwKQE/RhzA0/zwAapFncULRrrLxnVpv2x9YRqkXZhW3vbyeX9f8F2VzoNFgAA", "string": ""}, "headers": {"Server": ["GitHub.com"], "Date": ["Fri, 14 Apr 2023 07:51:23 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Cache-Control": ["public, max-age=60, s-maxage=60"], "Vary": ["Accept, Accept-Encoding, Accept, X-Requested-With"], "ETag": ["W/\"e7f859eeb6415cc98b087323f581a81f1367975559e620cd614130eaf4620b5c\""], "Last-Modified": ["Fri, 07 Apr 2023 08:35:54 GMT"], "X-GitHub-Media-Type": ["github.v3; param=full; format=json"], "x-github-api-version-selected": ["2022-11-28"], "Access-Control-Expose-Headers": ["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["0"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "Content-Encoding": ["gzip"], "X-RateLimit-Limit": ["60"], "X-RateLimit-Remaining": ["59"], "X-RateLimit-Reset": ["1681462283"], "X-RateLimit-Resource": ["core"], "X-RateLimit-Used": ["1"], "Accept-Ranges": ["bytes"], "Content-Length": ["1500"], "X-GitHub-Request-Id": ["F1C9:F162:672DCE9:683978F:643905FB"]}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2023-04-14T07:51:23"}, {"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["github3.py/3.2.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.v3.full+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"]}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/compare/a811e1a270f65eecb65755eca38d888cbefcb0a7...76dcc6cb4b9860034be81b7e58adc286a115aa97"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA+1bCW/bRhb+KwMBhROElniLIuo2QR1nU0D2tuukazeBMySH0tg8tCRlxzLy3/ebIWkdPiRaTZoCVBRLpOYd8+bNO+Y93nSmWdRxO+OimORur0cnvDvixXjqdf007mVskua9nI9iesmzaa6bvfJXozu57mHEhGasRx1NYxrV+2poW4z5nm31LYv51HACx3F8j4W+p9J+t9vt24Hv275negPHVlXD9JijeX1mOTTwdcemmmZROuh3FLAUR2fL3C1w9vfwNGFZTCOeXDydsUXG3UpyEMzS7UpKEELAw/DptL7CwnQFR2BsQgt//H1xJlkCax7N2Rl0M+ZFx73p5GMKBd9UFIBP0oCd8QBAw/0T+zd9UHh/ROpw5n8e7uP/8WR8tP/68+nxwXh47l+dnp9op3+8Pz/B5+HsHb4fjoez8cXR/sg80X+NTuNDPnzz2gDiOU90WozTTHCX0JiB0luakF/SLKC5n2IkiykX23KU0TDEtNIo5skovXyJjcgjsTWFbtBCgOqqpu/irRrHquZqpqs6p50vNbWCfWUyMctzOhKMHCWMxGnGSMHyAvwVGcPtegGwu/2Q6ZRpAfMtU7Us1fJCLaR2OAiCwNY1tW97jg7ALUwSLERP0M17G9ODqLYkWK5rvrEdrFSBJQXUdJpAS1Wlc8kyHnKfFjxNhNTKawY1DGmUM6WTMZqLnzrTBMYiwS9KR3yhxTSDnJNpFIlte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78WMm/g2Tv/8d1u/P1NwAA", "string": ""}, "headers": {"Server": ["GitHub.com"], "Date": ["Fri, 14 Apr 2023 07:51:24 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Cache-Control": ["public, max-age=60, s-maxage=60"], "Vary": ["Accept, Accept-Encoding, Accept, X-Requested-With"], "ETag": ["W/\"673d766978b8249a24d20e6c78eb657330ccc84e09234d6d1a284935fcb3e0b6\""], "Last-Modified": ["Mon, 03 Dec 2012 01:14:19 GMT"], "X-GitHub-Media-Type": ["github.v3; param=full; format=json"], "x-github-api-version-selected": ["2022-11-28"], "Access-Control-Expose-Headers": ["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["0"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "Content-Encoding": ["gzip"], "X-RateLimit-Limit": ["60"], "X-RateLimit-Remaining": ["58"], "X-RateLimit-Reset": ["1681462284"], "X-RateLimit-Resource": ["core"], "X-RateLimit-Used": ["2"], "Accept-Ranges": ["bytes"], "Content-Length": ["2184"], "X-GitHub-Request-Id": ["F1C9:F162:672DDAA:683986F:643905FC"]}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/compare/a811e1a270f65eecb65755eca38d888cbefcb0a7...76dcc6cb4b9860034be81b7e58adc286a115aa97"}, "recorded_at": "2023-04-14T07:51:24"}, {"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["github3.py/3.2.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.v3.full+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"]}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/compare/a811e1a270f65eecb65755eca38d888cbefcb0a7...76dcc6cb4b9860034be81b7e58adc286a115aa97?per_page=100"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA+1bCW/bRhb+KwMBhROElniLIuo2QR1nU0D2tuukazeBMySH0tg8tCRlxzLy3/ebIWkdPiRaTZoCVBRLpOYd8+bNO+Y93nSmWdRxO+OimORur0cnvDvixXjqdf007mVskua9nI9iesmzaa6bvfJXozu57mHEhGasRx1NYxrV+2poW4z5nm31LYv51HACx3F8j4W+p9J+t9vt24Hv275negPHVlXD9JijeX1mOTTwdcemmmZROuh3FLAUR2fL3C1w9vfwNGFZTCOeXDydsUXG3UpyEMzS7UpKEELAw/DptL7CwnQFR2BsQgt//H1xJlkCax7N2Rl0M+ZFx73p5GMKBd9UFIBP0oCd8QBAw/0T+zd9UHh/ROpw5n8e7uP/8WR8tP/68+nxwXh47l+dnp9op3+8Pz/B5+HsHb4fjoez8cXR/sg80X+NTuNDPnzz2gDiOU90WozTTHCX0JiB0luakF/SLKC5n2IkiykX23KU0TDEtNIo5skovXyJjcgjsTWFbtBCgOqqpu/irRrHquZqpqs6p50vNbWCfWUyMctzOhKMHCWMxGnGSMHyAvwVGcPtegGwu/2Q6ZRpAfMtU7Us1fJCLaR2OAiCwNY1tW97jg7ALUwSLERP0M17G9ODqLYkWK5rvrEdrFSBJQXUdJpAS1Wlc8kyHnKfFjxNhNTKawY1DGmUM6WTMZqLnzrTBMYiwS9KR3yhxTSDnJNpFIlteR2lFEDi8st2U3vCtJ5ss7FXnyC+fMUANfVeoLr5qgl3F2PNcsh9vn+jdMTFoizabwwQ5kM3VcfAyi7ak9/s9/89jPzzt+pwfzQbvtrbE9guaUGz1bnIm3nljac5y/w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1Ft0vQNpXWI1yX1K3EZTcVnzGMwrsGwnfyMJCPfjj0dYienWVagnNzoGgOeWEZim1vz/ruw1xEomWoPM99dIpoQcnm45Yn+YhkJNht0HxHPJtBYl0aQ8qOqMZQorGoMZBU6ydBnfE8n7K7qrZuverJPbysUu7VGWhj1pYc9rJuij3xMNWYZhcBGsfuwDyyzqlfpGgabcLkYvNYE7gJyqlnGfsfRN6IXoZ9GnHkzABG+3LSUB+lfvAiza7vMPuILHNGMzSo36chwkA4mtInLzTDwMfWpu0Rfbt/7g+rwIytrj5auW972FngGaZ8PqIvzsKC0NZMlQa6w6y+bupe4KjM0kUL9YJHrqysdMqT6/U+WdOXfDKubn2yZn4bn1yxXLllyfTX98r3EP1L/fIq/m08syb0FuqraEJ9S3uBvwELhY/FowVwps9kSU8hE5rnV3i0QCF4tmDCcoUkacH2dnbKLyLWwcVz90OyS/D60BH//sMYcYWrdj/dIiQ/1g67CsLe8OJfeFDodsBPn0pg7NM5piOvwJ4nCBrqcbJrlRTpBUtImKWxDCFKXOTVv98imsgWblXI8EO33P8CtYsYnsYkLzIiZ+mSZ8IwcbTsPq8AFobUEnh4lHDjlXgWBykELWY0l2HPFU0KsMXzivMiJXQigqAiVSqSgjPeZV2F7AgXAwHviJRl5y5HYgVAKJXtwDR6Xi4FoV46FUTYsqzuhxcLt4wDN26FJ3irniaowTOGJwWS3CWuH0En3E+vKlUpF+THpUus5eIqQrnEq0RBRuP5oj+uZnMdw7oI7/chEeZXqxRYr+yvUFzpc4Wxr4z2M9lCrYBmbf8VArOGUVJ3RWZRanFEPRbl4mbFZa2FkmUeEokIGhgs4IK6y5/Faz6rzXmoGFBISR2k5e5Z+8rTrFBIAE2VcTLQ8MRnENM09lhWK+8aNGuRSPhqWmJOz/78WMm/g2Tv/8d1u/P1NwAA", "string": ""}, "headers": {"Server": ["GitHub.com"], "Date": ["Fri, 14 Apr 2023 07:51:24 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Cache-Control": ["public, max-age=60, s-maxage=60"], "Vary": ["Accept, Accept-Encoding, Accept, X-Requested-With"], "ETag": ["W/\"673d766978b8249a24d20e6c78eb657330ccc84e09234d6d1a284935fcb3e0b6\""], "Last-Modified": ["Mon, 03 Dec 2012 01:14:19 GMT"], "X-GitHub-Media-Type": ["github.v3; param=full; format=json"], "Link": ["<https://api.github.com/repositories/3710711/compare/a811e1a270f65eecb65755eca38d888cbefcb0a7...76dcc6cb4b9860034be81b7e58adc286a115aa97?per_page=100&page=1>; rel=\"first\""], "x-github-api-version-selected": ["2022-11-28"], "Access-Control-Expose-Headers": ["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["0"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "Content-Encoding": ["gzip"], "X-RateLimit-Limit": ["60"], "X-RateLimit-Remaining": ["57"], "X-RateLimit-Reset": ["1681462283"], "X-RateLimit-Resource": ["core"], "X-RateLimit-Used": ["3"], "Accept-Ranges": ["bytes"], "Content-Length": ["2184"], "X-GitHub-Request-Id": ["F1C9:F162:672DF0A:68399C0:643905FC"]}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/compare/a811e1a270f65eecb65755eca38d888cbefcb0a7...76dcc6cb4b9860034be81b7e58adc286a115aa97?per_page=100"}, "recorded_at": "2023-04-14T07:51:24"}], "recorded_with": "betamax/0.8.1"}
1 change: 1 addition & 0 deletions tests/cassettes/Repository_compare_commits_large.json

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions tests/integration/test_repos_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,30 @@ def test_compare_commits(self):
comparison = repository.compare_commits(base, head)
assert isinstance(comparison, github3.repos.comparison.Comparison)

def test_compare_commits_consistency(self):
"""Test that Comparison commits matches original_commits"""
cassette_name = self.cassette_name("compare_commits_consistency")
with self.recorder.use_cassette(cassette_name):
repository = self.gh.repository("sigmavirus24", "github3.py")
base = "a811e1a270f65eecb65755eca38d888cbefcb0a7"
head = "76dcc6cb4b9860034be81b7e58adc286a115aa97"
comparison = repository.compare_commits(base, head)
self.assertListEqual(
list(comparison.commits()), comparison.original_commits
)

def test_compare_commits_large(self):
"""Test the ability to compare two commits with many changes."""
cassette_name = self.cassette_name("compare_commits_large")
with self.recorder.use_cassette(cassette_name):
repository = self.gh.repository("sigmavirus24", "github3.py")
base = "1.0.0"
head = "3.2.0"
comparison = repository.compare_commits(base, head)
assert isinstance(comparison, github3.repos.comparison.Comparison)
iter_count = sum(1 for _ in comparison.commits())
assert comparison.total_commits == iter_count

def test_contributor_statistics(self):
"""Test the ability to retrieve contributor statistics for a repo."""
cassette_name = self.cassette_name("contributor_statistics")
Expand Down