This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v2-8-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit b8e4dcde2010d239690894916f6efb8ff721d9c2
Author: Amogh Desai <[email protected]>
AuthorDate: Fri Jan 5 11:59:55 2024 +0530

    Optimise getting changelogs in airflow-github (#36548)
    
    (cherry picked from commit 142c7376c6d6566938ced345e97a1e2442e2fd32)
---
 dev/airflow-github | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/dev/airflow-github b/dev/airflow-github
index 46213b411a..7d4ad9ebb9 100755
--- a/dev/airflow-github
+++ b/dev/airflow-github
@@ -323,29 +323,30 @@ def changelog(previous_version, target_version, 
github_token):
     # Get a list of issues/PRs that have been committed on the current branch.
     log = get_commits_between(repo, previous_version, target_version)
 
+    print("Number of commits", len(log))
+
     gh = Github(github_token)
     gh_repo = gh.get_repo("apache/airflow")
     sections = defaultdict(list)
+    existing_commits = set()
+    with open("../RELEASE_NOTES.rst") as file:
+        for line in file.readlines():
+            match = re.search(r"\(#(\w+)\)", line)
+            if match:
+                existing_commits.add(match.group(1))
+
     for commit in log:
         tickets = pr_title_re.findall(commit["subject"])
         if tickets:
             issue = gh_repo.get_issue(number=int(tickets[0][1:]))
             issue_type = get_issue_type(issue)
             files = files_touched(repo, commit["id"])
+            if commit["id"] in existing_commits:
+                continue
             if is_core_commit(files):
-                if issue_type in ["bug-fix", "doc-only", "misc/internal"]:
-                    with open("../RELEASE_NOTES.rst") as file:
-                        for line in file.readlines():
-                            if line.endswith(f"(#{commit['id']})"):
-                                continue
-                        else:
-                            sections[issue_type].append(commit["subject"])
-                else:
-                    sections[issue_type].append(commit["subject"])
-
+                sections[issue_type].append(commit["subject"])
         else:
             sections[DEFAULT_SECTION_NAME].append(commit["subject"])
-
     print_changelog(sections)
 
 

Reply via email to