#!/bin/bash


usage() 
{
cat << EOF >&2
Usage: `basename $0` [document_repo_name] 

Clone an IVOA document repository from your own fork.  
This script assumes that you have already forked the relevant 
document repository from https://github.com/ivoa-std into your 
own github account.

It clones the specified document repo (e.g., VOTable) and sets up the 
recommended remote names for it:

 - The original "origin" remote (what you're cloning) is 
   renamed to your GitHub user name.

 - A new remote called 'ivoa-std' is added for the forked repo at 
   https://github.com/ivoa-std
   The 'ivoa-std' remote can be used when you need to update your clone
   from that forked repository.

EOF
}

git_user="tomdonaldson"  # customize this or make it an argument
doc_repo=$1   # The name of the document repository (e,g, VOTable)

# Require exactly one argument
if [ $# -ne 1 ]; then
   echo "Incorrect # of arguments"
   usage
   exit 1
fi


# Clone the repository with the ivoatex submodule, then switch to that directory.
git clone --recurse-submodule https://github.com/${git_user}/${doc_repo}.git
cd ${doc_repo}

# Ensure the recommended remotes.
git remote rename origin ${git_user}
git remote add ivoa-std git://github.com/ivoa-std/${doc_repo}.git

# Show the remotes for informational purposes and to note success:
printf "\nNew remotes:\n"
git remote -v