-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat GHES hosted sources as github sources
When a dependency is hosted on GHES, previously it was not treated as a GitHub source, meaning that we would not check for releases/changelogs etc when requesting Metadata for the PR. This fixes that, by first parsing the URL, and then making a request to `<host>/status`, and checking for a `X-GitHub-Request-Id` header, which we return from GitHub Enterprise Server.
- Loading branch information
Showing
13 changed files
with
226 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,108 @@ | |
end | ||
end | ||
|
||
context "with a GitHub Enterprise URL" do | ||
before do | ||
stub_request(:get, "https://ghes.mycorp.com/status").to_return( | ||
status: 200, | ||
body: "GitHub lives!", | ||
headers: { | ||
Server: "GitHub.com", | ||
"X-GitHub-Request-Id": "24e4e058-fdab-5ff4-8d79-be3493b7fa8e" | ||
} | ||
) | ||
end | ||
let(:url) { "https://ghes.mycorp.com/org/abc" } | ||
its(:provider) { is_expected.to eq("github") } | ||
its(:repo) { is_expected.to eq("org/abc") } | ||
its(:directory) { is_expected.to be_nil } | ||
its(:branch) { is_expected.to be_nil } | ||
|
||
context "with a git protocol" do | ||
let(:url) { "ssh://[email protected]:org/abc" } | ||
its(:provider) { is_expected.to eq("github") } | ||
its(:repo) { is_expected.to eq("org/abc") } | ||
its(:directory) { is_expected.to be_nil } | ||
end | ||
|
||
context "with a trailing .git" do | ||
let(:url) { "https://ghes.mycorp.com/org/abc.git" } | ||
its(:provider) { is_expected.to eq("github") } | ||
its(:repo) { is_expected.to eq("org/abc") } | ||
its(:directory) { is_expected.to be_nil } | ||
end | ||
|
||
context "with a trailing ." do | ||
let(:url) { "https://ghes.mycorp.com/org/abc. " } | ||
its(:provider) { is_expected.to eq("github") } | ||
its(:repo) { is_expected.to eq("org/abc") } | ||
its(:directory) { is_expected.to be_nil } | ||
end | ||
|
||
context "with a trailing space" do | ||
let(:url) { "https://ghes.mycorp.com/org/abc " } | ||
its(:provider) { is_expected.to eq("github") } | ||
its(:repo) { is_expected.to eq("org/abc") } | ||
its(:directory) { is_expected.to be_nil } | ||
end | ||
|
||
context "with a trailing /" do | ||
let(:url) { "https://ghes.mycorp.com/org/abc/" } | ||
its(:provider) { is_expected.to eq("github") } | ||
its(:repo) { is_expected.to eq("org/abc") } | ||
its(:directory) { is_expected.to be_nil } | ||
end | ||
|
||
context "with a trailing quote" do | ||
let(:url) { "<a href=\"https://ghes.mycorp.com/org/abc\">" } | ||
its(:provider) { is_expected.to eq("github") } | ||
its(:repo) { is_expected.to eq("org/abc") } | ||
its(:directory) { is_expected.to be_nil } | ||
end | ||
|
||
context "with no directory" do | ||
let(:url) { "https://ghes.mycorp.com/org/abc/tree/master/readme.md" } | ||
its(:provider) { is_expected.to eq("github") } | ||
its(:repo) { is_expected.to eq("org/abc") } | ||
its(:directory) { is_expected.to be_nil } | ||
end | ||
|
||
context "with a directory" do | ||
let(:url) { "https://ghes.mycorp.com/org/abc/tree/master/dir/readme.md" } | ||
its(:provider) { is_expected.to eq("github") } | ||
its(:repo) { is_expected.to eq("org/abc") } | ||
its(:directory) { is_expected.to eq("dir") } | ||
its(:branch) { is_expected.to eq("master") } | ||
|
||
context "with the filename specified by a #" do | ||
let(:url) { "https://ghes.mycorp.com/org/abc/tree/master/dir#readme.md" } | ||
its(:provider) { is_expected.to eq("github") } | ||
its(:repo) { is_expected.to eq("org/abc") } | ||
its(:directory) { is_expected.to eq("dir") } | ||
end | ||
|
||
context "when not looking at the master branch" do | ||
let(:url) { "https://ghes.mycorp.com/org/abc/tree/custom/dir/readme.md" } | ||
its(:provider) { is_expected.to eq("github") } | ||
its(:repo) { is_expected.to eq("org/abc") } | ||
its(:directory) { is_expected.to eq("dir") } | ||
its(:branch) { is_expected.to eq("custom") } | ||
end | ||
end | ||
|
||
context "when the source is not GHES" do | ||
before do | ||
stub_request(:get, "https://not-ghes.mycorp.com/status").to_return( | ||
status: 200, | ||
body: "This is not GHES!", | ||
headers: { Server: "nginx" } | ||
) | ||
end | ||
let(:url) { "https://not-ghes.mycorp.com/org/abc" } | ||
it { is_expected.to be_nil } | ||
end | ||
end | ||
|
||
context "with a Bitbucket URL" do | ||
let(:url) do | ||
"https://bitbucket.org/org/abc/src/master/dir/readme.md?at=default" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters