msuraev submitted this change.

View Change

Approvals: Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve pespin: Looks good to me, but someone else must approve msuraev: Looks good to me, approved
build_srcpkg.py: add option to use git-review

Having an option to explicitly checkout sources for package from gerrit
using numeric ID comes in handy for testing changes.

Related: OS#4107
Change-Id: I403c2083ef8c3f6f966c5b376fb13ea46d8a7a2b
---
M scripts/obs/build_srcpkg.py
M scripts/obs/data/Dockerfile
M scripts/obs/lib/config.py
M scripts/obs/lib/git.py
M scripts/obs/lib/srcpkg.py
5 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/scripts/obs/build_srcpkg.py b/scripts/obs/build_srcpkg.py
index 066d370..262ead8 100755
--- a/scripts/obs/build_srcpkg.py
+++ b/scripts/obs/build_srcpkg.py
@@ -18,6 +18,8 @@
" upload to https://obs.osmocom.org."
f" Output dir: {lib.config.path_temp}/srcpkgs")
lib.add_shared_arguments(parser)
+ parser.add_argument("-g", "--gerrit-id", type=int, default=0,
+ help="clone particular revision from gerrit using given ID")
parser.add_argument("package", nargs="?",
help="package name, e.g. libosmocore or open5gs")
args = parser.parse_args()
@@ -43,7 +45,7 @@

if args.package:
lib.srcpkg.build(args.package, args.feed, args.git_branch, args.conflict_version,
- args.git_fetch)
+ args.git_fetch, args.gerrit_id)


if __name__ == "__main__":
diff --git a/scripts/obs/data/Dockerfile b/scripts/obs/data/Dockerfile
index d8bd9c5..f5d72cd 100644
--- a/scripts/obs/data/Dockerfile
+++ b/scripts/obs/data/Dockerfile
@@ -23,6 +23,7 @@
dpkg-dev \
fakeroot \
git \
+ git-review \
meson \
osc \
python3-setuptools \
diff --git a/scripts/obs/lib/config.py b/scripts/obs/lib/config.py
index 1e569ef..c9df74a 100644
--- a/scripts/obs/lib/config.py
+++ b/scripts/obs/lib/config.py
@@ -17,6 +17,7 @@
"fakeroot",
"find",
"git",
+ "git-review",
"meson",
"osc",
"rebar3",
diff --git a/scripts/obs/lib/git.py b/scripts/obs/lib/git.py
index 29c183b..8dc57ae 100644
--- a/scripts/obs/lib/git.py
+++ b/scripts/obs/lib/git.py
@@ -58,6 +58,13 @@
lib.run_cmd(["git", "reset", "--hard", branch], cwd=repo_path)


+def checkout_from_review(project, gerrit_id):
+ """ checkout a given gerrit ID """
+ repo_path = get_repo_path(project)
+ lib.run_cmd(["git", "review", "-s"], cwd=repo_path)
+ lib.run_cmd(["git", "review", "-d", str(gerrit_id)], cwd=repo_path)
+
+
def checkout_default_branch(project):
branch = lib.config.git_branch_default
if project in lib.config.git_branch_other:
diff --git a/scripts/obs/lib/srcpkg.py b/scripts/obs/lib/srcpkg.py
index 035cf81..159f4ed 100644
--- a/scripts/obs/lib/srcpkg.py
+++ b/scripts/obs/lib/srcpkg.py
@@ -117,10 +117,13 @@
f.write(f"{version}\n")


-def build(project, feed, branch, conflict_version, fetch):
+def build(project, feed, branch, conflict_version, fetch, gerrit_id=0):
lib.git.clone(project, fetch)
lib.git.clean(project)
- checkout_for_feed(project, feed, branch)
+ if gerrit_id > 0:
+ lib.git.checkout_from_review(project, gerrit_id)
+ else:
+ checkout_for_feed(project, feed, branch)
version = get_version_for_feed(project, feed, conflict_version)
epoch = get_epoch(project)
version_epoch = f"{epoch}:{version}" if epoch else version

3 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one.

To view, visit change 29427. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I403c2083ef8c3f6f966c5b376fb13ea46d8a7a2b
Gerrit-Change-Number: 29427
Gerrit-PatchSet: 4
Gerrit-Owner: msuraev <msuraev@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: msuraev <msuraev@sysmocom.de>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged