Turns out ADO pipelines makes a shallow clone of the repo, which means that there's only 1 commit, thus causing `git rev-list --count HEAD` to return 1.
To fix it, force the pipeline to fetch everything:
- checkout: self
fetchDepth: 0
persistCredentials: true
clean: false
displayName: Checkout
- script: |
git rev-list --count HEAD
displayName: "git count"