Skip to content

Commit

Permalink
Update auto_cl.py
Browse files Browse the repository at this point in the history
  • Loading branch information
themanyfaceddemon committed Jun 27, 2024
1 parent fc14a5a commit df219bb
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions Tools/ATD/auto_cl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

MAX_ENTRIES = 500
CHANGELOG_PATH = os.path.join(os.path.dirname(__file__), '../../Resources/Changelog/ChangelogADT.yml')
OLD_CHANGELOG_PATH = os.path.join(os.path.dirname(__file__), 'cl_old.yml')

class NoDatesSafeLoader(yaml.SafeLoader):
@classmethod
Expand Down Expand Up @@ -100,7 +101,8 @@ def fetch_single_pr(number):
if not cl_match:
return None

author = cl_match.group(1).strip() or pr_info['user']['login']
# Извлекаем автора до конца строки
author = cl_match.group(1).split('\n')[0].strip() or pr_info['user']['login']

changes = []
for line in body.splitlines():
Expand Down Expand Up @@ -137,12 +139,11 @@ def fetch_single_pr(number):
return pr_data

def update_cl_file(file_path, new_data):
cl_old_data = load_yaml(file_path)
existing_entries = cl_old_data.get("Entries", [])
old_entries = load_yaml(OLD_CHANGELOG_PATH).get("Entries", [])

# Calculate the next ID based on existing entries
if existing_entries:
next_id = max(entry['id'] for entry in existing_entries) + 1
if old_entries:
next_id = max(entry['id'] for entry in old_entries) + 1
else:
next_id = 1

Expand All @@ -151,8 +152,8 @@ def update_cl_file(file_path, new_data):
entry['id'] = next_id
next_id += 1

# Combine and reorder entries
combined_data = existing_entries + new_data
# Combine old entries and new data
combined_data = old_entries + new_data

# Ensure we do not exceed MAX_ENTRIES
if len(combined_data) > MAX_ENTRIES:
Expand All @@ -162,8 +163,7 @@ def update_cl_file(file_path, new_data):
combined_data = strip_newlines(combined_data)

# Save the updated data back to ChangelogADT.yml
cl_old_data["Entries"] = combined_data
save_yaml(cl_old_data, file_path)
save_yaml({"Entries": combined_data}, file_path)

logging.info("Updated PR data saved to ChangelogADT.yml")

Expand All @@ -175,7 +175,6 @@ def main():
github_token = sys.argv[1]
repo = sys.argv[2]


pr_number = get_latest_pr_number(github_token, repo)
if pr_number is None:
logging.error("Failed to get the latest PR number")
Expand Down

0 comments on commit df219bb

Please sign in to comment.