Skip to content

Instantly share code, notes, and snippets.

@tjdett
Created January 6, 2012 05:13
Show Gist options
  • Save tjdett/1569124 to your computer and use it in GitHub Desktop.
Save tjdett/1569124 to your computer and use it in GitHub Desktop.
Migrate CoreTardis into MyTardis branch
#!/bin/bash
# NOTE: You can specify alternate locations environment variables
CORETARDIS_REPO=${CORETARDIS_REPO:-'https://github.com/aaryani/CoreTardis.git'}
MYTARDIS_REPO=${MYTARDIS_REPO:-'git://github.com/mytardis/mytardis.git'}
# Fork commit
FORK_BASE='9445c33ab383940fb4da556ff69fc21e5983ebdf'
# commit 9445c33ab383940fb4da556ff69fc21e5983ebdf
# Author: Ryan Braganza <ryan.braganza@gmail.com>
# Date: Thu Jul 28 04:15:18 2011 +0000
#
# ensure main fields shows up first in search fieldsets
#
# also includes some refactoring
#
#
# git-svn-id: http://mytardis.googlecode.com/svn/trunk@1714 1bbb43ac-ffe0-11de-8c0c-f1c8ac664a8e
# Clone CoreTardis
if [ -d CoreTardis_migration ]; then
rm -rf CoreTardis_migration
fi
git clone $CORETARDIS_REPO CoreTardis_migration
cd CoreTardis_migration
# Rename CoreTardis master to "coretardis"
git branch -m master coretardis
# Pull in MyTardis commits
git remote add mytardis $MYTARDIS_REPO
git fetch mytardis
git branch -f --track master mytardis/master
# Run through coretardis branch log, looking for a revision identical to the MyTardis base
MATCHING_COMMIT=''
for COMMIT in `git log --format="%H" coretardis`
do
# Check to see if the two commits have identical content
git diff --quiet $FORK_BASE $COMMIT
if [ $? == '0' ]; then
MATCHING_COMMIT=$COMMIT
echo "CoreTardis $MATCHING_COMMIT is the same as $FORK_BASE"
continue
fi
done
# Replace CoreTardis matching commit with the MyTardis one
git replace $MATCHING_COMMIT $FORK_BASE
# Rewrite history
git filter-branch
#!/bin/bash
# Modify as necessary
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "Steve Androulakis" ];
then
GIT_COMMITTER_NAME="Steve Androulakis";
GIT_AUTHOR_NAME="Steve Androulakis";
GIT_COMMITTER_EMAIL="steve.androulakis@gmail.com";
GIT_AUTHOR_EMAIL="steve.androulakis@gmail.com";
git commit-tree "$@";
else
git commit-tree "$@";
fi' --tag-name-filter cat -f -- --all
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "Steve Androulakis Squirrel" ];
then
GIT_COMMITTER_NAME="Steve Androulakis";
GIT_AUTHOR_NAME="Steve Androulakis";
GIT_COMMITTER_EMAIL="steve.androulakis@gmail.com";
GIT_AUTHOR_EMAIL="steve.androulakis@gmail.com";
git commit-tree "$@";
else
git commit-tree "$@";
fi' --tag-name-filter cat -f -- --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment