-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid mutating
_filter
dict for subsequent calls (#229)
* Avoid mutating `_filter` dict for subsequent calls * Check type of `_filter['labels']` instead of creating new object * Unit test for filters with multiple labels * Unit test fixes * Avoid mutating config object * Use deepcopy and test multiple labels for PRs as well --------- Co-authored-by: Ralph Bean <[email protected]>
- Loading branch information
Showing
4 changed files
with
130 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
# Authors: Ralph Bean <[email protected]> | ||
|
||
import logging | ||
from copy import deepcopy | ||
|
||
try: | ||
from urllib.parse import urlencode # py3 | ||
|
@@ -142,14 +143,18 @@ def github_prs(upstream, config): | |
.get('github', {}) \ | ||
.get(upstream, {}) | ||
|
||
if 'labels' in _filter: | ||
# We have to flatten the labels list to a comma-separated string | ||
_filter['labels'] = ','.join(_filter['labels']) | ||
|
||
# Build our URL | ||
url = 'https://api.github.com/repos/%s/pulls' % upstream | ||
if _filter: | ||
url += '?' + urlencode(_filter) | ||
labels = _filter.get('labels') | ||
if isinstance(labels, list): | ||
# We have to flatten the labels list to a comma-separated string, | ||
# so make a copy to avoid mutating the config object | ||
url_filter = deepcopy(_filter) | ||
url_filter['labels'] = ','.join(labels) | ||
else: | ||
url_filter = _filter # Use the existing filter, unmodified | ||
url += '?' + urlencode(url_filter) | ||
|
||
# Get our issues using helper functions | ||
prs = u_issue.get_all_github_data(url, headers) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters