name: Fix deprecated uses of ext namespace
on:
  push:
    branches-ignore:
      - 'dependabot/**'
jobs:
  check-namespaces:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v5
    - name: Check
      run: |
        shopt -s globstar
        sed -i -e 's/ext::function\b/std::function/g' **/*.[hc]pp
        sed -i -e 's/ext::bind\b/std::bind/g' **/*.[hc]pp
        sed -i -e 's/ext::ref\b/std::ref/g' **/*.[hc]pp
        sed -i -e 's/ext::cref\b/std::cref/g' **/*.[hc]pp
        sed -i -e 's/ext::placeholders\b/std::placeholders/g' **/*.[hc]pp
        sed -i -e 's/ext::tuple\b/std::tuple/g' **/*.[hc]pp
        sed -i -e 's/ext::make_tuple\b/std::make_tuple/g' **/*.[hc]pp
        sed -i -e 's/ext::get\b/std::get/g' **/*.[hc]pp
        sed -i -e 's/ext::tie\b/std::tie/g' **/*.[hc]pp
    - uses: peter-evans/create-pull-request@v7
      with:
        token: ${{ secrets.MACHINE_ACCOUNT_PAT }}
        push-to-fork: ${{ vars.MACHINE_ACCOUNT }}/QuantLib
        branch: fix-ext-namespace-${{ github.ref_name }}
        delete-branch: true
        commit-message: 'Fix deprecated uses of ext namespace'
        title: 'Fix deprecated uses of ext namespace'
        author: lballabio[bot] <224797326+lballabio-bot@users.noreply.github.com>
