summarylogtreecommitdiffstats
path: root/update_hash.sh
blob: 349d2b7feb5c963ed819355b20c1c9279b00c206 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash

function die() {
	echo "$@"
	exit 1
}

[ -f PKGBUILD ] || die "Could not find PKGBUILD"

tag="$(sed -n 's/^_tag="\?\([^"]*\)"\?.*$/\1/p' PKGBUILD)"
repo="$(sed -n 's/^_repo="\?\([^"]*\)"\?.*$/\1/p' PKGBUILD)"

commit="$(git ls-remote -q --tags "$repo" "$tag" | cut -f1 | tr -cd a-zA-Z0-9 )"

if [[ -z $commit ]] ; then
	die "could not find commit id for tag $tag on $repo"
else
	sed -i "s/^_commit=.*$/_commit=$commit/" PKGBUILD
fi