Skip to content

Instantly share code, notes, and snippets.

@Technicus
Last active August 25, 2016 16:07
Show Gist options
  • Save Technicus/59e57c0edce8393255ab32e69dd6c833 to your computer and use it in GitHub Desktop.
Save Technicus/59e57c0edce8393255ab32e69dd6c833 to your computer and use it in GitHub Desktop.
Repository Management Scripts
#!/bin/bash
clear
# Check for arguments, and give feedback
if [ -z "$1" ]; then
printf "\n\tThis script will read the list-git.<account> file and download the git project"
printf "\n\tto the directory provided.\n"
printf "\n\t\tInsifficient arguments provided."
printf "\n\t\tUsage:"
printf "\n\t\t\t# ${0} list-git.<account> <download_directory>\n\n"
exit 1
fi
if [ -z "$2" ]; then
printf "\n\tThis script will read the list-git.<account> file and download the git project"
printf "\n\tto the directory provided.\n"
printf "\n\t\tInsifficient arguments provided."
printf "\n\t\tUsage:"
printf "\n\t\t\t# ${0} list-git.<account> <download_directory>\n\n"
exit 1
fi
# Assign the arguments to gitlist and working directory
gitList="$1"
workingDirectory="$2"
if [ -d "$workingDirectory" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
printf "\n\tThe directory is present.\n\n"
else
printf "\n\tThe directory is not present.\n"
printf "\n\tCreating ${workingDirectory}."
mkdir "$workingDirectory"
printf "\n\n"
fi
# Download repositories from Github listed in a file
filename="${gitList}"
printf "\t"
# (cd "${workingDirectory}" && exec pwd)
while read -r gitFile
do
printf "\t\tgit clone ${gitFile}"
# git clone "${gitFile}"
# (cd "${workingDirectory}" && `git checkout -f HEAD "${gitFile}"`)
(cd "${workingDirectory}" && `git clone "${gitFile}"`)
printf "\t\tgit cloned ${gitFile}\n\n"
done < "$filename"
printf "\n"
@Technicus
Copy link
Author

This script will query the Github API and return four files. The files will include URL links to the repositories, tar links to the repositories, zip links to the repositories, and git links to the repositories. All in plain text files.
Usage:

get_repository_links.sh < github_account >

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment