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

pkgname=git-filter-repo
pkgver=2.38.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=('db954f4cae9e47c6be3bd3161bc80540d44f5379cb9cf9df498f4e019f0a41a9')

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"
}
