parent
acdb01b5f5
commit
2ac60d145d
@ -0,0 +1,53 @@ |
||||
#!/bin/sh |
||||
|
||||
set -e |
||||
|
||||
if [ $# -eq 0 ]; then |
||||
echo "No arguments provided. Aborting..." |
||||
exit 1 |
||||
fi |
||||
|
||||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then |
||||
echo "usage: ./getsauce.sh [-h] [mode <URL|repoName> [checkout]] |
||||
|
||||
Retrieves the source for you. |
||||
|
||||
Possible values for the arguments: |
||||
|
||||
mode git, github-tar |
||||
URL url of the repo |
||||
repoName name of the repo with user/org included (e.g. username/repo or organization/repo) |
||||
checkout tag, branch or complete hash of a commit |
||||
|
||||
Dependencies: curl jq ca-certificates git |
||||
" |
||||
exit 0 |
||||
fi |
||||
|
||||
if [ $# -lt 2 ]; then |
||||
echo "Arguments \"mode\" and \"URL/repoName\" not provided. Aborting..." |
||||
exit 1 |
||||
fi |
||||
|
||||
|
||||
GET_SRC_MODE=$1 |
||||
URL_REPONAME=$2 |
||||
[ ! -z ${3+x} ] && CHECKOUT=$3 |
||||
[ -z ${REPO_PATH+x} ] && REPO_PATH="project" |
||||
SRC_DIR_PATH="./" |
||||
TMP_DIR="tmp_extract" |
||||
|
||||
if [ $GET_SRC_MODE = "github-tar" ]; then |
||||
mkdir "${TMP_DIR}" |
||||
curl --silent --fail -L "https://api.github.com/repos/${URL_REPONAME}/tarball/${CHECKOUT}" -o - | tar xvz -f - -C "$SRC_DIR_PATH" || rm -rf "${TMP_DIR}" && exit 1 |
||||
mv "${TMP_DIR}"/* "${REPO_PATH}/" |
||||
elif [ $GET_SRC_MODE = "git" ]; then |
||||
TMP_POSITION="${PWD}" |
||||
git clone "${URL_REPONAME}" "${REPO_PATH}" |
||||
cd "${REPO_PATH}" |
||||
[ ! -z ${CHECKOUT+x} ] && git checkout "${CHECKOUT}" |
||||
cd "${TMP_POSITION}" |
||||
else |
||||
echo "Not valid mode" |
||||
exit 1 |
||||
fi |
Loading…
Reference in new issue