Sha256: f6dfbf9acd21daa28664a97b1967167c11ef0a1ecc4f9971744d268fc2fffca5
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
require "danger/ci_source/support/repo_info" module Danger class FindRepoInfoFromURL REGEXP = %r{ ://[^/]+/ (?<slug>[^/]+(/[^/]+){1,2}) (/(pull|merge_requests|pull-requests)/) (?<id>\d+) }x # Regex used to extract info from Bitbucket server URLs, as they use a quite different format REGEXPBB = %r{ (?:[\/:])projects \/([^\/.]+) \/repos\/([^\/.]+) \/pull-requests \/(\d+) }x # Regex used to extract info from Bitbucket server URLs, as they use a quite different format REGEXPBB = %r{ (?:[\/:])projects \/([^\/.]+) \/repos\/([^\/.]+) \/pull-requests \/(\d+) }x def initialize(url) @url = url end def call matched = url.match(REGEXPBB) if matched RepoInfo.new("#{matched[1]}/#{matched[2]}", matched[3]) else matched = url.match(REGEXP) if matched RepoInfo.new(matched[:slug], matched[:id]) end end end private attr_reader :url end end
Version data entries
5 entries across 5 versions & 1 rubygems