lib/danger/commands/init.rb in danger-5.2.2 vs lib/danger/commands/init.rb in danger-5.3.0
- old
+ new
@@ -141,12 +141,17 @@
def considered_an_oss_repo?
@is_open_source == "open"
end
def current_repo_slug
- @git = GitRepo.new
- repo_matches = @git.origins.match(%r{([\/:])([^\/]+\/[^\/.]+)(?:.git)?$})
- (repo_matches[2] || "[Your/Repo]").strip
+ git = GitRepo.new
+
+ author_repo_regexp = %r{(?:[\/:])([^\/]+\/[^\/]+)(?:.git)?$}
+ last_git_regexp = /.git$/
+
+ matches = git.origins.match(author_repo_regexp)
+
+ matches ? matches[1].gsub(last_git_regexp, "").strip : "[Your/Repo]"
end
def setup_danger_ci
ui.header "Step 4: Add Danger for your CI"