Repository: realm/realm-swift
File: build.sh (Shell)

Code before:
	sed -i '' -e "s/TDB_VERSION_PATCH .*$/TDB_VERSION_PATCH $realm_ver_patch/" $version_file || exit 1
	exit 0
	;;

    "clean")
        auto_configure || exit 1
        $MAKE clean || exit 1
        if [ "$OS" = "Darwin" ]; then
            for x in $IPHONE_PLATFORMS; do
                $MAKE BASE_DENOM="$x" clean || exit 1
            done
            $MAKE BASE_DENOM="ios" clean || exit 1
            if [ -e "$IPHONE_DIR" ]; then
                echo "Removing '$IPHONE_DIR'"
                rm -fr "$IPHONE_DIR/include" || exit 1
                rm -f "$IPHONE_DIR/librealm-objc-ios.a" "$IPHONE_DIR/librealm-objc-ios-dbg.a" || exit 1
                rmdir "$IPHONE_DIR" || exit 1
            fi
        fi
        echo "Done cleaning"
        exit 0
        ;;

    "ci-clean")
        git reset --hard HEAD
        git clean -xfd
        (
            cd ../tightdb
            git reset --hard HEAD
            git clean -xfd
        )
        exit 0
        ;;

    "ci-test")
        mkdir -p test-reports
        (
            cd ../tightdb
            mkdir -p install
            sh build.sh config $(pwd)/install
            sh build.sh build-iphone
            sh build.sh build
            sh build.sh install
        )
        export REALM_CONFIG=../tightdb/install/bin/tightdb-config
        sh build.sh config
        sh build.sh build
        sh build.sh build-iphone
        sh build.sh ios-framework
        sh build.sh test-debug
        (

Review comment (suggestion):
Wouldn't it make sense to just check if there is anything checked out before the reset hard? (this is now run at users, instead of jenkins)


Code after:
	sed -i '' -e "s/TDB_VERSION_PATCH .*$/TDB_VERSION_PATCH $realm_ver_patch/" $version_file || exit 1
	exit 0
	;;

    "clean")
        auto_configure || exit 1
        $MAKE clean || exit 1
        if [ "$OS" = "Darwin" ]; then
            for x in $IPHONE_PLATFORMS; do
                $MAKE BASE_DENOM="$x" clean || exit 1
            done
            $MAKE BASE_DENOM="ios" clean || exit 1
            if [ -e "$IPHONE_DIR" ]; then
                echo "Removing '$IPHONE_DIR'"
                rm -fr "$IPHONE_DIR/include" || exit 1
                rm -f "$IPHONE_DIR/librealm-objc-ios.a" "$IPHONE_DIR/librealm-objc-ios-dbg.a" || exit 1
                rmdir "$IPHONE_DIR" || exit 1
            fi
        fi
        echo "Done cleaning"
        exit 0
        ;;

    "ci-clean")
        # DO NOT USE THIS TARGET! IT WILL RESET YOUR WORKAREA IN A NON REVERSIBLE WAY!
        git reset --hard HEAD
        git clean -xfd
        (
            cd ../tightdb
            git reset --hard HEAD
            git clean -xfd
        )
        exit 0
        ;;

    "ci-test")
        if [ "$(id -u)" != "0" ]; then
           echo "This target must be run as root or with sudo" 1>&2
           exit 1
        fi
        mkdir -p test-reports || exit 1
        (
            cd ../tightdb
            mkdir -p install
            sh build.sh config $(pwd)/install
            sh build.sh build-iphone
            sh build.sh build
            sh build.sh install
        ) || exit 1
        (
            export REALM_CONFIG=../tightdb/install/bin/tightdb-config