Skip to content
Snippets Groups Projects
Commit 4455ed79 authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

modified: bin/clone_subgroup

parent 2fb2448d
No related branches found
No related tags found
No related merge requests found
#!/bin/bash #!/bin/bash
ORG=controls%2Fepics%2Fiocs set -o nounset
ACCESS_TOKEN="${PERSONAL_ACCESS_TOKEN}" set -o errexit
curl --header "PRIVATE-TOKEN: $ACCESS_TOKEN" "https://eicweb.phy.anl.gov/api/v4/groups/$ORG/projects" \
| sed 's/,/\'$'\n''/g' \
| grep -e 'ssh_url_to_repo*' | cut -d \" -f 4 | xargs -L1 git clone
curl --header "PRIVATE-TOKEN: ${ACCESS_TOKEN}" https://eicweb.phy.anl.gov/api/v4/groups/controls/projects function print_the_help {
echo "USAGE: clone_subgroup -g GROUPID -t TOKEN"
echo " OPTIONS: "
echo " -g,--group-id The group id (below name on webpage)"
echo " -t,--token Personal acces token"
exit
}
function yes_or_no {
while true; do
read -p "$* [y/n]: " yn
case $yn in
[Yy]*) return 0 ;;
[Nn]*) echo "No entered" ; return 1 ;;
esac
done
}
ONLINE_ONLY=1
if [[ $# -eq 0 ]] ; then
print_the_help
exit
fi
GROUPID=
TOKEN=
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
shift # past argument
print_the_help
;;
-g|--group-id)
GROUPID="$2"
shift # past argument
shift # past value
;;
-t|--token)
TOKEN="$2"
shift # past argument
shift # past argument
;;
*) # unknown option
#POSITIONAL+=("$1") # save it in an array for later
echo "unknown option $1"
print_the_help
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
for repo in \
$(curl "https://eicweb.phy.anl.gov/api/v4/groups/${GROUPID}?private_token=${TOKEN}" \
| jq .projects[].ssh_url_to_repo \
| tr -d '"')
do
git clone $repo
done
#curl --header "PRIVATE-TOKEN: ${TOKEN}" https://eicweb.phy.anl.gov/api/v4/groups/controls/projects
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment