From 8c8ae147cc5a6fcfe975f4a2a0a7a0825c8e2bf6 Mon Sep 17 00:00:00 2001 From: Maksims Svecovs Date: Wed, 17 Jan 2024 22:02:39 +0000 Subject: [PATCH] [scripts] Adds return values to license script Adds return values to annotate-license script. Return values: 0 - default, nothing was changed 1 - reuse lint complains, but files haven't been modified 2 - files have been modified by the script and have to be staged for commit 3 - both 1 and 2 Signed-off-by: Maksims Svecovs --- scripts/annotate-license.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/annotate-license.sh b/scripts/annotate-license.sh index bdbee6276..4c27c0dac 100755 --- a/scripts/annotate-license.sh +++ b/scripts/annotate-license.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # SPDX-FileCopyrightText: 2023 Arm Limited and/or its affiliates # @@ -17,6 +17,13 @@ # compatible with the file type. # If any changes has been made as a result of running this script the user will # be asked to add changes to commit. +# Script return values: +# 0 - default, nothing was changed +# 1 - reuse lint complains, but files haven't been modified +# 2 - files have been modified by the script and have to be staged for commit +# 3 - both 1 and 2 + +set -u RED='\033[0;31m' GREEN='\033[0;32m' @@ -47,10 +54,14 @@ done # Run license check on the entire codebase reuse lint +EXIT_CODE="${?}" # Notify user if there were changes made to staging files for file in $(git diff --name-only); do if ! echo "${UNSTAGED}" | grep -q "\b${file}\b"; then echo -e "${GREEN}Please stage ${file} for the commit${NC}" + EXIT_CODE=$((${EXIT_CODE} | 2)) fi done + +exit "${EXIT_CODE}" -- GitLab