Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be careful around trimming Git tags #17

Merged
merged 2 commits into from
Apr 5, 2018

Conversation

sigv
Copy link
Contributor

@sigv sigv commented Apr 5, 2018

This follows up #16.

'11.2.3' != '1.2.3'
'v1.2.3' == '1.2.3'

```
'11.2.3' != '1.2.3'
'v1.2.3' == '1.2.3'
```
lib/ra10ke.rb Outdated
@@ -61,7 +61,7 @@ def initialize(*args)
nil
end
end.select { |tag| !tag.nil? }.sort.last.to_s.downcase
latest_ref = tags.detect { |tag| tag.downcase == latest_tag || tag.downcase == latest_tag[1..-1] }
latest_ref = tags.detect { |tag| tag.downcase == latest_tag || (latest_tag[0] == 'v' && tag.downcase == latest_tag[1..-1]) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to do tags.detect { |tag| tag.downcase == latest_tag || "v#{tag.downcase}" == latest_tag } or even tags.detect { |tag| [tag.downcase, "v#{tag.downcase}"].include?(latest_tag) }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, makes sense.

Trimming off the 'v' letter from the latest version can be avoided
altogether by just trying to append that 'v' to the ref in question.

Credit for suggestion goes to @ekohl, thanks.
@tampakrap tampakrap merged commit 3c0f692 into voxpupuli:master Apr 5, 2018
@sigv sigv deleted the git-semverse-vtrim branch April 5, 2018 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants