lib/danger/ci_source/bitrise.rb in danger-6.3.1 vs lib/danger/ci_source/bitrise.rb in danger-6.3.2
- old
+ new
@@ -19,11 +19,11 @@
#
# Add the `DANGER_GITHUB_API_TOKEN` to your workflow's [Secret App Env Vars](https://blog.bitrise.io/anyone-even-prs-can-have-secrets).
#
# ### bitbucket server and bitrsie
#
- # Danger will read the environemnt variable GIT_REPOSITORY_URL to construct the Bitbucket Server API URL
+ # Danger will read the environment variable GIT_REPOSITORY_URL to construct the Bitbucket Server API URL
# finding the project and repo slug in the GIT_REPOSITORY_URL variable. This GIT_REPOSITORY_URL variable
# comes from the App Settings tab for your Bitrsie App. If you are manually setting a repo URL in the
# Git Clone Repo step, you may need to set adjust this propery in the settings tab, maybe even fake it.
# The patterns used are `(%r{\.com/(.*)})` and `(%r{\.com:(.*)})` and .split(/\.git$|$/) to remove ".git" if the URL contains it.
#
@@ -46,16 +46,19 @@
end
def initialize(env)
self.pull_request_id = env["BITRISE_PULL_REQUEST"]
self.repo_url = env["GIT_REPOSITORY_URL"]
-
- if repo_url.include? ".com/"
- repo_matches = self.repo_url.match(%r{\.com/(.*)})[1].split(/\.git$|$/)[0]
- elsif repo_url.include? ".com:"
- repo_matches = self.repo_url.match(%r{\.com:(.*)})[1].split(/\.git$|$/)[0]
- end
+ matcher_url = self.repo_url
+
+ #If the URL contains https:// as :// leads to inaccurate matching. So we remove it and proceed to match.
+ if repo_url.include? "https://"
+ matcher_url["https://"] = ''
+ end
+
+ repo_matches = matcher_url.match(%r{([\/:])(([^\/]+\/)+[^\/]+?)(\.git$|$)})[2]
+
self.repo_slug = repo_matches unless repo_matches.nil?
end
end
end