Repository: coreruleset/coreruleset

Issue:
Remaining issues with automatic changelog PR generation
This is coming along nicely. Still a few hiccups:

* The linter complains the title of the PR itself is not a conventional commit message. Suggestion: Prefix with `chore:`. That passes.
* The mapped dev name come with a prefix `@`. (-> `@Ervin Hegedüs`). This should be removed.
* There is 1 message per dev merging a PR per day. Yesterday we had 2 dev merging 1 PR, this leading to 2 Changelog PRs trying to add something to the same original CHANGES file, obviously resulting in a conflict. Can be resolved by hand, but a single Changelog PR per day would be easier for handling.
* The PRs are now changing the first few lines of the CHANGES file. I suggest to shift this down a bit to get a better looking file without having these new entries sticking out on top. Suggestion: Add the entries following the first line matching the pattern `/^## Version/`.


I have resolved the conflict right in the GUI and I have also rewritten the Changelog message by hand right in the GUI. I think that works smoothly. Then self-approval, then merging.

We do not usually self-approve, but on these administrative updates, we should keep the work to an absolute minimum.


Discussion:

Resolving patch:
diff --git a/.github/create-changelog-prs.py b/.github/create-changelog-prs.py
--- a/.github/create-changelog-prs.py
+++ b/.github/create-changelog-prs.py
@@ -6,7 +6,6 @@
 import tempfile
 import sys
 import os
-import shutil
 import re
 
 DEVELOPERS = dict()
@@ -76,7 +75,7 @@ def create_pr(repository: str, merged_by: str, prs: list, day: datetime.date):
 		--assignee "{merged_by}" \
 		--base "{base_branch}" \
 		--label "changelog-pr" \
-		--title "Changelog updates for {day}, merged by @{merged_by}" \
+		--title "chore: changelog updates for {day}, merged by @{merged_by}" \
 		--body '{pr_body}'
 	"""
 
@@ -88,16 +87,10 @@ def create_pr(repository: str, merged_by: str, prs: list, day: datetime.date):
 	print(f"Created PR: {outs.decode()}")
 
 def create_commit(changelog_lines: str):
-	new_changelog = tempfile.NamedTemporaryFile(delete=False, delete_on_close=False)
-	new_changelog.write(changelog_lines.encode())
-	with open('CHANGES.md', 'rt') as changelog:
-		new_changelog.write(changelog.read().encode())
+	with open('.changes-pending.md', 'at') as changelog:
+		changelog.write(changelog_lines.encode())
 
-	new_changelog.close()
-	os.remove('CHANGES.md')
-	shutil.move(new_changelog.name, 'CHANGES.md')
-
-	command = "git commit CHANGES.md -m 'Add pending changelog entries to changelog'"
+	command = "git commit .changes-pending.md -m 'Add pending changelog entries'"
 	proc = subprocess.Popen(command, shell=True, stderr=subprocess.PIPE)
 	_, errors = proc.communicate()
 	if proc.returncode != 0:
@@ -112,7 +105,7 @@ def generate_content(prs: list, merged_by: str) -> (str, str):
 		pr_number = pr["number"]
 		pr_title = pr["title"]
 		pr_author = get_pr_author_name(pr["author"]["login"])
-		new_line = f"* {pr_title} (@{pr_author}) [#{pr_number}]\n"
+		new_line = f"* {pr_title} ({pr_author}) [#{pr_number}]\n"
 		pr_body += new_line
 		pr_links += f"- #{pr_number}\n"
 
@@ -126,7 +119,7 @@ def get_pr_author_name(login: str) -> str:
 	if len(DEVELOPERS) == 0:
 		parse_contributors()
 
-	return DEVELOPERS[login] if login in DEVELOPERS else login
+	return DEVELOPERS[login] if login in DEVELOPERS else f"@{login}"
 
 def parse_contributors():
 	regex = re.compile(r'^\s*?-\s*?\[([^]]+)\]\s*?\(http.*/([^/]+)\s*?\)')


Test patch: