blob: d2560ac83991490a8d51e9127ea6b4b1887b0ac3 [file] [log] [blame]
garciadeblas26ccfbe2025-08-01 18:43:58 +02001#!/bin/bash
2#######################################################################################
3# Copyright ETSI Contributors and Others.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14# implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#######################################################################################
18
19if [ $# -lt 3 ] || [ $# -gt 4 ]; then
20 echo "Usage $0 <repo> <branch> <user> [<do_push>]"
21 echo "Example: $0 all master garciadeblas"
22 echo "Example: $0 NBI v18.0 garciadeblas false"
23 exit 1
24fi
25
26set -e -o pipefail
27
28BRANCH="$2"
29USER="$3"
30DO_PUSH="${4:-true}"
31
32modules="common IM NBI N2VC LCM MON PLA POL NG-SA RO osmclient tests"
33list=""
34for i in $modules; do
35 if [ "$1" == "$i" -o "$1" == "all" ]; then
36 list="$1"
37 break
38 fi
39done
40
41[ "$1" == "all" ] && list=$modules
42
43if [ -z "$list" ]; then
44 echo "Repo must be one of these: $modules all"
45 exit 1
46fi
47
48# Create a temporary folder
49TMP_DIR=$(mktemp -d)
50echo "Using temporary directory: $TMP_DIR"
51
52echo "Updating pip dependencies"
53for i in $list; do
54 echo "Updating pip dependencies for $i"
55 REPO_DIR="$TMP_DIR/$i"
56 if [ ! -d "$REPO_DIR" ]; then
57 git clone ssh://$USER@osm.etsi.org:29418/osm/$i "$REPO_DIR" && (cd "$REPO_DIR" && curl https://osm.etsi.org/gerrit/tools/hooks/commit-msg > .git/hooks/commit-msg ; chmod +x .git/hooks/commit-msg)
58 fi
59 pushd "$REPO_DIR"
60 git checkout $BRANCH
61 git pull --rebase
62 tox -e pip-compile
63 git add -u
64 git commit -s -m "Update pip dependencies"
65 git show HEAD --stat
66 git diff HEAD^ > "$TMP_DIR/$i.diff"
67 echo "===================" | tee -a "$TMP_DIR/all.diff"
68 echo "Showing diff for $i" | tee -a "$TMP_DIR/all.diff"
69 echo "===================" | tee -a "$TMP_DIR/all.diff"
70 git diff HEAD^ | tee -a "$TMP_DIR/all.diff"
71 if [ "$DO_PUSH" == "true" ]; then
72 echo "Pushing changes for $i"
73 git push origin $BRANCH
74 fi
75 popd
76done
77echo "All diffs saved in $TMP_DIR/all.diff"
78
79exit 0