Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- : '
- goal: install spr-paid-component from appropriate branch of sprinklr-app-client
- step 0: if current branch name is live then script will exit without doing anything
- becuase for live branch, spr-paid-component would have been added as a dependency with proper version number.
- step 1: Check if branch name as a argument is given or not :
- if given :
- clone from given branch name
- step 2: If branch name is not given or branch with given name not exist in sprinklr-app-client:
- clone from branch same as current branch name
- step 3: if branch as current branch name not exist in sprinklr-app-client :
- infer branch name with following strategy
- if branch name contains "hotfix" word
- inferred branch name is live
- else if branch name contains "release" word
- inferred branch name is master
- else
- inferred branch name is master
- clone from inferred branch
- '
- # for linebreak
- br(){
- echo ""
- }
- br
- echo "============================================================================"
- echo "Installing spr-paid-component from appropriate branch of sprinklr-app-client"
- echo "============================================================================"
- url=git@prod-gitlab.sprinklr.com:sprinklr/frontend/sprinklr-app-client.git
- nameOfCurrentBranch=$(git branch | grep "*" | awk '{ print $2}')
- # step 0
- if [ "$nameOfCurrentBranch" == "live" ]
- then
- br
- echo "Add spr-paid-component as a dependency in 'neo/package.json' with proper version number, if not added"
- exit;
- fi
- clone(){
- br
- echo "spr-paid-components cloning from branch: $1"
- git clone --depth 1 $url -b $1
- }
- # step 3
- infere_branch_name(){
- br
- echo "Inferring branch name from current branch..."
- if [[ "$nameOfCurrentBranch" =~ ^hotfix-.*$ ]]
- then
- inferredBranchName="live"
- elif [[ "$nameOfCurrentBranch" =~ ^release-.*$ ]]
- then
- inferredBranchName="master"
- else
- inferredBranchName="master"
- fi
- echo "Inferred branch name is: $inferredBranchName"
- }
- fallback(){
- clone $nameOfCurrentBranch || # step 2
- {
- br
- echo "$1 doesn't exist in sprinklr-app-client so trying to infer branch name from current branch"
- # step 3
- infere_branch_name
- clone "$inferredBranchName"
- }
- }
- cd node_modules
- rm -rf spr-paid-components
- mkdir spr-paid-components
- cd spr-paid-components
- if [ $# -ne 0 ] # if argument given
- then
- branch=$1 # take branch name from argument
- clone $branch || # step 1
- {
- br
- echo "Provided branch doesn't exist in sprinklr-app-client so trying to clone from branch name as current branch name"
- fallback
- }
- else # if argument not given given
- br
- echo "You haven't provided branch name so trying to clone from branch with name as current branch name"
- fallback
- fi
- mv sprinklr-app-client/packages/spr-space/* .
- rm -rf sprinklr-app-client
Add Comment
Please, Sign In to add comment