Skip to content

Commit

Permalink
Problem: can't find versions of ddlx
Browse files Browse the repository at this point in the history
Solution: specify a different version pattern

This is not strict SemVer, but that's okay.

Adds `version_pattern` to `git` and `github` DSLs
  • Loading branch information
yrashk committed Jan 19, 2025
1 parent 42f0395 commit a78c257
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/pgpm/package/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module Pgpm
class Package
module Git
Config = Data.define(:url, :download_version_tags, :tag_prefix)
Config = Data.define(:url, :download_version_tags, :tag_prefix, :version_pattern)

module ClassMethods
attr_reader :git_config
Expand All @@ -25,7 +25,7 @@ def package_versions
@tags ||=
::Git.ls_remote(git_config.url)["tags"].keys
.filter { |key| !key.end_with?("^{}") }
.filter { |key| key.match?(/^(#{prefix_re})#{SEMVER}/) }
.filter { |key| key.match?(/^(#{prefix_re})#{git_config.version_pattern || SEMVER}/) }
rescue StandardError
@tags ||= []
end
Expand All @@ -38,8 +38,8 @@ def package_versions
end
end

def git(url, download_version_tags: true, tag_prefix: /v?/)
@git_config = Config.new(url:, download_version_tags:, tag_prefix:)
def git(url, download_version_tags: true, tag_prefix: /v?/, version_pattern: nil)
@git_config = Config.new(url:, download_version_tags:, tag_prefix:, version_pattern:)
extend Methods
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/pgpm/package/git_hub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def source_url_directory_name
module ClassMethods
attr_reader :github_config

def github(name, download_version_tags: true, tag_prefix: /v?/)
def github(name, download_version_tags: true, tag_prefix: /v?/, version_pattern: nil)
@github_config = Config.new(name:, download_version_tags:)
include Pgpm::Package::Git
include Methods
git "https://github.com/#{@github_config.name}", download_version_tags:, tag_prefix:
git "https://github.com/#{@github_config.name}", download_version_tags:, tag_prefix:, version_pattern:
end
end

Expand Down
2 changes: 1 addition & 1 deletion packages/ddlx.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class Ddlx < Pgpm::Package
github "lacanoid/pgddl"
github "lacanoid/pgddl", tag_prefix: "", version_pattern: /(0|[1-9]\d*)\.(0|[1-9]\d*)/
end

0 comments on commit a78c257

Please sign in to comment.