melpa / package-build

Tools for assembling a package archive
https://github.com/melpa/melpa
25 stars 34 forks source link

Make sure the version regexp matches the tag. #54

Closed milkypostman closed 2 years ago

milkypostman commented 2 years ago

Before this change, for some reason unknown to me, if the string-match failed, the call to match-string would still return a result. A tag 0.16.0 with a regexp of foo/v\\(.*\\) was failing to match but was still return 0.16. as a result for the call to match-string.

With this change, match-string isn't even called if there is no string match.

This is related to melpa/melpa#7821

tarsius commented 2 years ago

This is because a failed `string-match' does not unset the match data, instead it merely forgoes overriding the existing match data:

  (progn
    (string-match "1" "1")
    (string-match "1" "2")
    (match-string 0 "3"))
  => "3"

I've also added a bit of cleanup.

milkypostman commented 2 years ago

Looks good to me. Feel free to merge whenever. Thanks!

tarsius commented 2 years ago

Done :grinning: