Don't edit commit history with migrate from tempest tool

This commit changes the migrate_from_tempest tool to not mess around
with the commit history. The previous approach in the tool isn't
actually something that we can do. The commit history we had when the
repository was created is the canonical past for tempest-lib and we
can't migrate over any other tempest commits directly, this was a
mistake on my part.

Moving forward we'll just have to refer to the commit sha1s from the
tempest repo in the commit message. This script will now just copy the
specified files from tempest and generate a commit message with the
complete list of sha1s from the tempest history.

Change-Id: I7e2b2a0543d113961598b33d23985a1082fbba9a
This commit is contained in:
Matthew Treinish
2014-09-16 17:12:19 -04:00
parent a7132fa2d7
commit 5f62c16d43

View File

@@ -1,16 +1,15 @@
#!/bin/bash #!/bin/bash
# #
# Use this script to move over a set of files from tempest master with commit # Use this script to move over a set of files from tempest master into
# history into the tempest lib. You must only do this for files that haven't # tempest-lib with the commit history for the files in the commit message.
# been migrated over already. # This should only be done for files that haven't been migrated over already.
#
# To use: # To use:
# 1. Create a new branch in the tempest-lib repo so not to destroy your current # 1. Create a new branch in the tempest-lib repo so not to destroy your current
# working branch # working branch
# 2. Run the script from the repo dir and specify the file paths relative to # 2. Run the script from the repo dir and specify the file paths relative to
# the root tempest dir(only code and unit tests): # the root tempest dir(only code and unit tests):
# #
# tools/migrate_from_tempest.sh tempest/ # tools/migrate_from_tempest.sh tempest/file.py tempest/sub_dir
function usage { function usage {
@@ -62,7 +61,7 @@ for file in $files; do
if git merge-base --is-ancestor $root $file_root; then if git merge-base --is-ancestor $root $file_root; then
fail=1 fail=1
break break
elif !git merge-base --is-ancestor $file_root $root; then elif ! git merge-base --is-ancestor $file_root $root; then
new_roots="$new_roots $root" new_roots="$new_roots $root"
fi fi
done done
@@ -95,22 +94,34 @@ fi
EOF EOF
) )
# Prune just the commits relevant to what is being migrated
git filter-branch --index-filter "$pruner" --parent-filter "$set_roots" --commit-filter "$skip_empty" HEAD git filter-branch --index-filter "$pruner" --parent-filter "$set_roots" --commit-filter "$skip_empty" HEAD
# Pull changes SHA1_LIST=`git log --oneline`
cd -
git remote add tempest-migrate $tmpdir
git pull tempest-migrate master
git remote rm tempest-migrate
# Move files and commit
cd -
file_list=''
for file in $files; do for file in $files; do
filename=`basename $file` filename=`basename $file`
if [ -n "$output_dir" ]; then if [ -n "$output_dir" ]; then
git mv $file "$output_dir/$filename" dest_file="$output_dir/$filename"
else else
git mv $file "tempest_lib/$filename" dest_file="tempest_lib/$filename"
fi
cp -r "$tmpdir/$file" "$dest_file"
git add "$dest_file"
if [[ -z "$file_list" ]]; then
file_list="$filename"
else
file_list="$file_list, $filename"
fi fi
done done
rm -r tempest # Cleanup temporary tempest repo
git add . rm -rf $tmpdir
git commit -m "Moved files from previous merge as part of tempest migration"
# Generate a migration commit
commit_message="Migrated $file_list from tempest"
pre_list=$"This migrates the above files from tempest. This includes tempest commits:"
post_list=$"to see the commit history for these files refer to the above sha1s in the tempest repository"
git commit -m "$commit_message" -m "$pre_list" -m "$SHA1_LIST" -m "$post_list"