Skip to content

Commit e58d255

Browse files
mrmancjekyllbot
authored andcommitted
Fix #120 by adapting the GitHub repo regex (#147)
Merge pull request 147
1 parent 50d9bc8 commit e58d255

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/jekyll-github-metadata/repository_finder.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,14 @@ def git_remote_url
6161

6262
def nwo_from_git_origin_remote
6363
return unless Jekyll.env == "development" || Jekyll.env == "test"
64-
matches = git_remote_url.chomp(".git").match %r!github.com(:|/)([\w-]+)/([\w\.-]+)!
64+
matches = git_remote_url.chomp(".git").match github_remote_regex
6565
matches[2..3].join("/") if matches
6666
end
67+
68+
def github_remote_regex
69+
github_host_regex = Regexp.escape(Jekyll::GitHubMetadata::Pages.github_hostname)
70+
%r!#{github_host_regex}(:|/)([\w-]+)/([\w\.-]+)!
71+
end
6772
end
6873
end
6974
end

spec/repository_finder_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@
7676
expect(subject.send(:nwo_from_git_origin_remote)).to include("afeld/hackerhours.org")
7777
end
7878

79+
it "handles private github instance addresses" do
80+
allow(Jekyll::GitHubMetadata::Pages).to receive(:github_hostname).and_return "github.myorg.com"
81+
allow(subject).to receive(:git_remote_url).and_return <<-EOS
82+
origin https://github.myorg.com/myorg/myrepo.git (fetch)
83+
origin https://github.myorg.com/myorg/myrepo.git (push)
84+
EOS
85+
expect(subject.send(:nwo_from_git_origin_remote)).to include("myorg/myrepo")
86+
end
87+
7988
context "when git doesn't exist" do
8089
before(:each) do
8190
@old_path = ENV["PATH"]

0 commit comments

Comments
 (0)