Skip to content

Commit 298eca2

Browse files
committed
Please welcome "gerrit-fetch-all"
A shell script to fetch all changesets from Gerrit This script allows to fetch all (open and closed) changesets from Gerrit. This can be useful for doing offline code review without access to the Gerit web interface, or to comparing differrent submitted changesets. Gerrit allows you to fetch individual changes into the git repository like this: git fetch https://review.openstack.org/p/openstack-ci/git-review refs/changes/84/5784/2 git checkout FETCH_HEAD This script fetches list of all "refs/changes/*" references from gerrit and then downloads them. For every patchset a branch will be created called change/5784/2 where 5784 is Gerrit changeset number and 2 is current patchset number. You can then compare changesets with a simple git diff change/5784/2 change/5784/3 (if they have the same parent) You should invoke the script giving it the name of the git "remote" that identifies the Gerrit instance the you fetch from: gerrit-fetch-all gerrit If no parameters are given, "review" is assumed default.
0 parents  commit 298eca2

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

README

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
A shell script to fetch all changesets from Gerrit
2+
3+
This script allows to fetch all (open and closed)
4+
changesets from Gerrit. This can be useful for
5+
doing offline code review without access to
6+
the Gerit web interface, or to comparing
7+
differrent submitted changesets.
8+
9+
10+
Gerrit allows you to fetch individual changes into
11+
the git repository like this:
12+
13+
git fetch https://review.openstack.org/p/openstack-ci/git-review refs/changes/84/5784/2
14+
git checkout FETCH_HEAD
15+
16+
This script fetches list of all "refs/changes/*"
17+
references from gerrit and then downloads them.
18+
19+
For every patchset a branch will be created called
20+
21+
change/5784/2
22+
23+
where 5784 is Gerrit changeset number and 2 is
24+
current patchset number.
25+
26+
You can then compare changesets with a simple
27+
28+
git diff change/5784/2 change/5784/3
29+
30+
(if they have the same parent)
31+
32+
You should invoke the script giving it the name
33+
of the git "remote" that identifies the Gerrit
34+
instance the you fetch from:
35+
36+
gerrit-fetch-all gerrit
37+
38+
If no parameters are given, "review" is assumed default.

gerrit-fetch-all

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#! /bin/sh
2+
REMOTE="${1-review}"
3+
git ls-remote "${REMOTE}" | grep /changes/ | awk '{print $2;}' | while read REF
4+
do
5+
git fetch "${REMOTE}" "${REF}"
6+
git branch `echo "${REF}" | sed 's#refs/changes/../#change/#'` FETCH_HEAD
7+
done

0 commit comments

Comments
 (0)