#!/bin/bash

PATCHED_BRANCH=0.51.2+dppy0.7.0
BASE_BRANCH=0.51.2
PATCH_NAME=0002-PyDPPL.patch

clean() {
    rm -rf numba
}
create() {
    clean
    git clone https://github.com/IntelPython/numba.git numba
    cd numba
    git diff ${BASE_BRANCH}..${PATCHED_BRANCH} > ../${PATCH_NAME}
    cd ..
}
check() {
    cd numba
    git reset --hard
    git clean -xdf
    git checkout ${BASE_BRANCH}
    git apply ../${PATCH_NAME}
    git add -A
    git diff ${PATCHED_BRANCH} | wc -  # expected 0
    cd ..
}
push() {
    git add ${PATCH_NAME}
    git commit -m "Update PyDPPL patch"
    git push
}

create
check
clean
# push
