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

Add option to filter by labels #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion slack_pull_reminder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
ignore = os.environ.get('IGNORE_WORDS')
IGNORE_WORDS = [i.lower().strip() for i in ignore.split(',')] if ignore else []

filter_labels = os.environ.get('FILTER_LABELS')
FILTER_LABELS = [i.lower().strip() for i in filter_labels.split(',')] if filter_labels else []

repositories = os.environ.get('REPOSITORIES')
REPOSITORIES = [r.lower().strip() for r in repositories.split(',')] if repositories else []

Expand Down Expand Up @@ -48,12 +51,23 @@ def is_valid_title(title):

return True

def is_valid_labels(labels):
if not FILTER_LABELS:
return True

for label in labels:
lowercase_label = label['name'].lower()
for filtered_label in FILTER_LABELS:
if filtered_label in lowercase_label:
return True

return False

def format_pull_requests(pull_requests, owner, repository):
lines = []

for pull in pull_requests:
if is_valid_title(pull.title):
if is_valid_title(pull.title) and is_valid_labels(pull.labels):
creator = pull.user.login
line = '*[{0}/{1}]* <{2}|{3} - by {4}>'.format(
owner, repository, pull.html_url, pull.title, creator)
Expand Down