Last active
October 27, 2026 16:47
-
-
Save bagder/67b2a08479f37e0e8fb3d49a02e771c5 to your computer and use it in GitHub Desktop.
github pull helper script to merge curl PRs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # converts "icing:tool-synthetic-error-handling" | |
| # to | |
| # "git pull git@github.com:icing/curl.git tool-synthetic-error-handling" | |
| # | |
| # or | |
| # "https://github.com/mvanslobbe/curl-fork/tree/perf/ws-mask-chunks" | |
| # to | |
| # "git pull git@github.com:mvanslobbe/curl-fork.git perf/ws-mask-chunks" | |
| WHAT="$1" | |
| if test -z "$WHAT"; then | |
| cat <<EOF | |
| ghpull.sh <branch name> | |
| Where branch name should use the format 'user:branch'. | |
| EOF | |
| exit | |
| fi | |
| pauthors=$(./scripts/delta | grep "^Commit authors" | tr -d ')' | awk '{ print $NF }') | |
| # default repo is curl | |
| repo="curl" | |
| https=$(echo $WHAT | grep ^https) | |
| if test -n "$https"; then | |
| # this is a https link to a specific repo and branch | |
| path=$(trurl "$WHAT" --get '{path}') | |
| user=$(echo $path | cut -d/ -f2) | |
| repo=$(echo $path | cut -d/ -f3) | |
| # skip the 'tree' component, then take the rest | |
| branch=$(echo $path | cut -d/ -f5-) | |
| # to mark it as a remote repo | |
| colon=":" | |
| else | |
| # this is just a branch | |
| # If there is no colon in there, it is a local branch | |
| colon=$(echo $WHAT | tr -cd :) | |
| user=$(echo $WHAT | cut -d: -f1) | |
| branch=$(echo $WHAT | cut -d: -f2) | |
| fi | |
| if test -n "$colon"; then | |
| # a remove repo | |
| git pull "git@github.com:$user/$repo.git" "$branch" | |
| if test $? -ne "0"; then | |
| echo "This was the pull command line:" | |
| echo "git pull git@github.com:$user/$repo.git $branch" | |
| exit | |
| fi | |
| else | |
| # a local branch | |
| git checkout $WHAT | |
| git checkout master | |
| git merge $WHAT --into-name master --no-edit | |
| fi | |
| git rebase -i origin/master | |
| nauthors=$(./scripts/delta | grep "^Commit authors" | tr -d ')' | awk '{ print $NF }') | |
| if test "$nauthors" -ne "$pauthors"; then | |
| message=$(git log -1 --format="%B") | |
| closes=$(echo $message | grep -Eo 'Closes #[0-9]+') | |
| url=$(echo $closes | sed 's!Closes \#!https://github.com/curl/curl/issues/!') | |
| author=$(git log -1 --format="%an") | |
| cat <<EOF | |
| Welcome $author as #curl commit author $nauthors: $url | |
| EOF | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment