extract fetchBuildScript to be shared between hook handler and rebuild commit handler