From 526c05f4ce6f236b5d1aa9c482b8ad8432c76b7f Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Mon, 7 Dec 2020 11:32:39 -0500 Subject: [PATCH 1/4] support hardcoded versions in links --- lib/rewrite-local-links.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/rewrite-local-links.js b/lib/rewrite-local-links.js index 4854a739cd..e0f4a12b1e 100644 --- a/lib/rewrite-local-links.js +++ b/lib/rewrite-local-links.js @@ -2,6 +2,7 @@ const externalRedirects = Object.keys(require('./redirects/external-sites')) const pathUtils = require('./path-utils') const assert = require('assert') const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version') +const supportedPlans = Object.values(require('./all-versions')).map(v => v.plan) // Content authors write links like `/some/article/path`, but they need to be // rewritten on the fly to match the current language and page version @@ -24,9 +25,17 @@ function getNewHref (link, languageCode, version) { // e.g. `/contact` should not be replaced with `/en/contact` if (externalRedirects.includes(href)) return + let newHref + + // If the link has a hardcoded plan name in it (e.g., /enterprise-server/rest/reference/oauth-authorizations), + // only rewrite it with a language code + if (supportedPlans.includes(href.split('/')[1])) { + newHref = pathUtils.getPathWithLanguage(href, languageCode) + } + // If link is dotcom-only, just get the language code // Otherwise, get the versioned path with language code - const newHref = link.hasClass('dotcom-only') + if (!newHref) newHref = link.hasClass('dotcom-only') ? pathUtils.getVersionedPathWithLanguage(href, nonEnterpriseDefaultVersion, languageCode) : pathUtils.getVersionedPathWithLanguage(href, version, languageCode) From ba2ebcfb30fb4b72da61dcacbf8ef7a14afb3ddf Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Mon, 7 Dec 2020 11:32:55 -0500 Subject: [PATCH 2/4] remove version number and leave plan name in Enterprise link --- content/rest/overview/troubleshooting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/rest/overview/troubleshooting.md b/content/rest/overview/troubleshooting.md index 0a22fab27b..a430cfd7be 100644 --- a/content/rest/overview/troubleshooting.md +++ b/content/rest/overview/troubleshooting.md @@ -63,7 +63,7 @@ curl -H 'Authorization: token my-oauth-token' https://api.github.com/user/repos #### Calls to OAuth Authorizations API -If you're making [OAuth Authorization API](/enterprise-server@2.22/rest/reference/oauth-authorizations) calls to manage your OAuth app's authorizations or to generate access tokens, similar to this example: +If you're making [OAuth Authorization API](/enterprise-server/rest/reference/oauth-authorizations) calls to manage your OAuth app's authorizations or to generate access tokens, similar to this example: ```bash curl -u my_username:my_password -X POST "https://api.github.com/authorizations" -d '{"scopes":["public_repo"], "note":"my token", "client_id":"my_client_id", "client_secret":"my_client_secret"}' From e2d114b96bf342001490874c6b27044d04c86ac8 Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Tue, 8 Dec 2020 11:47:14 -0500 Subject: [PATCH 3/4] lint --- lib/rewrite-local-links.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/rewrite-local-links.js b/lib/rewrite-local-links.js index e0f4a12b1e..2cd18221c0 100644 --- a/lib/rewrite-local-links.js +++ b/lib/rewrite-local-links.js @@ -35,9 +35,11 @@ function getNewHref (link, languageCode, version) { // If link is dotcom-only, just get the language code // Otherwise, get the versioned path with language code - if (!newHref) newHref = link.hasClass('dotcom-only') - ? pathUtils.getVersionedPathWithLanguage(href, nonEnterpriseDefaultVersion, languageCode) - : pathUtils.getVersionedPathWithLanguage(href, version, languageCode) + if (!newHref) { + newHref = link.hasClass('dotcom-only') + ? pathUtils.getVersionedPathWithLanguage(href, nonEnterpriseDefaultVersion, languageCode) + : pathUtils.getVersionedPathWithLanguage(href, version, languageCode) + } if (href !== newHref) link.attr('href', newHref) } From 9fef52449c9437d30bb77bb68310f54d1b2217b1 Mon Sep 17 00:00:00 2001 From: Chiedo John <2156688+chiedo@users.noreply.github.com> Date: Wed, 9 Dec 2020 13:23:46 -0500 Subject: [PATCH 4/4] Move to a version of this that works with a cron (#16830) Move to a version of this that works with a cron Co-authored-by: Chiedo --- .github/workflows/repo-sync-stalls.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/repo-sync-stalls.yml b/.github/workflows/repo-sync-stalls.yml index 2784f4703a..fb605313c3 100644 --- a/.github/workflows/repo-sync-stalls.yml +++ b/.github/workflows/repo-sync-stalls.yml @@ -22,8 +22,8 @@ jobs: github-token: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }} script: | let pulls; - const owner = context.payload.repository.owner.login - const repo = context.payload.repository.name + const owner = context.repo.owner + const repo = context.repo.repo try { pulls = await github.pulls.list({ owner: owner,