Skip to contentSkip to conversation

Change in openvpn[master]: dev-tools: Add new script to convert mails to Gerrit patches

Openvpn-devel flichtenheld (Code Review) 1 participant 1 message Mar 23 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1774268486000.I52773764e0f4056fe5367918a9b2e6720b165c21@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1585?usp=email

to review the following change.

Change subject: dev-tools: Add new script to convert mails to Gerrit patches
......................................................................

dev-tools: Add new script to convert mails to Gerrit patches

Also checks for some common issues.

Change-Id I52773764e0f4056fe5367918a9b2e6720b165c21

---
A dev-tools/gerrit-submit-from-mail.sh

1 file changed, 42 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/85/1585/1

dev-tools/gerrit-submit-from-mail.sh new file +42 -0
new file mode 100755
index 0000000..ac1988f
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# Assertions:
+#  - there is a remote called "gerrit" that can be used to
+#    pushed to gerrit. Create it with
+#    git remote add gerrit ssh://<yourgerritusername>@gerrit.openvpn.net:29418/openvpn.git
+# - the master branch does not contain pending commits, move them to branches
+#
+# Usage:
+# - Pipe mail to this script on stdin
+# - You can specify the target branch as the first argument to the script
+#   if it is not master.
+
+set -eu
+
+TARGET_BRANCH=${1:-master}
+SOURCE_DIR=$(dirname $(readlink -e "${BASH_SOURCE[0]}"))
+TIMESTAMP=$(date +%Y%M%dT%H%S)
+
+git -C $SOURCE_DIR checkout $TARGET_BRANCH
+git -C $SOURCE_DIR checkout -B mail-submit-${TIMESTAMP}
+git -C $SOURCE_DIR am
+
+warnings=0
+if git -C $SOURCE_DIR log -n1 --format=%an | grep -q "via Openvpn-devel"; then
+    echo WARNING: Author contains \"via Openvpn-devel\"
+    echo Try to get an actual email-adress from the submitter!
+    warnings=$((warnings + 1))
+fi
+
+if ! git -C $SOURCE_DIR log -n1 --format=%b | grep -qi "signed-off-by:"; then
+    echo WARNING: Signed-off-by: line missing
+    echo Consider adding it.
+    warnings=$((warnings + 1))
+fi
+
+if [ "$warnings" -ge 0 ]; then
+    echo Please fix the $warnings warnings above before pushing.
+    echo Push the changes with git -C $SOURCE_DIR push gerrit HEAD:refs/for/$TARGET_BRANCH
+else
+    echo git -C $SOURCE_DIR push gerrit HEAD:refs/for/$TARGET_BRANCH
+fi

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1585?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I52773764e0f4056fe5367918a9b2e6720b165c21
Gerrit-Change-Number: 1585
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>