summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a50114b77f2ced6cb071a7d0a6f16e02e690204c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Maintainer: Carl Smedstad <carsme@archlinux.org>
# Contributor: Andy Weidenbaum <archbaum@gmail.com>

pkgname=gitlint
pkgver=0.19.1
pkgrel=3
pkgdesc="Git commit message linter"
arch=(any)
url="https://github.com/jorisroovers/gitlint"
license=(MIT)
depends=(
  python
  python-arrow
  python-click
  python-sh
)
makedepends=(
  python-build
  python-hatch-vcs
  python-hatchling
  python-installer
  python-wheel
)
checkdepends=(
  git
  python-pytest
)
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
sha256sums=('60de0fe764bd8fc86eb38990fb6704c5c4649a1fee574407b87b3c1471e12bd0')

_archive="$pkgname-$pkgver"

build() {
  cd "$_archive/gitlint-core"

  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
  python -m build --wheel --no-isolation

  rm -rf tmp_install
  python -m installer --destdir=tmp_install dist/*.whl

  # Completions
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  export PYTHONPATH="$PWD/tmp_install/$site_packages"
  local gitlint_cmd="$PWD/tmp_install/usr/bin/gitlint"
  _GITLINT_COMPLETE=bash_source $gitlint_cmd > gitlint.bash
  _GITLINT_COMPLETE=fish_source $gitlint_cmd > gitlint.fish
  _GITLINT_COMPLETE=zsh_source $gitlint_cmd > gitlint.zsh
}

check() {
  cd "$_archive/gitlint-core"

  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  export PYTHONPATH="$PWD:$PWD/tmp_install/$site_packages"
  pytest
}

package() {
  cd "$_archive/gitlint-core"

  python -m installer --destdir="$pkgdir" dist/*.whl

  install -Dm644 gitlint.bash "$pkgdir/usr/share/bash-completion/completions/gitlint"
  install -Dm644 gitlint.fish "$pkgdir/usr/share/fish/vendor_completions.d/gitlint.fish"
  install -Dm644 gitlint.zsh "$pkgdir/usr/share/zsh/site-functions/_gitlint"

  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}