Skip to content

Instantly share code, notes, and snippets.

@furushchev
Created November 7, 2014 08:07
Show Gist options
  • Save furushchev/029df209cea03826349a to your computer and use it in GitHub Desktop.
Save furushchev/029df209cea03826349a to your computer and use it in GitHub Desktop.
ROS Package Reverter
#!/bin/bash
function abort() {
echo "error: $1"
echo "abort..."
exit 1
}
# find ws root
PKGPATHS=`rospack list | grep src`
if [ $PKGPATHS = "" ]; then
abort "could not found catkin workspace. check ROS_PACKAGE_PATH"
fi
PKGS=`echo $PKGPATHS | cut -d ' ' -f1`
BRANCH_CANDIDATES="$ROS_DISTRO-devel master develop"
for PKG in $PKGS; do
for BRANCH in $BRANCH_CANDIDATES; do
CURRENT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
git checkout $BRANCH
if [ $? -ne 1 ]; then
echo "package $PKG changed $CURRENT_BRANCH -> $BRANCH"
break
fi
done
done
echo 'All package are now ready to `wstool up`'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment