Skip to content

Commit

Permalink
add one-off cases for hooks and pre-receive-hooks (github#16784)
Browse files Browse the repository at this point in the history
* add one-off cases for hooks and pre-receive-hooks

* add forum redirect

* update redirect test

* update 2.19-2.22 fixutres

* revert 2.18/2.19 changes

* remove dotcom test

* update dotcom test
  • Loading branch information
rachmari authored Dec 9, 2020
1 parent 910a94b commit 6a3d326
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
1 change: 1 addition & 0 deletions content/github/working-with-github-support/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Working with GitHub Support
redirect_from:
- /categories/working-with-github-support
- /forum
versions:
free-pro-team: '*'
---
Expand Down
21 changes: 20 additions & 1 deletion lib/redirects/get-docs-path-from-developer-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,25 @@ module.exports = function getDocsPathFromDeveloperPath (oldDeveloperPath, allRed
// oneoff redirect
const v3OrgPreReceiveHooks = '/v3/orgs/pre_receive_hooks'
if (newPath.endsWith(v3OrgPreReceiveHooks)) {
newPath = newPath.replace(v3OrgPreReceiveHooks, '/v3/enterprise-admin/org_pre_receive_hooks')
newPath = newPath.replace(v3OrgPreReceiveHooks, '/v3/enterprise-admin/organization_pre_receive_hooks')
}

// oneoff redirect
const v3RepoPreReceiveHooks = '/v3/repos/pre_receive_hooks'
if (newPath.endsWith(v3RepoPreReceiveHooks)) {
newPath = newPath.replace(v3RepoPreReceiveHooks, '/v3/enterprise-admin/repository_pre_receive_hooks')
}

// oneoff redirect
const v3OrgHooks = '/v3/orgs/hooks'
if (newPath.endsWith(v3OrgHooks)) {
newPath = newPath.replace(v3OrgHooks, '/v3/orgs/webhooks')
}

// oneoff redirect
const v3RepoHooks = '/v3/repos/hooks'
if (newPath.endsWith(v3RepoHooks)) {
newPath = newPath.replace(v3RepoHooks, '/v3/repos/webhooks')
}

// oneoff redirect for a dotcom developer path to Enterprise-only path on docs.github.com
Expand Down Expand Up @@ -46,6 +64,7 @@ module.exports = function getDocsPathFromDeveloperPath (oldDeveloperPath, allRed
.replace(/_/g, '-')
// this is a special oneoff replacement
.replace('org-pre-receive-hooks', 'organization-pre-receive-hooks')
.replace('repo-pre-receive-hooks', 'repository-pre-receive-hooks')
: lastSegment
}

Expand Down
22 changes: 11 additions & 11 deletions tests/fixtures/rest-redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
"/en/enterprise/2.20/v3/enterprise-admin/orgs": "/en/enterprise-server@2.20/rest/reference/enterprise-admin#orgs",
"/en/enterprise/2.20/v3/enterprise-admin/pre_receive_environments": "/en/enterprise-server@2.20/rest/reference/enterprise-admin#pre-receive-environments",
"/en/enterprise/2.20/v3/enterprise-admin/pre_receive_hooks": "/en/enterprise-server@2.20/rest/reference/enterprise-admin#pre-receive-hooks",
"/en/enterprise/2.20/v3/enterprise-admin/repo_pre_receive_hooks": "/en/enterprise-server@2.20/rest/reference/enterprise-admin#repo-pre-receive-hooks",
"/en/enterprise/2.20/v3/enterprise-admin/repo_pre_receive_hooks": "/en/enterprise-server@2.20/rest/reference/enterprise-admin#repository-pre-receive-hooks",
"/en/enterprise/2.20/v3/enterprise-admin/search_indexing": "/en/enterprise-server@2.20/rest/reference/enterprise-admin#search-indexing",
"/en/enterprise/2.20/v3/enterprise-admin/users": "/en/enterprise-server@2.20/rest/reference/enterprise-admin#users",
"/en/enterprise/2.20/v3/gists/comments": "/en/enterprise-server@2.20/rest/reference/gists#comments",
Expand All @@ -243,7 +243,7 @@
"/en/enterprise/2.20/v3/markdown": "/en/enterprise-server@2.20/rest/reference/markdown",
"/en/enterprise/2.20/v3/meta": "/en/enterprise-server@2.20/rest/reference/meta",
"/en/enterprise/2.20/v3/oauth_authorizations": "/en/enterprise-server@2.20/rest/reference/oauth-authorizations",
"/en/enterprise/2.20/v3/orgs/hooks": "/en/enterprise-server@2.20/rest/reference/orgs#hooks",
"/en/enterprise/2.20/v3/orgs/hooks": "/en/enterprise-server@2.20/rest/reference/orgs#webhooks",
"/en/enterprise/2.20/v3/orgs": "/en/enterprise-server@2.20/rest/reference/orgs",
"/en/enterprise/2.20/v3/orgs/members": "/en/enterprise-server@2.20/rest/reference/orgs#members",
"/en/enterprise/2.20/v3/orgs/outside_collaborators": "/en/enterprise-server@2.20/rest/reference/orgs#outside-collaborators",
Expand All @@ -267,13 +267,13 @@
"/en/enterprise/2.20/v3/repos/deployments": "/en/enterprise-server@2.20/rest/reference/repos#deployments",
"/en/enterprise/2.20/v3/repos/downloads": "/en/enterprise-server@2.20/rest/reference/repos#downloads",
"/en/enterprise/2.20/v3/repos/forks": "/en/enterprise-server@2.20/rest/reference/repos#forks",
"/en/enterprise/2.20/v3/repos/hooks": "/en/enterprise-server@2.20/rest/reference/repos#hooks",
"/en/enterprise/2.20/v3/repos/hooks": "/en/enterprise-server@2.20/rest/reference/repos#webhooks",
"/en/enterprise/2.20/v3/repos": "/en/enterprise-server@2.20/rest/reference/repos",
"/en/enterprise/2.20/v3/repos/invitations": "/en/enterprise-server@2.20/rest/reference/repos#invitations",
"/en/enterprise/2.20/v3/repos/keys": "/en/enterprise-server@2.20/rest/reference/repos#keys",
"/en/enterprise/2.20/v3/repos/merging": "/en/enterprise-server@2.20/rest/reference/repos#merging",
"/en/enterprise/2.20/v3/repos/pages": "/en/enterprise-server@2.20/rest/reference/repos#pages",
"/en/enterprise/2.20/v3/repos/pre_receive_hooks": "/en/enterprise-server@2.20/rest/reference/repos#pre-receive-hooks",
"/en/enterprise/2.20/v3/repos/pre_receive_hooks": "/en/enterprise-server@2.20/rest/reference/enterprise-admin#repository-pre-receive-hooks",
"/en/enterprise/2.20/v3/repos/releases": "/en/enterprise-server@2.20/rest/reference/repos#releases",
"/en/enterprise/2.20/v3/repos/statistics": "/en/enterprise-server@2.20/rest/reference/repos#statistics",
"/en/enterprise/2.20/v3/repos/statuses": "/en/enterprise-server@2.20/rest/reference/repos#statuses",
Expand Down Expand Up @@ -316,7 +316,7 @@
"/en/enterprise/2.21/v3/enterprise-admin/orgs": "/en/enterprise-server@2.21/rest/reference/enterprise-admin#orgs",
"/en/enterprise/2.21/v3/enterprise-admin/pre_receive_environments": "/en/enterprise-server@2.21/rest/reference/enterprise-admin#pre-receive-environments",
"/en/enterprise/2.21/v3/enterprise-admin/pre_receive_hooks": "/en/enterprise-server@2.21/rest/reference/enterprise-admin#pre-receive-hooks",
"/en/enterprise/2.21/v3/enterprise-admin/repo_pre_receive_hooks": "/en/enterprise-server@2.21/rest/reference/enterprise-admin#repo-pre-receive-hooks",
"/en/enterprise/2.21/v3/enterprise-admin/repo_pre_receive_hooks": "/en/enterprise-server@2.21/rest/reference/enterprise-admin#repository-pre-receive-hooks",
"/en/enterprise/2.21/v3/enterprise-admin/search_indexing": "/en/enterprise-server@2.21/rest/reference/enterprise-admin#search-indexing",
"/en/enterprise/2.21/v3/enterprise-admin/users": "/en/enterprise-server@2.21/rest/reference/enterprise-admin#users",
"/en/enterprise/2.21/v3/gists/comments": "/en/enterprise-server@2.21/rest/reference/gists#comments",
Expand All @@ -340,7 +340,7 @@
"/en/enterprise/2.21/v3/markdown": "/en/enterprise-server@2.21/rest/reference/markdown",
"/en/enterprise/2.21/v3/meta": "/en/enterprise-server@2.21/rest/reference/meta",
"/en/enterprise/2.21/v3/oauth_authorizations": "/en/enterprise-server@2.21/rest/reference/oauth-authorizations",
"/en/enterprise/2.21/v3/orgs/hooks": "/en/enterprise-server@2.21/rest/reference/orgs#hooks",
"/en/enterprise/2.21/v3/orgs/hooks": "/en/enterprise-server@2.21/rest/reference/orgs#webhooks",
"/en/enterprise/2.21/v3/orgs": "/en/enterprise-server@2.21/rest/reference/orgs",
"/en/enterprise/2.21/v3/orgs/members": "/en/enterprise-server@2.21/rest/reference/orgs#members",
"/en/enterprise/2.21/v3/orgs/outside_collaborators": "/en/enterprise-server@2.21/rest/reference/orgs#outside-collaborators",
Expand All @@ -364,13 +364,13 @@
"/en/enterprise/2.21/v3/repos/deployments": "/en/enterprise-server@2.21/rest/reference/repos#deployments",
"/en/enterprise/2.21/v3/repos/downloads": "/en/enterprise-server@2.21/rest/reference/repos#downloads",
"/en/enterprise/2.21/v3/repos/forks": "/en/enterprise-server@2.21/rest/reference/repos#forks",
"/en/enterprise/2.21/v3/repos/hooks": "/en/enterprise-server@2.21/rest/reference/repos#hooks",
"/en/enterprise/2.21/v3/repos/hooks": "/en/enterprise-server@2.21/rest/reference/repos#webhooks",
"/en/enterprise/2.21/v3/repos": "/en/enterprise-server@2.21/rest/reference/repos",
"/en/enterprise/2.21/v3/repos/invitations": "/en/enterprise-server@2.21/rest/reference/repos#invitations",
"/en/enterprise/2.21/v3/repos/keys": "/en/enterprise-server@2.21/rest/reference/repos#keys",
"/en/enterprise/2.21/v3/repos/merging": "/en/enterprise-server@2.21/rest/reference/repos#merging",
"/en/enterprise/2.21/v3/repos/pages": "/en/enterprise-server@2.21/rest/reference/repos#pages",
"/en/enterprise/2.21/v3/repos/pre_receive_hooks": "/en/enterprise-server@2.21/rest/reference/repos#pre-receive-hooks",
"/en/enterprise/2.21/v3/repos/pre_receive_hooks": "/en/enterprise-server@2.21/rest/reference/enterprise-admin#repository-pre-receive-hooks",
"/en/enterprise/2.21/v3/repos/releases": "/en/enterprise-server@2.21/rest/reference/repos#releases",
"/en/enterprise/2.21/v3/repos/statistics": "/en/enterprise-server@2.21/rest/reference/repos#statistics",
"/en/enterprise/2.21/v3/repos/statuses": "/en/enterprise-server@2.21/rest/reference/repos#statuses",
Expand Down Expand Up @@ -453,7 +453,7 @@
"/v3/migrations/users": "/en/free-pro-team@latest/rest/reference/migrations#users",
"/v3/oauth_authorizations": "/en/enterprise-server/rest/reference/oauth-authorizations",
"/v3/orgs/blocking": "/en/free-pro-team@latest/rest/reference/orgs#blocking",
"/v3/orgs/hooks": "/en/free-pro-team@latest/rest/reference/orgs#hooks",
"/v3/orgs/hooks": "/en/free-pro-team@latest/rest/reference/orgs#webhooks",
"/v3/orgs": "/en/free-pro-team@latest/rest/reference/orgs",
"/v3/orgs/members": "/en/free-pro-team@latest/rest/reference/orgs#members",
"/v3/orgs/migrations": "/en/free-pro-team@latest/rest/reference/orgs#migrations",
Expand All @@ -479,13 +479,13 @@
"/v3/repos/deployments": "/en/free-pro-team@latest/rest/reference/repos#deployments",
"/v3/repos/downloads": "/en/free-pro-team@latest/rest/reference/repos#downloads",
"/v3/repos/forks": "/en/free-pro-team@latest/rest/reference/repos#forks",
"/v3/repos/hooks": "/en/free-pro-team@latest/rest/reference/repos#hooks",
"/v3/repos/hooks": "/en/free-pro-team@latest/rest/reference/repos#webhooks",
"/v3/repos": "/en/free-pro-team@latest/rest/reference/repos",
"/v3/repos/invitations": "/en/free-pro-team@latest/rest/reference/repos#invitations",
"/v3/repos/keys": "/en/free-pro-team@latest/rest/reference/repos#keys",
"/v3/repos/merging": "/en/free-pro-team@latest/rest/reference/repos#merging",
"/v3/repos/pages": "/en/free-pro-team@latest/rest/reference/repos#pages",
"/v3/repos/pre_receive_hooks": "/en/free-pro-team@latest/rest/reference/repos#pre-receive-hooks",
"/v3/repos/pre_receive_hooks": "/en/enterprise-server/rest/reference/enterprise-admin#repository-pre-receive-hooks",
"/v3/repos/releases": "/en/free-pro-team@latest/rest/reference/repos#releases",
"/v3/repos/statistics": "/en/free-pro-team@latest/rest/reference/repos#statistics",
"/v3/repos/statuses": "/en/free-pro-team@latest/rest/reference/repos#statuses",
Expand Down
4 changes: 2 additions & 2 deletions tests/routing/developer-site-redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('developer redirects', () => {
)
})

// TODO temprarily ensure we redirect old links using the new enterprise format
// TODO temporarily ensure we redirect old links using the new enterprise format
// for currently supported enterprise releases only
// EXAMPLE: /en/enterprise-server@2.20/v3/pulls/comments -> /en/enterprise-server@2.20/rest/reference/pulls#comments
// We can remove test after we update all the old `/v3` links to point to `/rest`
Expand Down Expand Up @@ -165,7 +165,7 @@ describe('developer redirects', () => {
)
})

// TODO temprarily ensure we redirect old links using the new enterprise format
// TODO temporarily ensure we redirect old links using the new enterprise format
// for currently supported enterprise releases only
// EXAMPLE: /en/enterprise-server@2.20/v4/interface/actor -> /en/enterprise-server@2.20/graphql/reference/interfaces#actor
// We can remove test after we update all the old `/v4` links to point to `/graphql`
Expand Down

0 comments on commit 6a3d326

Please sign in to comment.