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

Comment filter #215

Merged
merged 5 commits into from
Feb 15, 2017
Merged
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions scc/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import argparse
import re
import copy
import os
import sys
import uuid
Expand Down Expand Up @@ -857,7 +858,11 @@ def find_candidate_pulls(self, filters):
def filter_pull(self, pullrequest, filters):

def is_whitelisted_comment(x):
return self.is_whitelisted(x.user, filters["include"].get("user"))
# Always include the organization filter for whitelisting comments
user_filters = copy.deepcopy(filters["include"].setdefault(
"user", []))
user_filters.append('#org')
return self.is_whitelisted(x.user, user_filters)

if pullrequest.parse(filters["exclude"].get("label"),
whitelist=is_whitelisted_comment):
Expand Down Expand Up @@ -1606,7 +1611,6 @@ def rset_commit_status(self, filters, status, message, url, info=False):

for submodule_repo in self.submodules:
# Create submodule filters
import copy
sub_filters = copy.deepcopy(filters)
for ftype in ["include", "exclude"]:
sub_filters.pop("pr", None) # Do not copy top-level PRs
Expand Down Expand Up @@ -1665,7 +1669,6 @@ def rmerge(self, filters, info=False, comment=False, commit_id="merge",

for submodule_repo in self.submodules:
# Create submodule filters
import copy
sub_filters = copy.deepcopy(filters)
# Do not copy top-level PRs
for ftype in ["include", "exclude"]:
Expand Down
15 changes: 13 additions & 2 deletions test/integration/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,25 @@ def testExcludeComment(self):
self.pr.create_issue_comment('--exclude')
self.merge()
assert not self.isMerged()
self.merge('-Dnone', '-Iuser:#org')
assert self.isMerged()

def testIncludeComment(self):
""""Test PR inclusion using whitelisted comment"""

self.pr.create_issue_comment('--breaking')
self.pr.create_issue_comment('--foo\n--exclude')
self.merge()
# Default set of filters recognize --exclude comment
assert not self.isMerged()
self.merge('-Dnone', '-Iuser:#org', '-Ibreaking', '-Eexclude')
self.merge('-Dnone', '-Ifoo')
# --foo comment should be whitelisted
assert self.isMerged()
self.merge('-Dnone', '-Ifoo', '-Eexclude')
# --exclude filter takes priority
assert not self.isMerged()
self.merge('-Ifoo')
# Default set of filters recognize --exclude comment
assert not self.isMerged()

def testExcludeDescription(self):

Expand Down