Pádraig Brady <[email protected]> writes:

> On 19/06/2026 05:23, Collin Funk wrote:
>> Sam James <[email protected]> writes:
>> 
>>> I was going to make a comment on a recent commit
>>> (bd649cca23f30646a3856b47cd1c7afd1aeb6db3) but found there was no mail
>>> on the coreutils ML for me to reply to.
>
> I've just sent this email to the list for discussion.
> Note the diff does have the github PR discussion link
> in the commit message, if you wanted to comment there.

Looks good to me.

> BTW I use the attached script for pulling down a PR locally for
> review/adjustment before pushing, as merging on github is ineffective
> since we've only a mirror on github at present.

Makes sense. By the way, I reserved the "coreutils" organization on
codeberg in case we ever want a platform with pull requests and stuff in
the future [1]. Not advocating for that change, since email is fine with
me and Savannah is mostly okay nowadays with the git mirrors setup.

> #!/bin/sh
> set -e
>
> url=$1
> shift || { echo "Usage: ${0##*/} <github-pr-url> [git-am-flags...]" >&2; exit 
> 1; }
>
> pr_path=$(printf '%s' "$url" | sed -E 
> 's|https?://github\.com/([^/]+/[^/]+/pull/[0-9]+).*|\1|')
> [ "$pr_path" = "$url" ] && { echo "Invalid GitHub PR URL: $url" >&2; exit 1; }
>
> pr_url="https://github.com/${pr_path}";
>
> fetch() {
>     if command -v curl >/dev/null 2>&1; then
>         curl -fsSL "$1"
>     elif command -v wget >/dev/null 2>&1; then
>         wget -qO- "$1"
>     else
>         echo "curl or wget required" >&2; exit 1
>     fi
> }
>
> base=$(git rev-parse HEAD)
> fetch "${pr_url}.patch" | git am "$@"
>
> cmd='msg=$(git log -1 --format=%B) && '
> cmd=$cmd'new_msg=$(printf "%s\n" "$msg" | '
> cmd=$cmd'git interpret-trailers --no-divider '
> cmd=$cmd'--if-exists=addIfDifferent '
> cmd=$cmd'--trailer "Link: $PR_URL") && '
> cmd=$cmd'{ test "$msg" = "$new_msg" || printf "%s\n" "$new_msg" | '
> cmd=$cmd'git commit --amend -F -; }'
>
> PR_URL=$pr_url GIT_SEQUENCE_EDITOR='true' git rebase -i "$base" --exec "$cmd"

I vaguely remember GitHub having low rate limits for unauthenticated
users. If you run into it, you can do something like the following with
the API:

    $ PR=<PR>
    $ gh api --header "Accept: application/vnd.github.patch" \
        repos/coreutils/coreutils/pulls/$PR > pr.patch
    $ csplit -s -f patch- -b '%03d.patch' pr.patch \
        '/^From [0-9a-f]\{40\} Mon Sep 17 00:00:00 2001/' '{*}'
    $ rm patch-000.patch

You could also add a 'git send-email' between the commits that way.

Collin

[1] https://codeberg.org/coreutils

Reply via email to