# Template file for 'micro'
pkgname=micro
version=1.4.0
revision=5
# This will need to be updated along with version as it cannot currently be
# obtained from git before fetching, and is necessary if the user is to make
# error reports upsteam.
_commithash=af520cf047a7296ec292f15aa04114ad9f9052ae
build_style=go
go_import_path="github.com/zyedidia/micro"
go_package="${go_import_path}/cmd/micro"
go_ldflags="-X main.Version=${version} -X 'main.CommitHash=${_commithash}' -X 'main.CompileDate=$(date)'"
hostmakedepends="git"
short_desc="A modern and intuitive terminal-based text editor"
maintainer="Diogo Leal <diogo@diogoleal.com>"
license="MIT"
homepage="https://micro-editor.github.io"

do_fetch() {
	# We need the git repository since dependencies are vendored in submodules.
	# These submodules aren't included in the tarball. Go get then tries to get
	# the current versions which will cause the build to fail.

	git clone --branch v${version} https://github.com/zyedidia/micro $wrksrc
	cd $wrksrc

	# Simulate normal fetch error messages
	head=$(git rev-parse HEAD)
	msg_normal "$pkgver: verifying checksum for https://github.com/zyedidia/micro"
	if [[ "$_commithash" != "$head" ]]; then
		echo
		msg_red "SHA256 mismatch for 'https://github.com/zyedidia/micro' :\n$head\n"
		exit 1
	fi

	git submodule update --init --recursive --recommend-shallow
}

post_install() {
	vlicense LICENSE
}
