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 587b0a2e37eb20544c434db93210158dfef9aab1
Author: Amogh Desai <[email protected]>
AuthorDate: Fri Jan 5 18:30:39 2024 +0530

    Tracking airflow-github changelog activities using progress bar (#36610)
    
    * Tracking airflow-github changelog activities using progress bar
    
    * review comments from ephraimbuddy
    
    (cherry picked from commit b3b8ae99ca1ef0524854148ca8a549232e2f3ae0)
---
 dev/airflow-github | 41 ++++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/dev/airflow-github b/dev/airflow-github
index 7d4ad9ebb9..4b33802aef 100755
--- a/dev/airflow-github
+++ b/dev/airflow-github
@@ -31,6 +31,8 @@ import git
 import rich_click as click
 from github import Github
 from packaging import version
+from rich.console import Console
+from rich.progress import Progress
 
 if TYPE_CHECKING:
     from github.Issue import Issue
@@ -40,7 +42,6 @@ GIT_COMMIT_FIELDS = ["id", "author_name", "author_email", 
"date", "subject", "bo
 GIT_LOG_FORMAT = "%x1f".join(["%h", "%an", "%ae", "%ad", "%s", "%b"]) + "%x1e"
 pr_title_re = re.compile(r".*\((#[0-9]{1,6})\)$")
 
-
 STATUS_COLOR_MAP = {
     "Closed": "green",
     "Open": "red",
@@ -318,13 +319,11 @@ def compare(target_version, github_token, 
previous_version=None, show_uncherrypi
 @click.argument("previous_version")
 @click.argument("target_version")
 @click.argument("github-token", envvar="GITHUB_TOKEN")
-def changelog(previous_version, target_version, github_token):
[email protected]("--disable-progress", is_flag=True, help="Disable the progress 
bar")
+def changelog(previous_version, target_version, github_token, 
disable_progress):
     repo = git.Repo(".", search_parent_directories=True)
     # 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)
@@ -335,18 +334,26 @@ def changelog(previous_version, target_version, 
github_token):
             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):
-                sections[issue_type].append(commit["subject"])
-        else:
-            sections[DEFAULT_SECTION_NAME].append(commit["subject"])
+    console = Console(width=180)
+
+    with Progress(console=console, disable=disable_progress) as progress:
+        task = progress.add_task("Processing commits from changelog", 
total=len(log))
+        for commit in progress.track(log, description="Processing commits from 
changelog"):
+            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):
+                    sections[issue_type].append(commit["subject"])
+                progress.update(task, advance=1)
+            else:
+                sections[DEFAULT_SECTION_NAME].append(commit["subject"])
+                progress.update(task, advance=1)
+
+    console.print("\n")
     print_changelog(sections)
 
 

Reply via email to