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

Commit 846dccd

Browse files
authored
Merge pull request #201 from rust-lang/fix-broken-global-config
Fix exception when loading the global config
2 parents 577224b + 21d2f78 commit 846dccd

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

highfive/newpr.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ def __init__(self, payload, config, config_dir=None):
5353
self.integration_user = config.github_username
5454
self.integration_token = config.github_token
5555

56-
self.repo_config = self.load_repo_config(config_dir)
56+
self.config_dir = config_dir
57+
self.repo_config = self.load_repo_config()
5758

58-
def load_repo_config(self, config_dir=None):
59+
def load_repo_config(self):
5960
'''Load the repository configuration.'''
6061
(org, repo) = self.payload['repository', 'full_name'].split('/')
6162
try:
62-
return self._load_json_file(os.path.join(org, repo) + '.json', config_dir)
63+
return self._load_json_file(os.path.join(org, repo) + '.json')
6364
except IOError:
6465
raise UnsupportedRepoError
6566

@@ -75,8 +76,9 @@ def run(self, event):
7576
else:
7677
return 'Unsupported webhook event.\n'
7778

78-
def _load_json_file(self, name, config_dir=None):
79-
if not config_dir:
79+
def _load_json_file(self, name):
80+
config_dir = self.config_dir
81+
if not self.config_dir:
8082
config_dir = os.path.join(os.path.dirname(__file__), 'configs')
8183

8284
with open(os.path.join(config_dir, name)) as config:

highfive/tests/test_newpr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def test_load_repo_config_supported(self, mock_load_json_file):
8484
m.stop_patchers()
8585
assert m.handler.load_repo_config() == {'a': 'config!'}
8686
mock_load_json_file.assert_called_once_with(
87-
os.path.join('foo', 'blah.json'), None,
87+
os.path.join('foo', 'blah.json'),
8888
)
8989

9090
@mock.patch('highfive.newpr.HighfiveHandler._load_json_file')
@@ -99,7 +99,7 @@ def test_load_repo_config_unsupported(self, mock_load_json_file):
9999
with pytest.raises(newpr.UnsupportedRepoError):
100100
m.handler.load_repo_config()
101101
mock_load_json_file.assert_called_once_with(
102-
os.path.join('foo', 'blah.json'), None
102+
os.path.join('foo', 'blah.json'),
103103
)
104104

105105
class TestNewPRGeneral(TestNewPR):

0 commit comments

Comments
 (0)