Skip to content
This repository was archived by the owner on Mar 14, 2023. It is now read-only.

Commit 74079c4

Browse files
authored
Merge pull request #129 from davidalber/fixing-is-new-contributor-logic
Fixing the currently-inverted logic in `is_new_contributor`
2 parents 0ac943a + ad5ef29 commit 74079c4

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

highfive/newpr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ def is_new_contributor(username, owner, repo, token, payload):
178178
'GET', commit_search_url % (owner, repo, username), None, token,
179179
'application/vnd.github.cloak-preview'
180180
)
181-
return json.loads(result['body'])['total_count'] > 0
181+
return json.loads(result['body'])['total_count'] == 0
182182
except urllib2.HTTPError, e:
183183
if e.code == 422:
184-
return False
184+
return True
185185
else:
186186
raise e
187187

highfive/tests/integration_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ def setUp(self):
1010
self.payload = {'repository': {'fork': False}}
1111

1212
def test_real_contributor_true(self):
13-
self.assertTrue(
13+
self.assertFalse(
1414
newpr.is_new_contributor(
1515
'nrc', 'rust-lang', 'rust', '', self.payload
1616
)
1717
)
1818

1919
def test_real_contributor_false(self):
20-
self.assertFalse(
20+
self.assertTrue(
2121
newpr.is_new_contributor(
2222
'octocat', 'rust-lang', 'rust', '', self.payload
2323
)
2424
)
2525

2626
def test_fake_user(self):
27-
self.assertFalse(
27+
self.assertTrue(
2828
newpr.is_new_contributor(
2929
'fjkesfgojsrgljsdgla', 'rust-lang', 'rust', '', self.payload
3030
)

highfive/tests/test_newpr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,17 +626,17 @@ def test_is_new_contributor_fork(self):
626626

627627
def test_is_new_contributor_has_commits(self):
628628
self.mocks['api_req'].return_value = self.api_return(5)
629-
self.assertTrue(self.is_new_contributor())
629+
self.assertFalse(self.is_new_contributor())
630630
self.assert_api_req_call()
631631

632632
def test_is_new_contributor_no_commits(self):
633633
self.mocks['api_req'].return_value = self.api_return(0)
634-
self.assertFalse(self.is_new_contributor())
634+
self.assertTrue(self.is_new_contributor())
635635
self.assert_api_req_call()
636636

637637
def test_is_new_contributor_nonexistent_user(self):
638638
self.mocks['api_req'].side_effect = HTTPError(None, 422, None, None, None)
639-
self.assertFalse(self.is_new_contributor())
639+
self.assertTrue(self.is_new_contributor())
640640
self.assert_api_req_call()
641641

642642
def test_is_new_contributor_error(self):

0 commit comments

Comments
 (0)