From 3915d125dc6d6e604462e4752bd3cb46cbb33804 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Diemer?= <stephane.diemer@ubicast.eu>
Date: Tue, 16 Jan 2018 09:12:26 +0100
Subject: [PATCH] Use stable brnach by default (refs #24053).

---
 global-conf.sh     | 18 +++++++++---------
 launcher.sh        |  2 ++
 tester.py          | 18 +++++++-----------
 update_envsetup.py |  8 +++++++-
 4 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/global-conf.sh b/global-conf.sh
index 65a1dcf8..998177f1 100644
--- a/global-conf.sh
+++ b/global-conf.sh
@@ -4,15 +4,7 @@
 
 # Default configuration values
 # ----------------------------
-
-# -- Constants --
-CYAN='\033[0;36m'
-PURPLE='\033[0;35m'
-BLUE='\033[0;34m'
-YELLOW='\033[0;32m'
-GREEN='\033[0;32m'
-RED='\033[0;31m'
-NC='\033[0;0m'
+ENVSETUP_BRANCH='stable'
 
 # -- System --
 # Skyreach in which system looks for packages
@@ -136,6 +128,14 @@ TESTER_MAX_INSTANCES=
 # separate values with commas
 TESTER_IGNORED_TESTS=
 
+# -- Constants --
+CYAN='\033[0;36m'
+PURPLE='\033[0;35m'
+BLUE='\033[0;34m'
+YELLOW='\033[0;32m'
+GREEN='\033[0;32m'
+RED='\033[0;31m'
+NC='\033[0;0m'
 
 # Upstream configuration override
 # -------------------------------
diff --git a/launcher.sh b/launcher.sh
index 246e7f2f..b7fb6234 100755
--- a/launcher.sh
+++ b/launcher.sh
@@ -23,6 +23,8 @@ echo "$version"
 
 # envsetup action calls
 init() {
+	python3 /root/envsetup/update_envsetup.py
+
 	python3 /root/envsetup/envsetup.py 31
 	python3 /root/envsetup/envsetup.py 32
 	python3 /root/envsetup/envsetup.py 33
diff --git a/tester.py b/tester.py
index 8e3276bc..6724ab8c 100755
--- a/tester.py
+++ b/tester.py
@@ -230,18 +230,14 @@ class Tester():
             log('Instances that will be tested: %s.' % ', '.join(ms_users))
             # Clone testing suite
             ms_path = os.path.join(path, 'ms-testing-suite')
-            if os.path.exists(ms_path):
-                log('Updating ms-testing-suite in "%s".' % ms_path)
-                os.chdir(ms_path)
-                # TODO:
-                # subprocess.check_call(['git', 'checkout', 'stable'])
-                subprocess.check_call(['git', 'pull', '--recurse-submodules'])
-                subprocess.check_call(['git', 'submodule', 'init'])
-                subprocess.check_call(['git', 'submodule', 'update', '--init', '--recursive'])
-                os.chdir(self.root_dir)
-            else:
+            if not os.path.exists(ms_path):
                 log('Cloning ms-testing-suite in "%s".' % ms_path)
-                subprocess.check_call(['git', 'clone', 'https://panel.ubicast.eu/git/mediaserver/ms-testing-suite.git', ms_path])
+                subprocess.check_call(['git', 'clone', '--recursive', 'https://panel.ubicast.eu/git/mediaserver/ms-testing-suite.git', ms_path])
+            log('Updating ms-testing-suite in "%s".' % ms_path)
+            os.chdir(ms_path)
+            subprocess.check_call(['git', 'pull', '--recurse-submodules'])
+            subprocess.check_call(['git', 'submodule', 'update', '--init', '--recursive'])
+            os.chdir(self.root_dir)
             # Add tests to list
             wowza_dir = '/usr/local/WowzaStreamingEngine'
             etc_lives_conf = '/etc/mediaserver/lives_conf.py'
diff --git a/update_envsetup.py b/update_envsetup.py
index 5532477a..3ebe7174 100755
--- a/update_envsetup.py
+++ b/update_envsetup.py
@@ -4,12 +4,18 @@ import os
 import subprocess
 import sys
 
+import utils
+
 
 if __name__ == '__main__':
+    branch = utils.get_conf('ENVSETUP_BRANCH') or 'stable'
     os.chdir(os.path.dirname(os.path.abspath(os.path.expanduser(__file__))))
     sys.stdout.write('Updating envsetup: ')
     sys.stdout.flush()
     subprocess.call('find . -name *.pyc -type f -delete', shell=True)
     subprocess.call('find . -name __pycache__ -type d -delete', shell=True)
-    subprocess.call('git pull', shell=True)
+    if branch:
+        subprocess.check_call(['git', 'checkout', branch])
+    subprocess.check_call(['git', 'pull', '--recurse-submodules'])
+    subprocess.check_call(['git', 'submodule', 'update', '--init', '--recursive'])
     subprocess.call('find . -type d -empty -delete', shell=True)
-- 
GitLab