/ scripts / add_submodule.sh
add_submodule.sh
 1  #!/usr/bin/env bash
 2  
 3  # Copyright (c) 2018-2020 Status Research & Development GmbH. Licensed under
 4  # either of:
 5  # - Apache License, version 2.0
 6  # - MIT license
 7  # at your option. This file may not be copied, modified, or distributed except
 8  # according to those terms.
 9  
10  [ -z "$1" -o `echo "$1" | tr '/' '\n' | wc -l` != 2 ] && \
11  	{ echo "Usage: `basename $0` some/repo [destdir] # 'destdir' defaults to 'vendor/repo'"; exit 1; }
12  REPO="$1"
13  
14  DEST="vendor/${REPO#*/}"
15  [ -n "$2" ] && DEST="$2"
16  
17  git submodule add --force https://github.com/${REPO}.git "$DEST"
18  git config -f .gitmodules submodule.${DEST}.ignore untracked
19  git config -f .gitmodules submodule.${DEST}.branch master
20