Skip to content

Instantly share code, notes, and snippets.

@kbinani
Last active September 16, 2015 06:26
Show Gist options
  • Save kbinani/d7794bab4ce58296b0cd to your computer and use it in GitHub Desktop.
Save kbinani/d7794bab4ce58296b0cd to your computer and use it in GitHub Desktop.
#!/bin/bash
function command {
echo "$@"
"$@"
if [ $? -ne 0 ]; then
echo "Error: command \"$@\" failed" >&2
exit 1
fi
}
function inplace_sed {
local regexp="$1"
local file="$2"
if [ "x$(uname -s)" = "xLinux" ]; then
command sed -i "$regexp" "$file"
else
command sed -i '' "$regexp" "$file"
fi
}
(
echo "**********************************************************************************"
date
echo "----------------------------------------------------------------------------------"
command pwd
echo "----------------------------------------------------------------------------------"
command git clean -xf
command git fetch origin
if [ "x$(uname -s)" = "xLinux" ]; then
TAB_CHAR="\\t"
else
TAB_CHAR="\\ "
fi
for tag in $(git tag | grep '^boost-[0-9]*\.[0-9]*\.[0-9]*$'); do
new_tag="gh-$tag"
num_existing_new_tag=$(git tag | grep $new_tag | wc -l)
if [ $num_existing_new_tag = "0" ]; then
echo "=================================================================================="
echo "creating $new_tag ..."
echo "----------------------------------------------------------------------------------"
echo "git checkout $tag"
if git checkout $tag; then
echo -n "" #ok
else
for file in $(git diff --name-only 2>/dev/null); do
command git checkout -- "$file"
command rm "$file"
done
command git checkout $tag
fi
command git checkout -- .
command git clean -xf
inplace_sed "s@^${TAB_CHAR}url = \.\./\(.*\)\.git\$@${TAB_CHAR}url = https://github.com/boostorg/\1.git@g" .gitmodules
command git add .gitmodules
command git commit -m "Change submodule url to https://github.com/boostorg/*"
command git tag $new_tag
command git push fork $tag $new_tag
sleep 10
fi
done
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment