#!/bin/sh
project="cups"
train=""
version=""
while test $ opt="$1"
shift
case "$opt" in
-project)
project="$1"
shift
;;
-tagonly)
train="tag"
;;
-train)
train="$1"
shift
;;
-*)
echo "Usage: submitcups [-project project] [-tagonly] [-train train] version"
exit 1
;;
*)
version="$opt"
;;
esac
done
if test "x$version" = x; then
echo "Usage: submitcups [-project project] [-tagonly] [-train train] version"
exit 1
fi
if test "x$train" = x; then
if test "$project" = cups_ios; then
build=`xcodebuild -sdk iphoneos -version ProductBuildVersion`
train=`xbs getTrainForBuild --embedded $build --quiet`
else
build=`xcodebuild -sdk macosx -version ProductBuildVersion`
train=`xbs getTrainForBuild $build --quiet`
fi
echo "Auto-detected train for submission is $train."
fi
git pull
if test "x`git checkout master | grep -e '^Your branch is ahead of' `" != x; then
echo Error: Local repository has checkins not pushed:
echo ""
git checkout master
echo ""
echo Push these changes before submitting.
exit 1
fi
if test "x`git status | grep -e '^ modified:' `" != x; then
echo Error: Local files have modifications:
echo ""
git status | grep -e '^ modified:'
echo ""
echo Commit these changes before submitting.
exit 1
fi
tagname="cups-$version"
if test "x`git tag | grep ^$tagname`" != x; then
echo "Tag for $tagname already exists..."
else
git tag -a $tagname -m "Tag $tagname"
git push origin $tagname
fi
if test "x$train" != xtag; then
xbs submitproject -git -url ssh://stash.sd.apple.com/img/cups.git -tag $tagname -project $project -version $version $train
fi