Skip to content

Instantly share code, notes, and snippets.

@tegan-lamoureux
Created October 1, 2018 05:24
Show Gist options
  • Save tegan-lamoureux/96482dd784f36a4848b201d0b014ac23 to your computer and use it in GitHub Desktop.
Save tegan-lamoureux/96482dd784f36a4848b201d0b014ac23 to your computer and use it in GitHub Desktop.
Will pull latest changes from Mozilla mercurial repo and apply them to our github repo, excluding our two working directories.
#!/bin/bash
# Summer-Fall Capstone Team-A
# Mozilla Mercurial --> Capstone Github Script
#
# Instructions: Run in an emty directory to initialize, or
# in a directory containing both the github
# repository and the mozilla repository to keep
# up to date.
# Warn the user this could mess things up~
echo "WARNING - This will potentially overwrite any changes to"
echo "destination toolkit other than those saved in"
echo "components/osfile and components/filewatcher."
echo
read -p "Are you sure? (y/N): " -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
# Check if mozilla-central exists. If not, pull from mercurial.
# If so, then update it.
if [ ! -d "mozilla-central" ]; then
hg clone https://hg.mozilla.org/mozilla-central
else
cd mozilla-central
hg pull
cd ..
fi
# Check if capstone repository exists. If not, clone.
# Otherwise, update.
if [ ! -d "Capstone_Team-A" ]; then
git clone https://github.com/gavin4/Capstone_Team-A.git
else
cd Capstone_Team-A
git pull
cd ..
fi
# Incrementally copy over updated toolkit files, skipping our working directories.
rsync -a --exclude components/osfile/ --exclude components/filewatcher mozilla-central/toolkit Capstone_Team-A
# Grab date for commit message.
DATE=`date '+%Y-%m-%d %H:%M:%S'`
# Add new files, commit, and push.
cd Capstone_Team-A
git add .
git commit -m "Auto-sync from toolkit script, ran: $DATE"
git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment