[MERGED] osmo-dev[master]: add fetch-gerrit-patch.sh, tweak READMEs

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Tue Sep 5 10:29:08 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: add fetch-gerrit-patch.sh, tweak READMEs
......................................................................


add fetch-gerrit-patch.sh, tweak READMEs

Change-Id: I6df4f3226af9087ef346de72cbcaa86a4d4d5e13
---
M README
M src/README
A src/fetch-gerrit-patch.sh
3 files changed, 87 insertions(+), 0 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved; Verified



diff --git a/README b/README
index a3ab68f..65dbf2e 100644
--- a/README
+++ b/README
@@ -52,3 +52,8 @@
 
 Remove osmocom built binaries and headers from given prefix,
 default is /usr/local.
+
+
+=== src/*
+
+Find other useful scripts in src/, see src/README.
diff --git a/src/README b/src/README
index 4444824..a2fbe81 100644
--- a/src/README
+++ b/src/README
@@ -2,6 +2,15 @@
 
 There are some handy scripts I use for my daily Osmocom development:
 
+ osmo-add-gerrit-hooks.sh
+	Look for git repositories in and below the current dir and install the
+	gerrit commit-msg hook in each one. This requires an ~/.ssh/config
+	entry, see top comment in the script.
+
+ fetch-gerrit-patch.sh
+	Pass a patch number seen on gerrit to fetch the latest patch set into
+	your git clone. See top comment in the script.
+
  ./g   run a git command in each source tree
  ./e   run an arbitrary shell command in each source tree
  ./st  show a brief branch and local mods status for each source tree
@@ -11,6 +20,38 @@
 
 Examples:
 
+
+-----------------------------------------------------------------------------
+
+git clone ssh://go/osmo-msc
+
+./osmo-add-gerrit-hooks.sh
++ cd /n/s/osmo/src/./osmo-msc/.git
++ [ ! -f hooks/commit-msg ]
++ scp go:hooks/commit-msg hooks/
+commit-msg                                                             100% 4688     4.6KB/s   00:00    
+
+
+-----------------------------------------------------------------------------
+
+
+cd osmo-msc
+../fetch-gerrit-patch.sh 3787
++ git fetch origin refs/changes/87/3787/2
+From ssh://go/osmo-msc
+ * branch            refs/changes/87/3787/2 -> FETCH_HEAD
++ git checkout -b 3787_2 FETCH_HEAD
+Switched to a new branch '3787_2'
+
+
+# or if you want an earlier patch set
+../fetch-gerrit-patch.sh 3787/1
+From ssh://go/osmo-msc
+ * branch            refs/changes/87/3787/1 -> FETCH_HEAD
++ git checkout -b 3787_1 FETCH_HEAD
+Switched to a new branch '3787_1'
+
+
 -----------------------------------------------------------------------------
 
 ./g fetch    # run 'git fetch' in each clone = fetch all from upstream
diff --git a/src/fetch-gerrit-patch.sh b/src/fetch-gerrit-patch.sh
new file mode 100755
index 0000000..0353461
--- /dev/null
+++ b/src/fetch-gerrit-patch.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+# fetch gerrit patch into new branch named like the patch number.
+#
+# Usage: go to a git clone and pass a patch number:
+#
+#   cd osmo-msc
+#   P 973
+# or
+#   P 973/2
+#
+# Will create new local branches '973_4' (if 4 is the latest patch set)
+# or '973_2', respectively.
+
+patch="$1"
+
+if [ -z "$patch" ]; then
+  echo "Usage: $0 1234[/5]"
+  exit 1
+fi
+
+if [ -z "$(echo "$patch" | grep '/')" ]; then
+  patch="/$patch/"
+fi
+
+if [ -z "$(echo "$patch" | grep '^/')" ]; then
+  patch="/$patch"
+fi
+
+last_set="$(git ls-remote origin "changes/*" | grep "$patch" | sed 's#.*/\([^/]*\)$#\1 &#' | sort -n | tail -n 1)"
+if [ -z "$last_set" ]; then
+  echo "Not found: $patch"
+  exit 1
+fi
+
+change_name="$(echo "$last_set" | sed 's/.*\(refs.*\)/\1/')"
+branch_name="$(echo "$change_name" | sed 's#refs/changes/../\([0-9]*\)/\([0-9]*\)#\1_\2#')"
+
+set -x
+git fetch origin "$change_name"
+git checkout -b "$branch_name" FETCH_HEAD
+

-- 
To view, visit https://gerrit.osmocom.org/3803
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6df4f3226af9087ef346de72cbcaa86a4d4d5e13
Gerrit-PatchSet: 1
Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list