httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpl...@apache.org
Subject svn commit: r1890443 - in /httpd/site/trunk/tools/github: ./ README apply_backport_pr.sh apply_trunk_pr.sh create_pr.sh
Date Thu, 03 Jun 2021 18:56:11 GMT
Author: rpluem
Date: Thu Jun  3 18:56:11 2021
New Revision: 1890443

URL: http://svn.apache.org/viewvc?rev=1890443&view=rev
Log:
Commit a set of scripts that help dealing with GitHub PR's for backports or
PR's created for review before merging into trunk.
These scripts require the following tools (details in the script headers):

- curl
- svn
- git
- hub
- jq

* create_pr.sh:
  This script creates a pull request against the 2.4.x branch to backport
  the given Subversion revisions from trunk.

* apply_backport_pr.sh: 
  This script applies the pull request <PR number> to the Subversion working
  copy of the branch. It works best with PR's created by create_pr.sh.

* apply_trunk_pr.sh:
  This script applies the pull request <PR number> to the Subversion working
  copy of the trunk. 

More details can be found at the top of the scripts.

Added:
    httpd/site/trunk/tools/github/
    httpd/site/trunk/tools/github/README   (with props)
    httpd/site/trunk/tools/github/apply_backport_pr.sh   (with props)
    httpd/site/trunk/tools/github/apply_trunk_pr.sh   (with props)
    httpd/site/trunk/tools/github/create_pr.sh   (with props)

Added: httpd/site/trunk/tools/github/README
URL: http://svn.apache.org/viewvc/httpd/site/trunk/tools/github/README?rev=1890443&view=auto
==============================================================================
--- httpd/site/trunk/tools/github/README (added)
+++ httpd/site/trunk/tools/github/README Thu Jun  3 18:56:11 2021
@@ -0,0 +1,23 @@
+This directory contains a set of scripts that help dealing with GitHub PR's for
+backports or PR's created for review before merging into trunk.
+These scripts require the following tools (details in the script headers):
+
+- curl
+- svn
+- git
+- hub
+- jq
+
+* create_pr.sh:
+  This script creates a pull request against the 2.4.x branch to backport
+  the given Subversion revisions from trunk.
+
+* apply_backport_pr.sh: 
+  This script applies the pull request <PR number> to the Subversion working
+  copy of the branch. It works best with PR's created by create_pr.sh.
+
+* apply_trunk_pr.sh:
+  This script applies the pull request <PR number> to the Subversion working
+  copy of the trunk. 
+
+More details can be found at the top of the scripts.

Propchange: httpd/site/trunk/tools/github/README
------------------------------------------------------------------------------
    svn:eol-style = native

Added: httpd/site/trunk/tools/github/apply_backport_pr.sh
URL: http://svn.apache.org/viewvc/httpd/site/trunk/tools/github/apply_backport_pr.sh?rev=1890443&view=auto
==============================================================================
--- httpd/site/trunk/tools/github/apply_backport_pr.sh (added)
+++ httpd/site/trunk/tools/github/apply_backport_pr.sh Thu Jun  3 18:56:11 2021
@@ -0,0 +1,72 @@
+#!/bin/bash
+#
+# This script applies the pull request <PR number> to the Subversion working
+# copy of the branch. It requires that is executed in the root of the working
+# copy. Apart from applying the patch it also updates the mergeinfo property
+# if the commits in the PR have this information, e.g. the PR got created via
+# create_pr.sh and creates a possible commit message in a file named clog.
+# Requires curl, svn and jq be on the PATH.
+
+if [ "$#" -lt 1 ] ; then
+    echo "usage: $(basename $0) <PR number>"
+    exit
+fi
+
+if [ ! -d .svn ] ; then
+    echo "No Subversion working copy"
+    exit
+fi
+
+PR=$1
+
+DIFF_URL="https://github.com/apache/httpd/pull/$PR.diff"
+TRUNK="https://svn.apache.org/repos/asf/httpd/httpd/trunk"
+
+if curl -s -v -L -o /dev/null ${DIFF_URL} 2>&1 | grep -q "HTTP/1.1 404 Not Found"
; then
+    echo "Pull request $PR not found."
+    exit
+fi
+
+if ! curl -s -L ${DIFF_URL} | patch -p1 ; then
+    echo "Patching failed."
+    exit
+fi
+
+REVS=`curl -s https://api.github.com/repos/apache/httpd/pulls/${PR}/commits | jq .[].commit.message
| egrep -o "git-svn-id: ${TRUNK}@[0-9]+" | cut -f2 -d '@'`
+
+COMMITS=`echo -n $REVS | tr ' ' ,`
+
+svn merge --record-only -c ${COMMITS} ${TRUNK} .
+
+if [ -f clog ] ; then
+    mv -f clog clog~
+fi
+
+echo "Merge r$(echo $COMMITS | sed -e 's/,/, r/g') from trunk:" > clog
+
+for REV in ${REVS} ; do
+    svn log -r${REV} ${TRUNK} | sed '1,2d;$d' >> clog
+    RAUTH=`svn propget svn:author --revprop -r${REV} ${TRUNK}`
+
+    if [ -z "${AUTHOR}" ] ; then
+        AUTHOR="${RAUTH}"
+    fi
+    if [ "${RAUTH}" != "${AUTHOR}" ] ; then
+        AUTHOR="${AUTHOR}, ${RAUTH}"
+    fi
+done
+
+echo >> clog
+echo "Submitted by: ${AUTHOR}" >> clog
+echo "Reviewed by: ">> clog
+
+echo >> clog
+echo "Github: closes #${PR}" >> clog
+
+echo
+cat clog
+
+make update-changes
+
+grep --color=auto -i "skip ci" clog
+

Propchange: httpd/site/trunk/tools/github/apply_backport_pr.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpd/site/trunk/tools/github/apply_backport_pr.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: httpd/site/trunk/tools/github/apply_trunk_pr.sh
URL: http://svn.apache.org/viewvc/httpd/site/trunk/tools/github/apply_trunk_pr.sh?rev=1890443&view=auto
==============================================================================
--- httpd/site/trunk/tools/github/apply_trunk_pr.sh (added)
+++ httpd/site/trunk/tools/github/apply_trunk_pr.sh Thu Jun  3 18:56:11 2021
@@ -0,0 +1,38 @@
+#!/bin/bash
+#
+# This script applies the pull request <PR number> to the Subversion working
+# copy of the trunk. It requires that is executed in the root of the working
+# copy. Apart from applying the patch it also and creates a possible commit
+# message in a file named clog.
+# Requires curl, svn and jq be on the PATH.
+
+if [ "$#" -lt 1 ] ; then
+    echo "usage: $(basename $0) <PR number>"
+    exit
+fi
+
+if [ ! -d .svn ] ; then
+    echo "No Subversion working copy"
+    exit
+fi
+
+PR=$1
+
+DIFF_URL="https://github.com/apache/httpd/pull/$PR.diff"
+TRUNK="https://svn.apache.org/repos/asf/httpd/httpd/trunk"
+
+if curl -s -v -L -o /dev/null ${DIFF_URL} 2>&1 | grep -q "HTTP/1.1 404 Not Found"
; then
+    echo "Pull request $PR not found."
+    exit
+fi
+
+if ! curl -s -L ${DIFF_URL} | patch -p1 ; then
+    echo "Patching failed."
+    exit
+fi
+
+curl -s https://api.github.com/repos/apache/httpd/pulls/${PR}/commits | jq .[].commit.message
| perl -pe 's/^"//; s/"$//; s/\\n/\n/g; ' > clog
+
+echo >> clog
+echo "Github: closes #{$PR}" >> clog
+

Propchange: httpd/site/trunk/tools/github/apply_trunk_pr.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpd/site/trunk/tools/github/apply_trunk_pr.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: httpd/site/trunk/tools/github/create_pr.sh
URL: http://svn.apache.org/viewvc/httpd/site/trunk/tools/github/create_pr.sh?rev=1890443&view=auto
==============================================================================
--- httpd/site/trunk/tools/github/create_pr.sh (added)
+++ httpd/site/trunk/tools/github/create_pr.sh Thu Jun  3 18:56:11 2021
@@ -0,0 +1,82 @@
+#!/bin/bash
+#
+# This script creates a pull request against the 2.4.x branch to backport
+# the given Subversion revisions from trunk.
+# It requires that is executed in the root of a local clone of your fork
+# of https://github.com/apache/httpd.git.
+# In that clone two remotes are required:
+# - origin  : which points to your fork
+# - upstream: which points to https://github.com/apache/httpd.git
+# Furthermore you need to have remote tracking branches for the trunk and
+# 2.4.x branches in your clone that are tracked in your fork.
+# Requires git and hub be on the PATH.
+
+
+if [ "$#" -lt 1 ] ; then
+    echo "usage: $(basename $0) <revision number> [revision numbers] ..."
+    exit
+fi
+
+BRANCH_NAME=`echo "$@" | tr " " _`
+
+git fetch upstream trunk
+
+if ! git branch | grep -q $BRANCH_NAME ; then
+    git checkout 2.4.x
+    if [ "$?" -ne 0 ] ; then
+        exit
+    fi
+    git pull upstream 2.4.x
+    if [ "$?" -ne 0 ] ; then
+        exit
+    fi
+    git checkout -b $BRANCH_NAME
+    if [ "$?" -ne 0 ] ; then
+        exit
+    fi
+else
+    git checkout $BRANCH_NAME
+    if [ "$?" -ne 0 ] ; then
+        exit
+    fi
+fi
+
+for i in "$@" ; do
+#    COMMITS="$COMMITS $(git log --grep="git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@($i)"
--left-right upstream/trunk...$BRANCH_NAME  --cherry-pick -P --pretty=format:%H)"
+    POTENTIAL_COMMIT=$(git log --grep="git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@($i)"
--left-only upstream/trunk...$BRANCH_NAME  --cherry-pick -P --pretty=format:%H)
+    if [ -n "$POTENTIAL_COMMIT" ] ; then
+        CHERRY_CHECK=$(git log --grep="cherry picked from commit $POTENTIAL_COMMIT" --right-only
 upstream/trunk...$BRANCH_NAME -P --pretty=format:%H)
+        if [ -z "$CHERRY_CHECK" ] ; then
+            COMMITS="$COMMITS $POTENTIAL_COMMIT"
+        fi
+    fi
+done
+
+for i in $COMMITS ; do
+    git cherry-pick -x $i
+    if [ "$?" -ne 0 ] ; then
+        exit
+    fi
+done
+
+git push -u origin $BRANCH_NAME
+MESSAGE=`echo "$@" | sed -e 's/ /, r/g'`
+RESULT=`hub pull-request -b apache:2.4.x -m "Merge r${MESSAGE} from trunk"`
+echo $RESULT
+PR=`echo $RESULT | sed -e 's#.*/##'`
+
+cat <<EOF
+  *) module_name: What
+     Trunk version of patch:
+EOF
+
+for i in "$@" ; do
+    echo "        https://svn.apache.org/r$i"
+done
+
+cat <<EOF
+     Backport version for 2.4.x of patch:
+       https://patch-diff.githubusercontent.com/raw/apache/httpd/pull/$PR.diff
+     +1:
+EOF
+

Propchange: httpd/site/trunk/tools/github/create_pr.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpd/site/trunk/tools/github/create_pr.sh
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message