1
0
mirror of synced 2026-01-20 03:01:07 -05:00

Merge pull request #24270 from github/repo-sync

repo sync
This commit is contained in:
Octomerger Bot
2023-03-02 14:02:05 -08:00
committed by GitHub
4 changed files with 52 additions and 9 deletions

View File

@@ -155,9 +155,13 @@
"/rest/enterprise-admin#update-a-self-hosted-runner-group-for-an-enterprise": "/rest/actions/self-hosted-runner-groups#update-a-self-hosted-runner-group-for-an-enterprise",
"/rest/orgs#list-custom-repository-roles-in-an-organization": "/rest/orgs/custom-roles#list-custom-repository-roles-in-an-organization",
"/rest/apps/oauth-applications#create-a-scoped-access-token": "/rest/apps/apps#create-a-scoped-access-token",
"/rest/enterprise-admin#get-code-security-analysis-features-for-an-enterprise": "/rest/enterprise-admin/code-security-and-analysis#get-code-security-analysis-features-for-an-enterprise",
"/rest/enterprise-admin#update-code-security-and-analysis-features-for-an-enterprise": "/rest/enterprise-admin/code-security-and-analysis#update-code-security-and-analysis-features-for-an-enterprise",
"/rest/enterprise-admin#enable-or-disable-a-security-feature": "/rest/enterprise-admin/code-security-and-analysis#enable-or-disable-a-security-feature",
"/rest/repos#deploy-keys": "/rest/deploy-keys",
"/rest/deployments#deploy-keys": "/rest/deploy-keys",
"/rest/repos#statuses": "/rest/commits/statuses",
"/rest/enterprise-admin#code-security-and-analysis": "/rest/enterprise-admin/code-security-and-analysis",
"/rest/apps#get-the-authenticated-app": "/rest/apps/apps#get-the-authenticated-app",
"/rest/apps#create-a-github-app-from-a-manifest": "/rest/apps/apps#create-a-github-app-from-a-manifest",
"/rest/apps#get-a-webhook-configuration-for-an-app": "/rest/apps/webhooks#get-a-webhook-configuration-for-an-app",
@@ -783,7 +787,6 @@
"/rest/repos#get-a-repository-readme": "/rest/repos/contents#get-a-repository-readme",
"/rest/repos#get-a-repository-directory-readme": "/rest/repos/contents#get-a-repository-directory-readme",
"/rest/repos#releases": "/rest/repos/releases",
"/rest/releases/releases#create-a-release": "/rest/repos/releases#create-a-release",
"/rest/activity#list-stargazers": "/rest/activity/starring#list-stargazers",
"/rest/activity#starring": "/rest/activity/starring",
"/rest/metrics/statistics#get-the-weekly-commit-activity": "/rest/metrics/statistics#get-the-weekly-commit-activity",
@@ -1072,9 +1075,6 @@
"/rest/announcement-banners#enterprises": "/rest/announcement-banners/enterprises",
"/rest/announcement-banners/enterprises#set-announcement-banner-for-enterprise": "/rest/announcement-banners/enterprises#set-announcement-banner-for-enterprise",
"/rest/announcement-banners/enterprises#remove-announcement-banner-from-enterprise": "/rest/announcement-banners/enterprises#remove-announcement-banner-from-enterprise",
"/rest/enterprise-admin#get-code-security-analysis-features-for-an-enterprise": "/rest/enterprise-admin/code-security-and-analysis#get-code-security-analysis-features-for-an-enterprise",
"/rest/enterprise-admin#code-security-and-analysis": "/rest/enterprise-admin/code-security-and-analysis",
"/rest/enterprise-admin#update-code-security-and-analysis-features-for-an-enterprise": "/rest/enterprise-admin/code-security-and-analysis#update-code-security-and-analysis-features-for-an-enterprise",
"/rest/enterprise-admin#list-enterprise-consumed-licenses": "/rest/enterprise-admin/license#list-enterprise-consumed-licenses",
"/rest/enterprise-admin#get-a-license-sync-status": "/rest/enterprise-admin/license#get-a-license-sync-status",
"/rest/billing#get-github-actions-billing-for-an-enterprise": "/rest/enterprise-admin/billing#get-github-actions-billing-for-an-enterprise",
@@ -1082,7 +1082,6 @@
"/rest/billing#export-advanced-security-active-committers-data-for-enterprise": "/rest/enterprise-admin/billing#export-advanced-security-active-committers-data-for-enterprise",
"/rest/billing#get-github-packages-billing-for-an-enterprise": "/rest/enterprise-admin/billing#get-github-packages-billing-for-an-enterprise",
"/rest/billing#get-shared-storage-billing-for-an-enterprise": "/rest/enterprise-admin/billing#get-shared-storage-billing-for-an-enterprise",
"/rest/enterprise-admin#enable-or-disable-a-security-feature": "/rest/enterprise-admin/code-security-and-analysis#enable-or-disable-a-security-feature",
"/rest/orgs#custom_roles": "/rest/orgs/custom_roles",
"/rest/actions#list-repository-access-to-a-self-hosted-runner-group-in-an-organization": "/rest/actions/self-hosted-runner-groups#list-repository-access-to-a-self-hosted-runner-group-in-an-organization",
"/rest/actions#set-repository-access-to-a-self-hosted-runner-group-in-an-organization": "/rest/actions/self-hosted-runner-groups#set-repository-access-to-a-self-hosted-runner-group-in-an-organization",

View File

@@ -784,11 +784,27 @@
"category": "apps",
"subcategory": "apps",
"originalUrl": "/rest/apps/oauth-applications#create-a-scoped-access-token"
},
"secret-scanning/get-security-analysis-settings-for-enterprise": {
"category": "enterprise-admin",
"subcategory": "code-security-and-analysis",
"originalUrl": "/rest/enterprise-admin#get-code-security-analysis-features-for-an-enterprise"
},
"secret-scanning/patch-security-analysis-settings-for-enterprise": {
"category": "enterprise-admin",
"subcategory": "code-security-and-analysis",
"originalUrl": "/rest/enterprise-admin#update-code-security-and-analysis-features-for-an-enterprise"
},
"secret-scanning/post-security-product-enablement-for-enterprise": {
"category": "enterprise-admin",
"subcategory": "code-security-and-analysis",
"originalUrl": "/rest/enterprise-admin#enable-or-disable-a-security-feature"
}
},
"sectionUrls": {
"/rest/repos#deploy-keys": "/rest/deploy-keys",
"/rest/deployments#deploy-keys": "/rest/deploy-keys",
"/rest/repos#statuses": "/rest/commits/statuses"
"/rest/repos#statuses": "/rest/commits/statuses",
"/rest/enterprise-admin#code-security-and-analysis": "/rest/enterprise-admin/code-security-and-analysis"
}
}

View File

@@ -21,7 +21,7 @@ import { validateVersionsOptions } from './utils/get-openapi-schemas.js'
import { allVersions } from '../../../lib/all-versions.js'
import { syncWebhookData } from '../../webhooks/scripts/sync.js'
import { syncGitHubAppsData } from '../../github-apps/scripts/sync.js'
import { syncRestRedirects } from './utils/getRedirects.js'
import { syncRestRedirects } from './utils/get-redirects.js'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const TEMP_OPENAPI_DIR = path.join(__dirname, '../../../openApiTemp')

View File

@@ -60,8 +60,36 @@ async function decorateRedirects(operation, clientSideRedirects) {
if (!externalDocs) {
return
}
const oldUrl = `/rest${externalDocs.url.replace('/rest/reference', '/rest').split('/rest')[1]}`
// Because we generate a list of redirect programmatically which sprung
// from a large move of operations from /rest/reference to /rest on
// docs.github.com, we only want to programmatically generate redirects
// for those cases. I've noticed that sometimes someone will come along and
// update the url in the OpenAPI but they don't update the category
// and subcategory to match. So the url is accurate and category/subcategory
// are out-of-date.
//
// This logic roughly checks to see if the url looks up-to-date by
// seeing if the category and subcategory are in it. If they are not
// it indicates that the url is newer than the category/subcategory and
// we can skip generating a redirect.
if (
category &&
subcategory &&
!oldUrl.includes(`${category}/${subcategory}`) &&
!externalDocs.url.includes('/rest/reference')
) {
return
} else if (
category &&
!oldUrl.includes(`${category}`) &&
!externalDocs.url.includes('/rest/reference')
) {
return
}
if (!(oldUrl in clientSideRedirects)) {
// There are some operations that aren't nested in the sidebar
// For these, don't need to add a client-side redirect, the
@@ -69,9 +97,9 @@ async function decorateRedirects(operation, clientSideRedirects) {
if (categoriesWithoutSubcategories.includes(category)) {
return
}
const anchor = oldUrl.split('#')[1]
const fragment = anchor ? `#${oldUrl.split('#')[1]}` : ''
const anchor = oldUrl.split('#')[1]
const fragment = anchor ? `#${anchor}` : ''
// If there is no subcategory, a new page with the same name as the
// category was created. That page name may change going forward.
const redirectTo = subcategory