# Maintainer: James Morris <jamesmorris2@gmail.com>

pkgname=git-filter-repo
pkgver=2.47.0
pkgrel=1
pkgdesc='Quickly rewrite git repository history (filter-branch replacement)'
arch=('any')
url='https://github.com/newren/git-filter-repo'
license=('MIT')
depends=('git' 'python')
source=("https://github.com/newren/git-filter-repo/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.xz")
noextract=("${pkgname}-${pkgver}.tar.xz")
sha256sums=('4662cbe5918196a9f1b5b3e1211a32e61cff1812419c21df4f47c5439f09e902')

prepare() {
	# tar chokes on a symlink in the contrib directory
	# We're not installing anything from there, so just don't bother with it
	bsdtar -x -f "${pkgname}-${pkgver}.tar.xz" --exclude '*contrib*'

	cd "${pkgname}-${pkgver}"
	sed -i 's|^#!/usr/bin/env python3$|#!/usr/bin/python3|' git-filter-repo
}

package() {
	cd "${pkgname}-${pkgver}"
	install -Dm0755 git-filter-repo "${pkgdir}/usr/bin/git-filter-repo"
	install -Dm0644 Documentation/man1/git-filter-repo.1 "${pkgdir}/usr/share/man/man1/git-filter-repo.1"
	install -Dm0644 Documentation/html/git-filter-repo.html "${pkgdir}/usr/share/doc/git/html/git-filter-repo.html"
}
