From nobody Mon Apr 21 16:03:05 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Zh9Bd437Mz5sgY5; Mon, 21 Apr 2025 16:03:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Zh9Bd26k3z3Sbr; Mon, 21 Apr 2025 16:03:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745251385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7e7DzrE8pD4tlSa97i1sYziRvriekGP+VkcG6Wr1esM=; b=q7vUnyxVRH3VaooHuIuljGRlxUdCaOiesZFCguVjjf1/LxRS7lmAlIkg4b5Ii45a2z2NOb x0SkpjRKgX+cAeeDiYmf2p/T31OHskD65tIy2lGXp/QMjtZg/HveHYKqpC/4X3LYczR76k gO+Zps8ciF73xX3uZAf7NIPqShi1aMFRZmCdFjL+SngxGU92+o506ElG5zY8ZiFGSjJ5gO W8dzojF+iOdy9efhCfCy9qQTUSkIvy2ATXUZ97nRRyghk9ZfP8VKW3yQpPa2UpjBaBHVWW fXbgW0I/1j2o/MMQxVFA+HYKJh32UR4FD1n+VHONJToZjS99tNRZrxfd3+d46Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1745251385; a=rsa-sha256; cv=none; b=r9wJIFwANV2wwDN7dJWWKOs45wg/P242VCN7YOT2w26ncWx4vAKuFD1/cyPyzQH/zF/lLD uuWfcGznNrObsrYiY2s8eUn/muXPlu1YkcQG+7BTQ0d6v1hRbfenLnqYzbyrIg/yc5VqBM HR0fBGcCJtp2CqDQU/nuyNxC4aW+pFVi0+lIYDBfTkemlNsjlBrgVfy1AMPRvFWP6Vi/8g Gf84f1HXly7cdQB3sBqthfenkcFTmjfMULoTbIWLwP+Cxh9U22wzSXdJbOQrhzIeL10hRs YtQiIyMdP48CDKUhtONDMjOmDMhcH1aN3wZnqLxKwKdj5VZZA+pETTOBB63FCw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745251385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7e7DzrE8pD4tlSa97i1sYziRvriekGP+VkcG6Wr1esM=; b=OL2onmdtC1Ix2rL7bjfXd57H+5S/lVPY0B+/M76ikmD8R1pjzMpW0NmzxxnywW8ulbWcel +5iCz5zwFtPs4ahLw5EB5OLfvg0/yZehpnVtn7egpw3FbEkFWVzNlsQ4srDKr7DZDVerrI ETMzo/A4c6PegLbpPCXbNU2E9z9x3Qtciupi4m2F+nL6q2WG8UF4eB7NK0pP++f7y4kSCi lQW39Gb977Avwo7BHWSskrgnAbLTEKDq2h5LecgAqXwAMBKpT6YJtrT+PHmLWq3u8jFXEc N1GvQaFNhI20uZhH3iob/wIOmHYCNkQ+ep9LVspoewcULmB5g0xNsFm/5e+w6A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Zh9Bd1jrBzx1c; Mon, 21 Apr 2025 16:03:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 53LG35dU050569; Mon, 21 Apr 2025 16:03:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53LG358I050566; Mon, 21 Apr 2025 16:03:05 GMT (envelope-from git) Date: Mon, 21 Apr 2025 16:03:05 GMT Message-Id: <202504211603.53LG358I050566@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 9bb0dd4b8bb6 - main - gphr: Extremely experimental github landing scripts List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9bb0dd4b8bb6213555831acbac26d007b50a7524 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=9bb0dd4b8bb6213555831acbac26d007b50a7524 commit 9bb0dd4b8bb6213555831acbac26d007b50a7524 Author: Warner Losh AuthorDate: 2025-04-21 16:00:15 +0000 Commit: Warner Losh CommitDate: 2025-04-21 16:02:34 +0000 gphr: Extremely experimental github landing scripts These are the scripts I've been using to land github pull requests. They suck for me and likely are too painful for any other person to use. I share them to help facilitate collaboration to make the characterizations in this commit message a big lie. Sponsored by: Netflix --- tools/tools/git/ghpr/README | 5 +++ tools/tools/git/ghpr/ghpr-init.sh | 27 ++++++++++++++ tools/tools/git/ghpr/ghpr-push.sh | 39 +++++++++++++++++++++ tools/tools/git/ghpr/ghpr-stage.sh | 72 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 143 insertions(+) diff --git a/tools/tools/git/ghpr/README b/tools/tools/git/ghpr/README new file mode 100644 index 000000000000..e07d56b1e09b --- /dev/null +++ b/tools/tools/git/ghpr/README @@ -0,0 +1,5 @@ +These are totally experimental + +Shared for collaboration on writing them, if you aren't +in touch with Warner about them, you may find it's super +tough sledding to use them. diff --git a/tools/tools/git/ghpr/ghpr-init.sh b/tools/tools/git/ghpr/ghpr-init.sh new file mode 100644 index 000000000000..3b1d65c56fe2 --- /dev/null +++ b/tools/tools/git/ghpr/ghpr-init.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -e + +die() { + echo $* + exit 1 +} + +# Create a fresh branch for the staging tree. +BRANCH=${1:-staging} +base=main + +if [ "$(git config branch.${BRANCH}.opabinia)" = "true" ]; then + echo "Branch ${BRANCH} has already been initialized" + # Bail if the branch already exists +else + if git rev-parse --verify ${BRANCH} > /dev/null 2>&1; then + echo "Branch ${BRANCH} already exists, skipping creation" + else + # Create the branch and tag it as the one we're using for opabinia merging. + git checkout -b ${BRANCH} ${base} || die "Can't create ${BRANCH}" + fi +fi + +git config --add --type bool branch.${BRANCH}.opabinia true || die "Can't annotate" +git config --add branch.${BRANCH}.opabinia.base ${base} || die "Can't annotate" diff --git a/tools/tools/git/ghpr/ghpr-push.sh b/tools/tools/git/ghpr/ghpr-push.sh new file mode 100644 index 000000000000..21cd9b52e41b --- /dev/null +++ b/tools/tools/git/ghpr/ghpr-push.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +set -e + +die() { + echo $* + exit 1 +} + +staging=staging + +# Iteratively try to push all the branches, then push upstream. Repeat until the upstream +# push works... +while true; do + for pr in $(git config --get-all branch.${staging}.opabinia.prs); do + upstream=$(git config --get branch.${staging}.opabinia.${pr}.upstream) + upstream_branch=$(git config --get branch.${staging}.opabinia.${pr}.upstream-branch) + + git push $upstream HEAD:$upstream_branch --force || true # bare git push gives cut and paste line + done + + if ! git push --push-option=confirm-author freebsd HEAD:main; then + git fetch freebsd + git rebase freebsd/main ${stagig} + continue + fi + break +done + +# OK, pull and rebase to catchup to these changes... +git checkout main; +git pull --rebase + +# try to cleanup +for pr in $(git config --get-all branch.${staging}.opabinia.prs); do + git branch -D PR-${pr} + git config --remove-section branch.${staging}.opabinia.${pr} +done +git config --remove-section branch.${staging}.opabinia diff --git a/tools/tools/git/ghpr/ghpr-stage.sh b/tools/tools/git/ghpr/ghpr-stage.sh new file mode 100644 index 000000000000..df9eeeeea5a3 --- /dev/null +++ b/tools/tools/git/ghpr/ghpr-stage.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +set -e + +die() { + echo $* + exit 1 +} + +update_to_upstream() ( + local staging=$1 + local base=$2 + + git checkout ${base} + git pull --rebase + git rebase -i ${base} ${staging} +) + +PR=$1 +staging=staging + +[ -n "${PR}" ] || die "Need a pr" + +if [ "$(git config branch.${staging}.opabinia)" != "true" ]; then + die "Branch ${staging} has not been initialized" +fi + +base=$(git config branch.${staging}.opabinia.base) +[ -n "${base}" ] || die "No base set on ${staging}" + +if [ -z "$(git config --get-all branch.${staging}.opabinia.prs)" ]; then + # Update ${base} if prs list is empty + update_to_upstream ${staging} ${base} +else + # Otherwise checkout staging as is + git checkout ${staging} +fi + +# OK. We always have to create a new branch for the PR. We do this into +# ${base} first (since that's what gh pr checkout does). We then then rebase +# this branch onto the staging branch, doing the rebase rewriting along the +# way. This rather convoluted setup was selected over cherry-picking and/or +# pulling a formatted patch to apply because it always applies it correctly +# and then we use git's tools to merge, pushing the problems there rather than +# trying to deal with them ourselves here. + +# In the future, PR may be a list +# Also, error handling is annoying at best. + +git branch -D PR-$PR || true +gh pr checkout $PR -b PR-$PR + +upstream=$(git config branch.PR-$PR.pushRemote) +upstream_branch=$(git config branch.PR-$PR.merge | sed -e s=refs/heads/==) + +git rebase -i ${base} --onto ${staging} --exec 'env EDITOR=$HOME/bin/git-fixup-editor git commit --amend --trailer "Reviewed-by: imp" --trailer "Pull-Request: https://github.com/freebsd/freebsd-src/pull/'"$PR"'"' +# Save the upstream data +git config --add branch.${staging}.opabinia.prs ${PR} +git config --add branch.${staging}.opabinia.${PR}.upstream ${upstream} +git config --add branch.${staging}.opabinia.${PR}.upstream-branch ${upstream_branch} +# Move the staging branch to the new tip of the tree. +git checkout -B ${staging} HEAD + +# XXX need to somehow scrape the PR for approvals, translate that to FreeBSD's name +# and add that in the Reviewed-by stuff... that's done by hand... + +# Sanity check things... not 100% right, since it checks everything we're queued up so far... +tools/build/checkstyle9.pl ${base}..${staging} + +# Bump .Dd dates? +# run before/after igor? +# Anything else?