Skip to content

Commit

Permalink
Update auto_cl.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Schrodinger71 committed Jun 28, 2024
1 parent 88431ab commit 0b0aa7c
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions Tools/ATD/auto_cl.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,34 +91,38 @@ def fetch_pr_data(token, repo, pr_number):
def fetch_single_pr(number):
try:
pr_info = get_pr_info(token, repo, number)

# Проверяем, что PR был замержен
if not pr_info.get('merged_at'):
return None

body = pr_info.get('body', '')

# Находим строку, которая начинается с :cl:
author = pr_info['user']['login']
for line in body.splitlines():
if line.strip().startswith(':cl:'):
potential_author = line.strip()[4:].strip() # Убираем :cl: и пробелы
changes = []

lines = [line.strip() for line in body.splitlines()]
for line in lines:
if line.lower().startswith('no cl'):
return None

if line.startswith(':cl:'):
potential_author = line[4:].strip()
if potential_author:
author = potential_author
break
changes = []
for line in body.splitlines():
line = line.strip()
if line.startswith('- add:'):
changes.append({"message": line[len('- add:'):].strip(), "type": "Add"})
elif line.startswith('- remove:'):
changes.append({"message": line[len('- remove:'):].strip(), "type": "Remove"})
elif line.startswith('- tweak:'):
changes.append({"message": line[len('- tweak:'):].strip(), "type": "Tweak"})
elif line.startswith('- fix:'):
changes.append({"message": line[len('- fix:'):].strip(), "type": "Fix"})
continue

change_types = {
'- add:': "Add",
'- remove:': "Remove",
'- tweak:': "Tweak",
'- fix:': "Fix"
}

for prefix, change_type in change_types.items():
if line.startswith(prefix):
changes.append({"message": line[len(prefix):].strip(), "type": change_type})
break

if changes:
return {
"author": author,
Expand All @@ -127,6 +131,7 @@ def fetch_single_pr(number):
}
except requests.exceptions.RequestException as e:
logging.error(f"Failed to fetch PR #{number}: {e}")

return None

with ThreadPoolExecutor(max_workers=10) as executor:
Expand Down

0 comments on commit 0b0aa7c

Please sign in to comment.