From 0eef68b01ebd19d311cf07c890878f90e516eb96 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Tue, 19 Dec 2023 16:38:30 +0100 Subject: [PATCH] Fix IndexError when calling subprocess --- .github/workflows/ci.yml | 2 +- .gitlab-ci.yml | 2 +- lizmap/tools.py | 24 +++++++++++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d16f728..e799a7fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,7 +107,7 @@ jobs: - name: Package and deploy the zip run: >- qgis-plugin-ci - -vv + -v release ${{ env.RELEASE_VERSION }} --github-token ${{ secrets.BOT_HUB_TOKEN }} --transifex-token ${{ secrets.TRANSIFEX_TOKEN }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cf1dff04..3b0b05cf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,7 @@ package-zip: script: - > qgis-plugin-ci - -vv + -v package ${VERSION} --plugin-repo-url https://packages.3liz.org/pub/lizmap-qgis-plugin/${STATUS}/ --transifex-token ${TX_TOKEN} diff --git a/lizmap/tools.py b/lizmap/tools.py index 3969144c..6cc55ffd 100755 --- a/lizmap/tools.py +++ b/lizmap/tools.py @@ -151,7 +151,13 @@ def current_git_hash() -> str: universal_newlines=True, encoding='utf8' ) - hash_number = git_show.communicate()[0].partition('\n')[0] + try: + hash_number = git_show.communicate()[0].partition('\n')[0] + except IndexError: + # Reported on redmine + # IndexError: list index out of range + hash_number = '' + if hash_number == '': hash_number = 'unknown' return hash_number @@ -169,7 +175,13 @@ def has_git() -> bool: universal_newlines=True, encoding='utf8' ) - output = git_show.communicate()[0].partition('\n')[0] + try: + output = git_show.communicate()[0].partition('\n')[0] + except IndexError: + # Reported on redmine + # IndexError: list index out of range + output = '' + return output != '' @@ -185,7 +197,13 @@ def next_git_tag(): universal_newlines=True, encoding='utf8' ) - tag = git_show.communicate()[0].partition('\n')[0] + try: + tag = git_show.communicate()[0].partition('\n')[0] + except IndexError: + # Reported on redmine + # IndexError: list index out of range + tag = '' + if not tag: return 'next' versions = tag.split('.')