You've already forked go-semantic-release
fix(github): fix baseURL for enterprise and test failures
This commit is contained in:
committed by
Felix Wiedmann
parent
382cb54bcb
commit
795f5d54ef
@@ -55,12 +55,12 @@ func New(c *config.GitHubProvider, checkConfig bool) (*Client, error) {
|
|||||||
client = github.NewClient(httpClient)
|
client = github.NewClient(httpClient)
|
||||||
} else {
|
} else {
|
||||||
// v25.0 of google github does not append prefixes for base and upload URLs
|
// v25.0 of google github does not append prefixes for base and upload URLs
|
||||||
if client, err = github.NewEnterpriseClient(c.CustomURL+"/api/v3", c.CustomURL+"/api/uploads/", httpClient); err != nil {
|
if client, err = github.NewEnterpriseClient(c.CustomURL+"/api/v3/", c.CustomURL+"/api/uploads/", httpClient); err != nil {
|
||||||
return &Client{}, err
|
return &Client{}, err
|
||||||
}
|
}
|
||||||
// NewEnterpriseClient(newest versions) adds prefix /api/v3 to base URL and /api/uploads to upload URL
|
// note: do not append find / to end of the url since all the url constructions using this
|
||||||
// So save the new base url here
|
// assume no trailing /
|
||||||
baseURL = client.BaseURL.String()
|
baseURL = c.CustomURL + "/api/v3"
|
||||||
}
|
}
|
||||||
return &Client{
|
return &Client{
|
||||||
config: c,
|
config: c,
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ func TestGetCommitURL(t *testing.T) {
|
|||||||
client, _ := New(&testOject.config, false)
|
client, _ := New(&testOject.config, false)
|
||||||
actualURL := client.GetCommitURL()
|
actualURL := client.GetCommitURL()
|
||||||
if testOject.config.CustomURL != "" {
|
if testOject.config.CustomURL != "" {
|
||||||
expectedURL := fmt.Sprintf("%s/%s/%s/commit/{{hash}}", testOject.config.CustomURL, testOject.config.User, testOject.config.Repo)
|
expectedURL := fmt.Sprintf("%s/api/v3/%s/%s/commit/{{hash}}", testOject.config.CustomURL, testOject.config.User, testOject.config.Repo)
|
||||||
assert.EqualValues(t, expectedURL, actualURL)
|
assert.EqualValues(t, expectedURL, actualURL)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -154,7 +154,7 @@ func TestGetCompareURL(t *testing.T) {
|
|||||||
client, _ := New(&testOject.config, false)
|
client, _ := New(&testOject.config, false)
|
||||||
actualURL := client.GetCompareURL("1", "2")
|
actualURL := client.GetCompareURL("1", "2")
|
||||||
if testOject.config.CustomURL != "" {
|
if testOject.config.CustomURL != "" {
|
||||||
expectedURL := fmt.Sprintf("%s/%s/%s/compare/%s...%s", testOject.config.CustomURL, testOject.config.User, testOject.config.Repo, "1", "2")
|
expectedURL := fmt.Sprintf("%s/api/v3/%s/%s/compare/%s...%s", testOject.config.CustomURL, testOject.config.User, testOject.config.Repo, "1", "2")
|
||||||
assert.EqualValues(t, expectedURL, actualURL)
|
assert.EqualValues(t, expectedURL, actualURL)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user