Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Auto merge pull request #36: Fix auto cleanup lint deleting wrong com…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
Lusheng Lv committed Oct 26, 2016
2 parents b8977fa + c4689e8 commit c431ad2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions badwolf/lint/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@ def _report(self):
logger.exception('Error fetching all comments for pull request')
comments = []

existing_comments = set()
existing_comments_ids = {}
for comment in comments:
inline = comment.get('inline')
if not inline:
continue

raw = comment['content']['raw']
if not raw.startswith(':broken_heart: **'):
continue
filename = inline['path']
line_to = inline['to']
existing_comments.add((filename, line_to, raw))
existing_comments_ids[(filename, line_to, raw)] = comment['id']

if len(self.problems) == 0:
Expand All @@ -151,9 +151,9 @@ def _report(self):
problem_count = 0
for problem in self.problems:
content = ':broken_heart: **{}**: {}'.format(problem.linter, problem.message)
commnet_tuple = (problem.filename, problem.line, content)
lint_comments.add(commnet_tuple)
if commnet_tuple in existing_comments:
comment_tuple = (problem.filename, problem.line, content)
lint_comments.add(comment_tuple)
if comment_tuple in existing_comments_ids:
continue

try:
Expand All @@ -176,7 +176,7 @@ def _report(self):
problem_count
)

outdated_comments = existing_comments - lint_comments
outdated_comments = set(existing_comments_ids.keys()) - lint_comments
logger.info('%d outdated lint comments found', len(outdated_comments))
for comment in outdated_comments:
# Delete comment
Expand Down

0 comments on commit c431ad2

Please sign in to comment.