Merge pull request #18174 from Homebrew/gitlab-urls
This commit is contained in:
		
						commit
						83645e2917
					
				@ -790,7 +790,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
        tag = SharedAudits.gitlab_tag_from_url(url)
 | 
			
		||||
        tag ||= stable.specs[:tag]
 | 
			
		||||
        tag ||= stable.version
 | 
			
		||||
        tag ||= stable.version.to_s
 | 
			
		||||
 | 
			
		||||
        if @online
 | 
			
		||||
          error = SharedAudits.gitlab_release(owner, repo, tag, formula:)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										27
									
								
								Library/Homebrew/test/utils/shared_audits_spec.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								Library/Homebrew/test/utils/shared_audits_spec.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,27 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
require "utils/shared_audits"
 | 
			
		||||
 | 
			
		||||
RSpec.describe SharedAudits do
 | 
			
		||||
  describe "::gitlab_tag_from_url" do
 | 
			
		||||
    it "doesn't find tags in invalid urls" do
 | 
			
		||||
      url = "https://gitlab.com/a/-/archive/v1.2.3/a-v1.2.3.tar.gz"
 | 
			
		||||
      expect(described_class.gitlab_tag_from_url(url)).to be_nil
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "finds tags in basic urls" do
 | 
			
		||||
      url = "https://gitlab.com/a/b/-/archive/v1.2.3/b-1.2.3.tar.gz"
 | 
			
		||||
      expect(described_class.gitlab_tag_from_url(url)).to eq("v1.2.3")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "finds tags in urls with subgroups" do
 | 
			
		||||
      url = "https://gitlab.com/a/b/c/d/e/f/g/-/archive/2.5/g-2.5.tar.gz"
 | 
			
		||||
      expect(described_class.gitlab_tag_from_url(url)).to eq("2.5")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "finds tags in urls with special characters" do
 | 
			
		||||
      url = "https://gitlab.com/a.b/c-d_e/-/archive/2.5/c-d_e-2.5.tar.gz"
 | 
			
		||||
      expect(described_class.gitlab_tag_from_url(url)).to eq("2.5")
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
@ -197,9 +197,6 @@ module SharedAudits
 | 
			
		||||
 | 
			
		||||
  sig { params(url: String).returns(T.nilable(String)) }
 | 
			
		||||
  def self.gitlab_tag_from_url(url)
 | 
			
		||||
    url = url.to_s
 | 
			
		||||
    url.match(%r{^https://gitlab\.com/[\w-]+/[\w-]+/-/archive/([^/]+)/})
 | 
			
		||||
       .to_a
 | 
			
		||||
       .second
 | 
			
		||||
    url[%r{^https://gitlab\.com/(?:\w[\w.-]*/){2,}-/archive/([^/]+)/}, 1]
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user