From 54fdb267bc27783bcb84dd46591d3feb77c8e3fd Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Mon, 30 Aug 2021 15:31:39 +0300 Subject: [PATCH] GIT_BRANCH environment variable handling + add some docs --- scripts/export_src.sh | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/scripts/export_src.sh b/scripts/export_src.sh index 3f48a1f..b44f4e6 100755 --- a/scripts/export_src.sh +++ b/scripts/export_src.sh @@ -1,31 +1,49 @@ #!/bin/sh +# Description: +# Creates archive with source code of multiple repositories. +# +# Parameters: +# $1 - github repository name without suffix (project name). +# $2, $3, ..., $n - repository suffixes (platforms). +# +# Optional environment variables: +# GIT_BRANCH - branch to use. Default - master. +# +# Example of usage: +# export_src.sh TestProject ios android backend +# GIT_BRANCH="develop"; ./export_src.sh TestProject ios web +# + +if [ -z "${GIT_BRANCH}" ]; then + GIT_BRANCH="master" +fi + PROJECT_NAME=$1 -SRC_FOLDER_NAME=${PROJECT_NAME}-src-$(date +%F) -SRC_DIR=./${SRC_FOLDER_NAME} +SRC_FOLDER_NAME="${PROJECT_NAME}-src-$(date +%F)" +SRC_DIR="./${SRC_FOLDER_NAME}" COMMAND_LINE_ARGUMENTS=$@ clone_platform() { - PROJECT_DIR=$1 + PROJECT_NAME=$1 PLATFORM=$2 - git clone --recurse-submodules -j8 git@github.com:TouchInstinct/${PROJECT_DIR}-${PLATFORM}.git --branch master + git clone --recurse-submodules -j8 "git@github.com:TouchInstinct/${PROJECT_NAME}-${PLATFORM}.git" --branch "${GIT_BRANCH}" } -mkdir -p ${SRC_DIR} -cd ${SRC_DIR} +mkdir -p "${SRC_DIR}" +cd "${SRC_DIR}" for argument in ${COMMAND_LINE_ARGUMENTS} do - if [ $argument != $PROJECT_NAME ] - then + if [ $argument != $PROJECT_NAME ]; then platform=${argument} # all arguments after project name treated as platforms clone_platform ${PROJECT_NAME} ${platform} fi done find . -name ".git*" -print0 | xargs -0 rm -rf -zip -r ${SRC_FOLDER_NAME}.zip . +zip -r -q ${SRC_FOLDER_NAME}.zip . open .