# Maintainer: Øystein Krog <oystein.krog@gmail.com>
# Maintainer: Tom Schoonjans <Tom.Schoonjans@rfi.ac.uk>

_realname=hub
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.14.2
pkgrel=3
pkgdesc="hub introduces git to GitHub (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://hub.github.com"
msys2_repository_url="https://github.com/github/hub"
license=('spdx:MIT')
#TODO: change this when git-for-windows is upstreamed
#depends=('${MINGW_PACKAGE_PREFIX}-git')
depends=('git')
makedepends=("${MINGW_PACKAGE_PREFIX}-go")
options=('!strip')
source=(https://github.com/github/${_realname}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz
        update-x-sys.patch)
sha256sums=('e19e0fdfd1c69c401e1c24dd2d4ecf3fd9044aa4bd3f8d6fd942ed1b2b2ad21a'
            '27ea5c73e36003ed7feebce9f2519aa1ba147978467073fe6d3bfbe0debf7e49')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Nbp1 -i "${srcdir}/update-x-sys.patch"
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  export GOROOT=${MINGW_PREFIX}/lib/go
  make
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"

  make install prefix="${pkgdir}"${MINGW_PREFIX}

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}"/share/licenses/hub/LICENSE
  install -Dm644 etc/hub.bash_completion.sh "${pkgdir}${MINGW_PREFIX}"/share/bash-completion/completions/hub
  install -Dm644 etc/hub.zsh_completion "${pkgdir}${MINGW_PREFIX}"/share/zsh/site-functions/_hub
  install -Dm644 etc/hub.fish_completion "${pkgdir}${MINGW_PREFIX}"/share/fish/vendor_completions.d/hub.fish
}
