pkgautoversion: if multiple tags are present on commit, return earliest one

This fixes a bug where this wouldn't happen if the tags were on current
commit (i.e., when git describe returned <tag>-0-g<sha1>).
pkgautoversion: change version number computation

Now applies the following logic:
  * If ref is a tag, returns the ref
  * Otherwise, return an annotated tag attached to ref
  * Otherwise, returns [branch-g]<sha1>[-dirty]

If multiple tags are elegible to describe the ref, uses the
one that's the lowest when compared per-component (i.e.,
given tags "1.2.3", "1.2.4", and "1.12" it will use 1.2.3).

If --dirty is given, ref must be empty or HEAD.

Example versions:
	7.10.2.1
	master-gdeadbeef
	ticket.dm-1234-gdeadbeef