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

rok pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 83b4c539d36 GH-55475: [Dev] Use merge button instead of merge script 
(#55484)
83b4c539d36 is described below

commit 83b4c539d3659c0eab7e3de671803fdedaa1a0e8
Author: Rok Mihevc <[email protected]>
AuthorDate: Fri Nov 27 11:03:13 2026 +0100

    GH-55475: [Dev] Use merge button instead of merge script (#55484)
    
    ### Rationale for this change
    
    Committers currently need a GitHub personal access token and 
`dev/merge_arrow_pr.py` to merge pull requests. This change lets committers use 
GitHub's "Squash and merge" button directly while preserving automatic issue 
closure, milestone tracking, and release-note committer counts.
    
    ### What changes are included in this PR?
    
    * **Automatic issue closure with partial-fix opt-out** 
(`.github/boring-cyborg.yml`, `.github/pull_request_template.md`): For PRs 
targeting `main`, Boring Cyborg populates `* GitHub Issue: Closes #XXX` so 
GitHub natively closes and links the issue on merge. Changing `Closes` to 
`Refs` keeps the issue open for partial fixes and is preserved by the bot. The 
non-blocking "PR Title" check no longer accepts `WIP:` prefixes, and the 
template guidance lives inside the placeholder so nothing  [...]
    * **Self-healing milestone assignment from the commit graph** 
(`dev/archery/archery/release/`, 
`.github/workflows/dev_update_milestones.yml`): Adds `archery release 
update-milestones` and runs it every 6 hours (plus `workflow_dispatch`) to set 
milestones on closed, unmilestoned issues referenced by `GH-XXX` commits since 
the last major release tag. Milestones are chosen from branch membership 
(`maint-X.0.0` vs. the next open major release), existing milestones are never 
overwritten, a [...]
    * **GitHub-based patch committer counting** 
(`dev/archery/archery/release/`, `dev/archery/setup.py`, 
`dev/release/post-04-website.sh`): Adds `archery release committers` to count 
merged PRs via GitHub GraphQL instead of `Signed-off-by:` commit trailers, and 
updates `post-04-website.sh` to load `GH_TOKEN` via `utils-env.sh` and use it.
    * **Developer and release documentation** (`dev/README.md`, 
`docs/source/developers/`): Documents merging with the GitHub button, the 
`Closes`/`Refs` convention, the scheduled milestone workflow, and running 
`archery release update-milestones` before curating a release. 
`dev/merge_arrow_pr.py` remains unchanged and usable during the transition.
    
    ### Are these changes tested?
    
    * Added unit tests in `dev/archery/archery/release/tests/test_release.py` 
covering `count_committers` and `update_milestones` (maintenance branch cuts, 
cherry-picks, partial-to-closing spans, 
`NOT_PLANNED`/open/existing-milestone/PR/`NOT_FOUND` handling, `dry_run`, and 
missing next major milestone).
    * Verified both new Archery commands live against `apache/arrow` (`archery 
release update-milestones --dry-run` and `archery release committers`).
    * Verified `dev/archery` tests, linters, docs build, and release tests in 
CI.
    
    ### Are there any user-facing changes?
    
    No.
    
    ### Was AI used for this PR?
    
    **PR code and description written by:**
    
    - [x] Human
    - [x] AI
    
    **Reviewed before submission by:**
    
    - [x] Human
    - [x] AI
    - [ ] Not reviewed
    
    * GitHub Issue: #55475
    
    Lead-authored-by: Rok Mihevc <[email protected]>
    Co-authored-by: Raúl Cumplido <[email protected]>
    Co-authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Rok Mihevc <[email protected]>
---
 .asf.yaml                                          |   6 +
 .github/boring-cyborg.yml                          |   8 +-
 .github/pull_request_template.md                   |   2 +-
 .github/workflows/dev_update_milestones.yml        |  52 ++++++
 dev/README.md                                      |  38 +++-
 dev/archery/archery/release/cli.py                 |  39 +++-
 dev/archery/archery/release/core.py                | 193 +++++++++++++++++++-
 dev/archery/archery/release/tests/test_release.py  | 203 ++++++++++++++++++++-
 dev/archery/setup.py                               |   2 +-
 dev/merge_arrow_pr.py                              |   5 +
 dev/release/post-04-website.sh                     |  14 +-
 .../developers/continuous_integration/overview.rst |   1 +
 docs/source/developers/overview.rst                |  14 +-
 docs/source/developers/release.rst                 |  10 +-
 14 files changed, 566 insertions(+), 21 deletions(-)

diff --git a/.asf.yaml b/.asf.yaml
index 4cc0199abe4..ac3f4af3745 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -27,6 +27,12 @@ github:
     projects: true
     discussions: true
 
+  enabled_merge_buttons:
+    merge: false
+    rebase: false
+    squash: true
+    squash_commit_message: PR_TITLE_AND_DESC
+
   protected_branches:
     # protect main against force push
     main: {}
diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml
index 8789531ae07..d5697feef35 100644
--- a/.github/boring-cyborg.yml
+++ b/.github/boring-cyborg.yml
@@ -59,7 +59,7 @@ labelPRBasedOnFilePath:
     - "**/*.Rd"
 
 verifyTitles:
-  titleRegexp: '^(WIP:?\s*)?GH-[0-9]+|^MINOR: '
+  titleRegexp: '^GH-[0-9]+|^MINOR: '
   alwaysUsePrTitle: true
   validateEitherPrOrSingleCommitTitle: false
   statusTitle: "PR Title"
@@ -67,8 +67,12 @@ verifyTitles:
   failureMessage: "Title must start with 'GH-<issue>: [Component]' or 'MINOR: 
[Component]'"
 
 insertIssueLinkInPrDescription:
-  descriptionIssuePlaceholderRegexp: '^\* GitHub Issue: (.*)$'
+  descriptionIssuePlaceholderRegexp: '^\* GitHub Issue: (?![Rr]efs\b)(.*)$'
   matchers:
+    closedIssue:
+      targetBranchFilter: '^main$'
+      titleIssueIdRegexp: '^GH-([0-9]+)'
+      descriptionIssueLink: 'Closes #${1}'
     githubIssue:
       titleIssueIdRegexp: '^(?:WIP:?\s*)?GH-([0-9]+)'
       descriptionIssueLink: '#${1}'
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index dd7509e2605..fd83f252ae9 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -34,4 +34,4 @@ In accordance to the [AI generation 
guidelines](https://arrow.apache.org/docs/de
 - [ ] AI
 - [ ] Not reviewed
 
-* GitHub Issue: (filled in automatically from the PR title)
+* GitHub Issue: (filled in automatically from the PR title; change "Closes" to 
"Refs" for a partial fix)
diff --git a/.github/workflows/dev_update_milestones.yml 
b/.github/workflows/dev_update_milestones.yml
new file mode 100644
index 00000000000..030a702285e
--- /dev/null
+++ b/.github/workflows/dev_update_milestones.yml
@@ -0,0 +1,52 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Update issue milestones
+
+on:
+  schedule:
+    - cron: "17 */6 * * *" # Every 6 hours
+  workflow_dispatch:
+
+permissions:
+  contents: read
+  issues: write
+
+jobs:
+  update:
+    name: Update milestones
+    if: github.repository == 'apache/arrow'
+    runs-on: ubuntu-latest
+    timeout-minutes: 10
+    steps:
+      - name: Checkout Arrow
+        uses: actions/checkout@v7
+        with:
+          persist-credentials: false
+          fetch-depth: 0
+      - name: Setup Python
+        uses: actions/setup-python@v7
+        with:
+          python-version: '3.12'
+      - name: Install Archery
+        run: |
+          pip install "dev/archery[release]"
+      - name: Update milestones
+        env:
+          GH_TOKEN: ${{ github.token }}
+        run: |
+          archery release update-milestones --execute
diff --git a/dev/README.md b/dev/README.md
index 275e1ae5c92..eada86f62be 100644
--- a/dev/README.md
+++ b/dev/README.md
@@ -33,8 +33,42 @@ committer.
 
 ## How to Merge a Pull Request
 
-Please don't merge PRs using the GitHub Web interface. Instead, run
-the following command:
+Use the "Squash and merge" button of the GitHub Web interface. Before
+you merge, check that:
+
+* The pull request title is what you want as the commit title:
+  `GH-XXX: [Component] Title` or `MINOR: [Component] Title`. The
+  "PR Title" status of the Boring Cyborg app
+  (`.github/boring-cyborg.yml`) fails unless the title starts with
+  `GH-XXX` or `MINOR: ` but it doesn't block the merge.
+* The last line of the pull request description is
+  `* GitHub Issue: Closes #XXX`. The Boring Cyborg app writes it for a
+  pull request to `main` and GitHub closes the issue on merge because
+  of it. If the pull request fixes only a part of the issue, change
+  the line to `* GitHub Issue: Refs #XXX` before you merge: the issue
+  stays open. If the line doesn't say `Closes #XXX`, for example
+  because the app is down, change it or close the issue yourself.
+* The pull request description is what you want as the commit
+  message. Remove leftovers of the pull request template in the
+  merge dialog if needed.
+
+A scheduled GitHub Actions workflow (`Update issue milestones`,
+`.github/workflows/dev_update_milestones.yml`) runs
+`archery release update-milestones --execute` to set the milestone on
+closed issues referenced by `GH-XXX` commits since the previous major
+release. Existing issue milestones are retained, so set a milestone
+before or after merging if the pull request isn't targeted for the next
+major release. If the issue doesn't have a milestone, the workflow sets
+the major release matching the commit's branch (`maint-X.0.0` if
+already branched, otherwise the next major release). The workflow can
+also be triggered manually via `workflow_dispatch`.
+
+### Merge script
+
+The merge script is still available for now, but using the merge button
+is encouraged. It additionally adds `Authored-by:`, `Co-authored-by:`
+and `Signed-off-by:` trailers to the commit message. Run the following
+command:
 
 ```bash
 dev/merge_arrow_pr.sh
diff --git a/dev/archery/archery/release/cli.py 
b/dev/archery/archery/release/cli.py
index 58979406c33..079dd96c0ef 100644
--- a/dev/archery/archery/release/cli.py
+++ b/dev/archery/archery/release/cli.py
@@ -15,12 +15,19 @@
 # specific language governing permissions and limitations
 # under the License.
 
+import os
 import pathlib
 
 import click
+from git import Repo
 
 from ..utils.cli import validate_arrow_sources
-from .core import IssueTracker, Release
+from .core import (
+    IssueTracker,
+    Release,
+    count_committers,
+    update_milestones,
+)
 
 
 @click.group('release')
@@ -52,6 +59,36 @@ def release_curate(obj, version, minimal):
     click.echo(curation.render('console'))
 
 
[email protected]('committers')
[email protected]('previous_version')
[email protected]('version')
[email protected]_obj
+def release_committers(obj, previous_version, version):
+    """Count the pull requests of a release by who merged them."""
+    commit_range = f"apache-arrow-{previous_version}..apache-arrow-{version}"
+    commits = Repo(obj['repo']).iter_commits(commit_range)
+    committers = count_committers(commits, obj['issue_tracker'])
+    for name, count in committers:
+        click.echo(f"{count:6d}\t{name}")
+
+
[email protected]('update-milestones')
[email protected]('--dry-run/--execute', default=True,
+              help="Display milestone updates instead of applying them.")
[email protected]_obj
+def release_update_milestones(obj, dry_run):
+    """Set milestones on closed issues merged since the last major release."""
+    updates = update_milestones(
+        Repo(obj['repo']),
+        obj['issue_tracker'],
+        branch=os.getenv('ARCHERY_DEFAULT_BRANCH', 'main'),
+        dry_run=dry_run,
+    )
+    for issue_number, milestone in updates:
+        action = "Would set" if dry_run else "Set"
+        click.echo(f"{action} milestone {milestone} on #{issue_number}")
+
+
 @release.group('changelog')
 def release_changelog():
     """Release changelog."""
diff --git a/dev/archery/archery/release/core.py 
b/dev/archery/archery/release/core.py
index 3ce2110a550..0e08a4f6208 100644
--- a/dev/archery/archery/release/core.py
+++ b/dev/archery/archery/release/core.py
@@ -24,7 +24,7 @@ import re
 import warnings
 
 from git import Repo
-from github import Github
+from github import Github, GithubException
 from semver import VersionInfo as SemVer
 
 from ..utils.source import ArrowSources
@@ -146,6 +146,52 @@ class IssueTracker:
     def issue(self, key):
         return Issue.from_github(self.github_repo.get_issue(key))
 
+    def open_major_milestones(self):
+        return sorted(
+            (Version.parse(m.title), m)
+            for m in self.github_repo.get_milestones(state="open")
+            if re.fullmatch(r"\d+\.0\.0", m.title)
+        )
+
+    def set_milestone(self, number, milestone):
+        self.github_repo.get_issue(number).edit(milestone=milestone)
+
+    def query_nodes(self, numbers, selection, batch_size=50):
+        """Query issueOrPullRequest nodes in GraphQL batches."""
+        owner, name = self.github_repo.full_name.split("/", 1)
+        unique = list(dict.fromkeys(numbers))
+        nodes = {}
+        for i in range(0, len(unique), batch_size):
+            batch = unique[i:i + batch_size]
+            fields = " ".join(
+                f"n{n}: issueOrPullRequest(number: {n}) {{{selection}}}"
+                for n in batch
+            )
+            query = (
+                'query($owner: String!, $name: String!) '
+                f'{{repository(owner: $owner, name: $name) {{{fields}}}}}'
+            )
+            variables = {"owner": owner, "name": name}
+            try:
+                _, result = self.github_repo.requester.graphql_query(
+                    query, variables
+                )
+            except GithubException as exc:
+                data = getattr(exc, "data", None)
+                errors = (
+                    data.get("errors") if isinstance(data, dict) else None
+                )
+                if (errors and data.get("data") and
+                        all(err.get("type") == "NOT_FOUND"
+                            for err in errors)):
+                    result = data
+                else:
+                    raise
+            repository = result["data"]["repository"]
+            for n in batch:
+                nodes[n] = repository[f"n{n}"]
+        return nodes
+
 
 _TITLE_REGEX = re.compile(
     r"(?P<issue>(?P<project>(ARROW|PARQUET|GH))\-(?P<issue_id>(\d+)))?\s*:?\s*"
@@ -241,6 +287,151 @@ class Commit:
     def title(self):
         return self._title
 
+    @property
+    def github_issue_id(self):
+        if self.project == "GH" and self.issue_id:
+            return int(self.issue_id)
+        return None
+
+
+_PULL_REQUEST_NUMBER_REGEX = re.compile(r" \(#(\d+)\)$")
+
+
+def count_committers(commits, issue_tracker, batch_size=50):
+    """
+    Count the pull requests of the commits by who merged them.
+
+    We ask GitHub because commits merged with the merge button don't
+    have "Signed-off-by:" trailers.
+
+    Returns (name, count) pairs sorted by count (descending) and name.
+    """
+    # Release commits and direct pushes don't have a pull request number.
+    matches = (_PULL_REQUEST_NUMBER_REGEX.search(commit.summary)
+               for commit in commits)
+    numbers = [int(match.group(1)) for match in matches if match]
+
+    nodes = issue_tracker.query_nodes(
+        numbers,
+        "... on PullRequest {mergedBy {login ... on User {name}}}",
+        batch_size=batch_size,
+    )
+    counts = defaultdict(int)
+    for number in numbers:
+        node = nodes[number]
+        merger = node.get("mergedBy") if node is not None else None
+        if merger is None:
+            warnings.warn(f"#{number} doesn't have a merger. It isn't "
+                          "counted.")
+            continue
+        counts[merger.get("name") or merger["login"]] += 1
+    return sorted(counts.items(), key=lambda item: (-item[1], item[0]))
+
+
+def _find_ref(repo, name):
+    for candidate in (name, f"upstream/{name}", f"origin/{name}"):
+        if candidate in repo.refs:
+            return repo.refs[candidate]
+    return None
+
+
+def _plan_issue_milestones(repo, open_major, branch):
+    """Map GH issue numbers in commits since the last major tag to 
milestones."""
+    main_ref = _find_ref(repo, branch)
+    if main_ref is None:
+        raise ValueError(f"Branch `{branch}` not found in repository.")
+
+    major_tags = sorted(
+        (Version.parse(t.name.removeprefix("apache-arrow-")), t.name)
+        for t in repo.tags
+        if re.fullmatch(r"apache-arrow-\d+\.0\.0", t.name)
+    )
+    previous_tag = next(
+        (tag for v, tag in reversed(major_tags)
+         if not open_major or v < open_major[0][0]),
+        None,
+    )
+    if previous_tag is None:
+        raise ValueError("No released major version tag found in repository.")
+
+    branched = []
+    next_milestone = None
+    for version, milestone in open_major:
+        maint_ref = _find_ref(repo, f"maint-{version}")
+        if maint_ref is not None:
+            branched.append((milestone, maint_ref))
+        elif next_milestone is None:
+            next_milestone = milestone
+
+    base_ref = previous_tag
+    maint_summaries = set()
+    target_milestones = {}
+    for milestone, maint_ref in branched:
+        for raw_commit in repo.iter_commits(f"{base_ref}..{maint_ref.name}"):
+            maint_summaries.add(raw_commit.summary)
+            issue_number = Commit(raw_commit).github_issue_id
+            if issue_number is not None:
+                target_milestones[issue_number] = milestone
+        base_ref = maint_ref.name
+
+    missing_next_milestone = False
+    for raw_commit in repo.iter_commits(f"{base_ref}..{main_ref.name}"):
+        if raw_commit.summary in maint_summaries:
+            continue
+        issue_number = Commit(raw_commit).github_issue_id
+        if issue_number is None:
+            continue
+        if next_milestone is None:
+            missing_next_milestone = True
+            continue
+        target_milestones[issue_number] = next_milestone
+
+    return target_milestones, missing_next_milestone
+
+
+def update_milestones(repo, issue_tracker, branch="main", dry_run=False,
+                      batch_size=50):
+    """
+    Set milestones on closed GitHub issues merged since the last major release.
+
+    Only closed issues without an existing milestone (and not closed as
+    NOT_PLANNED) are updated. Commits in an open major maintenance branch
+    (``maint-X.0.0``) get ``X.0.0``; commits only on ``branch`` get the
+    next open major release without a maintenance branch.
+
+    Returns a sorted list of ``(issue_number, milestone_title)`` pairs that
+    were updated (or would be updated when ``dry_run=True``).
+    """
+    target_milestones, missing_next_milestone = _plan_issue_milestones(
+        repo, issue_tracker.open_major_milestones(), branch
+    )
+    nodes = issue_tracker.query_nodes(
+        sorted(target_milestones),
+        "... on Issue {state stateReason milestone {number}}",
+        batch_size=batch_size,
+    )
+    updated = []
+    for number, node in nodes.items():
+        if node is None:
+            warnings.warn(f"#{number} not found. It isn't updated.")
+            continue
+        if (node.get("state") != "CLOSED" or
+                node.get("stateReason") == "NOT_PLANNED" or
+                node.get("milestone") is not None):
+            continue
+        milestone = target_milestones[number]
+        if not dry_run:
+            issue_tracker.set_milestone(number, milestone)
+        updated.append((number, milestone.title))
+
+    if missing_next_milestone:
+        raise ValueError(
+            "No open major release milestone without a maintenance branch "
+            "found."
+        )
+
+    return updated
+
 
 class Release:
 
diff --git a/dev/archery/archery/release/tests/test_release.py 
b/dev/archery/archery/release/tests/test_release.py
index fae2bdcea04..a2ae48d14ea 100644
--- a/dev/archery/archery/release/tests/test_release.py
+++ b/dev/archery/archery/release/tests/test_release.py
@@ -15,11 +15,15 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from types import SimpleNamespace
+
+from github import GithubException
 import pytest
 
 from archery.release.core import (
     Release, MajorRelease, MinorRelease, PatchRelease,
-    IssueTracker, Version, Issue, CommitTitle, Commit
+    IssueTracker, Version, Issue, CommitTitle, Commit,
+    count_committers, update_milestones,
 )
 
 
@@ -355,3 +359,200 @@ def test_maintenance_patch_selection(fake_issue_tracker):
         '9123dadfd123bca7af4eaa9455f5b0d1ca8b929d',
     ]
     assert shas_to_pick == expected
+
+
+def _make_issue_tracker(nodes, milestones=(), not_found=()):
+    queries = []
+    edited = []
+
+    def graphql_query(query, variables):
+        queries.append((query, variables))
+        data, errors = {}, []
+        for number, node in nodes.items():
+            alias = f"n{number}"
+            if f"{alias}:" in query:
+                data[alias] = node
+                if number in not_found:
+                    errors.append({
+                        "type": "NOT_FOUND",
+                        "path": ["repository", alias],
+                        "message": f"Not found: {number}",
+                    })
+        payload = {"data": {"repository": data}}
+        if errors:
+            payload["errors"] = errors
+            raise GithubException(404, payload, {})
+        return {}, payload
+
+    def get_issue(number):
+        return SimpleNamespace(
+            edit=lambda **kw: edited.append((number, kw["milestone"].title))
+        )
+
+    tracker = object.__new__(IssueTracker)
+    tracker.github_repo = SimpleNamespace(
+        full_name="apache/arrow",
+        get_milestones=lambda state="open": [
+            m for m in milestones if state == "all" or m.state == state
+        ],
+        get_issue=get_issue,
+        requester=SimpleNamespace(graphql_query=graphql_query),
+    )
+    return tracker, queries, edited
+
+
+def test_count_committers():
+    commits = [SimpleNamespace(summary=s) for s in [
+        "GH-1: [C++] Title (#11)",
+        "GH-2: [Python] Title (#12)",
+        "GH-2: [Python] Reland (#12)",
+        "MINOR: [Release] Update versions for 2.0.0",
+        "GH-3: [R] Title (#13)",
+        "GH-4: [Docs] Title (#14)",
+        "GH-5: [CI] Mention (#10) in the middle",
+        "GH-6: [Ruby] Title (#15)",
+        "GH-7: [Go] Title (#16)",
+        "GH-8: [C++] Issue number (#17)",
+    ]]
+    nodes = {
+        11: {"mergedBy": {"login": "zoe", "name": "Zoe Z"}},
+        12: {"mergedBy": {"login": "bob", "name": "Bob B"}},
+        13: {"mergedBy": {"login": "zoe", "name": "Zoe Z"}},
+        # a user without a name: the login is used
+        14: {"mergedBy": {"login": "alice", "name": None}},
+        # no merger: not counted
+        15: {"mergedBy": None},
+        # not a user, for example a bot: the login is used
+        16: {"mergedBy": {"login": "carol"}},
+        # an issue rather than a pull request: not counted
+        17: {},
+    }
+    tracker, queries, _ = _make_issue_tracker(nodes)
+
+    with pytest.warns(UserWarning) as record:
+        committers = count_committers(commits, tracker, batch_size=4)
+
+    assert [str(w.message) for w in record] == [
+        "#15 doesn't have a merger. It isn't counted.",
+        "#17 doesn't have a merger. It isn't counted.",
+    ]
+    assert committers == [
+        ("Bob B", 2),
+        ("Zoe Z", 2),
+        ("alice", 1),
+        ("carol", 1),
+    ]
+    sel = "... on PullRequest {mergedBy {login ... on User {name}}}"
+    assert queries == [
+        (
+            'query($owner: String!, $name: String!) '
+            '{repository(owner: $owner, name: $name) {' +
+            " ".join(f"n{n}: issueOrPullRequest(number: {n}) {{{sel}}}"
+                     for n in batch) +
+            '}}',
+            {"owner": "apache", "name": "arrow"},
+        )
+        for batch in ([11, 12, 13, 14], [15, 16, 17])
+    ]
+
+
+def _make_fake_repo(commits_by_range, refs=("main",),
+                    tags=("apache-arrow-26.0.0", "apache-arrow-26.0.1")):
+    return SimpleNamespace(
+        tags=[SimpleNamespace(name=t) for t in tags],
+        refs={name: SimpleNamespace(name=name) for name in refs},
+        iter_commits=lambda r: iter(
+            SimpleNamespace(summary=s) for s in commits_by_range[r]
+        ),
+    )
+
+
+def _ms(title, number, state="open"):
+    return SimpleNamespace(
+        title=title, number=number, state=state, due_on=None
+    )
+
+
+def _issue(state="CLOSED", reason="COMPLETED", milestone=None):
+    return {"state": state, "stateReason": reason, "milestone": milestone}
+
+
+def test_update_milestones_with_maintenance_branch():
+    repo = _make_fake_repo(
+        refs=("main", "origin/maint-27.0.0"),
+        commits_by_range={
+            "apache-arrow-26.0.0..origin/maint-27.0.0": [
+                "GH-110: [CI] Direct maint commit (#11)",
+                "GH-103: [Python] Cherry-picked fix (#3)",
+                "GH-102: [C++] Partial fix (#2)",
+                "GH-101: [C++] Before branch cut (#1)",
+            ],
+            "origin/maint-27.0.0..main": [
+                "MINOR: [Release] Bump version",
+                "GH-109: [Dev] Typo issue number (#10)",
+                "GH-108: [Dev] Actually a PR (#9)",
+                "GH-107: [Dev] Closed not planned (#8)",
+                "GH-106: [Dev] Already milestoned (#7)",
+                "GH-105: [Docs] Still open (#6)",
+                "GH-104: [R] After branch cut (#5)",
+                "GH-102: [C++] Complete fix (#4)",
+                "GH-103: [Python] Cherry-picked fix (#3)",
+            ],
+        },
+    )
+    milestones = [
+        _ms("JS-0.4.0", 1, "closed"),
+        _ms("26.0.0", 75, "closed"),
+        _ms("26.0.1", 76),
+        _ms("27.0.0", 77),
+        _ms("28.0.0", 78),
+    ]
+    nodes = {
+        101: _issue(),
+        102: _issue(),
+        103: _issue(),
+        104: _issue(),
+        105: _issue(state="OPEN", reason=None),
+        106: _issue(milestone={"number": 76}),
+        107: _issue(reason="NOT_PLANNED"),
+        108: {},
+        109: None,
+        110: _issue(),
+    }
+    tracker, _, edited = _make_issue_tracker(
+        nodes, milestones=milestones, not_found=(109,)
+    )
+    expected = [
+        (101, "27.0.0"),
+        (102, "28.0.0"),
+        (103, "27.0.0"),
+        (104, "28.0.0"),
+        (110, "27.0.0"),
+    ]
+
+    with pytest.warns(UserWarning, match="#109 not found"):
+        assert update_milestones(
+            repo, tracker, dry_run=True, batch_size=4
+        ) == expected
+    assert edited == []
+
+    with pytest.warns(UserWarning, match="#109 not found"):
+        assert update_milestones(
+            repo, tracker, dry_run=False, batch_size=4
+        ) == expected
+    assert edited == expected
+
+
+def test_update_milestones_missing_next_major():
+    repo = _make_fake_repo(
+        refs=("main", "origin/maint-27.0.0"),
+        commits_by_range={
+            "apache-arrow-26.0.0..origin/maint-27.0.0": [],
+            "origin/maint-27.0.0..main": ["GH-301: [Dev] Fix"],
+        },
+    )
+    milestones = [_ms("26.0.0", 75, "closed"), _ms("27.0.0", 77)]
+    tracker, _, _ = _make_issue_tracker({}, milestones=milestones)
+
+    with pytest.raises(ValueError, match="No open major release milestone"):
+        update_milestones(repo, tracker, dry_run=True)
diff --git a/dev/archery/setup.py b/dev/archery/setup.py
index 0b2bbfcb89c..30c064ad951 100755
--- a/dev/archery/setup.py
+++ b/dev/archery/setup.py
@@ -35,7 +35,7 @@ extras = {
     'integration': ['cffi', 'numpy'],
     'integration-java': ['jpype1'],
     'numpydoc': ['numpydoc==1.1.0'],
-    'release': ['pygithub<2.9.0', jinja_req, 'semver', 'gitpython'],
+    'release': ['pygithub>=2.5.0,<2.9.0', jinja_req, 'semver', 'gitpython'],
 }
 extras['bot'] = extras['crossbow'] + ['pygithub<2.9.0']
 extras['all'] = list(set(functools.reduce(operator.add, extras.values())))
diff --git a/dev/merge_arrow_pr.py b/dev/merge_arrow_pr.py
index ba1a11ea8e0..989956aeb00 100755
--- a/dev/merge_arrow_pr.py
+++ b/dev/merge_arrow_pr.py
@@ -580,6 +580,11 @@ def get_pr_num():
 
 
 def cli():
+    print(
+        'WARNING: Using GitHub\'s "Squash and merge" button is now '
+        "recommended instead of this script. See dev/README.md for details.\n"
+    )
+
     # Location of your Arrow git clone
     ARROW_HOME = os.path.abspath(os.path.dirname(__file__))
     print(f"ARROW_HOME = {ARROW_HOME}")
diff --git a/dev/release/post-04-website.sh b/dev/release/post-04-website.sh
index 41a7ee4a04c..b8a6bbb43d8 100755
--- a/dev/release/post-04-website.sh
+++ b/dev/release/post-04-website.sh
@@ -35,6 +35,12 @@ if ! archery --help > /dev/null 2>&1; then
   exit 1
 fi
 
+. "${SOURCE_DIR}/utils-env.sh"
+
+# Without a token archery waits on the rate limit of GitHub for a long
+# time instead of failing.
+: "${GH_TOKEN:?GH_TOKEN is required to ask GitHub who merged the pull 
requests}"
+
 previous_version=$1
 version=$2
 
@@ -75,10 +81,11 @@ rough_n_development_months=$((
 git_tag=apache-arrow-${version}
 git_range=apache-arrow-${previous_version}..${git_tag}
 
-committers_command_line="git shortlog -sn --group=trailer:signed-off-by 
${git_range}"
 contributors_command_line="git shortlog -sn ${git_range}"
 
-committers=$(${committers_command_line})
+# Count the pull requests of the commits in ${git_range} by who merged
+# them. This asks GitHub: it needs GH_TOKEN.
+committers=$(archery release committers ${previous_version} ${version})
 contributors=$(${contributors_command_line})
 
 n_commits=$(git log --pretty=oneline ${git_range} | wc -l)
@@ -151,8 +158,7 @@ cat <<ANNOUNCE >> "${announce_file}"
 
 The following Apache committers merged contributed patches to the repository.
 
-\`\`\`console
-$ ${committers_command_line}
+\`\`\`text
 ANNOUNCE
 
 echo "${committers}" >> "${announce_file}"
diff --git a/docs/source/developers/continuous_integration/overview.rst 
b/docs/source/developers/continuous_integration/overview.rst
index 4ae0e97297c..a4b9c9c0685 100644
--- a/docs/source/developers/continuous_integration/overview.rst
+++ b/docs/source/developers/continuous_integration/overview.rst
@@ -53,6 +53,7 @@ The ``.yml`` files in ``.github/workflows`` are workflows 
which are run on GitHu
   - ``@github-actions crossbow submit ...`` - runs the specified Crossbow 
command
   - ``@github-actions rebase`` - rebases the PR onto the main branch
 - ``dev.yml`` - runs any time there is activity on a PR, or a PR is merged; it 
runs the linter and tests that the PR can be merged
+- ``dev_update_milestones.yml`` - runs on a schedule (and via 
``workflow_dispatch``); runs ``archery release update-milestones --execute`` to 
set the milestone on closed GitHub issues merged since the previous major 
release
 
 PR housekeeping (component labels, PR title validation and the GitHub issue 
link in the PR description) is handled by the `Boring Cyborg 
<https://github.com/kaxil/boring-cyborg>`_ GitHub App, configured in 
``.github/boring-cyborg.yml``.
 
diff --git a/docs/source/developers/overview.rst 
b/docs/source/developers/overview.rst
index 3b877502323..fe5447c3138 100644
--- a/docs/source/developers/overview.rst
+++ b/docs/source/developers/overview.rst
@@ -133,8 +133,13 @@ in the end. To make the review process smooth for 
everyone, try to
 
 When tests are passing and the pull request has been approved by the interested
 parties, a `committer <https://arrow.apache.org/committers/>`_
-will merge the pull request. This is done with a
-**command-line utility that does a squash merge**.
+will merge the pull request. This is done with a **squash merge**.
+
+The ``* GitHub Issue:`` line at the end of the pull request description is
+filled in automatically from the pull request title. For a pull request to
+``main`` it says ``Closes #XXX`` and GitHub closes the issue when the pull
+request is merged. If your pull request fixes only a part of the issue, change
+the line to ``* GitHub Issue: Refs #XXX`` so that the issue stays open.
 
 .. dropdown:: Details on squash merge
   :animate: fade-in-slide-down
@@ -147,9 +152,8 @@ will merge the pull request. This is done with a
   cherry-pick individual patches onto a maintenance branch.
 
   Your pull request will appear in the GitHub interface to have been "merged".
-  In the commit message of that commit, the merge tool adds the pull request
-  description, a link back to the pull request, and attribution to the 
contributor
-  and any co-authors.
+  The commit message includes the pull request description, a link to the
+  pull request, and attribution to the contributor and any co-authors.
 
 .. _ai-generated-code:
 
diff --git a/docs/source/developers/release.rst 
b/docs/source/developers/release.rst
index fbce61ae9d1..3c8c255fc98 100644
--- a/docs/source/developers/release.rst
+++ b/docs/source/developers/release.rst
@@ -99,14 +99,17 @@ assigned.
     # Setup gpg agent for signing binary artifacts
     source dev/release/setup-gpg-agent.sh
 
+    # Ensure closed issues have their milestone set before curating
+    archery release update-milestones --execute
+
     # Curate the release
     # The end of the generated report shows any GitHub issues with the wrong
     # version number assigned.
     archery release curate <version>
 
 Ensure a major version milestone for a follow up release is created on GitHub. 
This will
-automatically be used by our merge script as the new version for issues closed 
when
-the maintenance branch is created.
+automatically be used by ``archery release update-milestones`` as the new 
version for
+issues closed after the maintenance branch is created.
 
 Patch Releases
 ==============
@@ -400,7 +403,8 @@ Be sure to go through on the following checklist:
    :class-title: sd-fs-5
    :class-container: sd-shadow-md
 
-   Add a release note for the new version to our website and update the latest 
release information:
+   Add a release note for the new version to our website and update the latest 
release information.
+   The script reads ``GH_TOKEN`` from ``dev/release/.env`` to ask GitHub who 
merged the pull requests of the release:
 
    .. code-block:: Bash
 

Reply via email to