Skip to content

Commit

Permalink
Allow .git extension in public repo names (github#30053)
Browse files Browse the repository at this point in the history
accommodate .git in repo names
  • Loading branch information
sarahs authored Aug 18, 2022
1 parent 65848b2 commit 7956d9e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/meta/repository-references.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ If this test is failing...
add the file name to ALLOW_DOCS_PATHS.
*/

// These are a list of known public repositories in the GitHub organization
// These are a list of known public repositories in the GitHub organization.
// The names below on their own, plus the same names ending with '.git', will be accepted.
// Do not include '.git' in the names below.
const PUBLIC_REPOS = new Set([
'actions-oidc-gateway-example',
'advisory-database',
Expand Down Expand Up @@ -43,7 +45,6 @@ const PUBLIC_REPOS = new Set([
'gitignore',
'gov-takedowns',
'haikus-for-codespaces',
'hello-world.git',
'hello-world',
'help-docs-archived-enterprise-versions',
'hubot',
Expand Down Expand Up @@ -81,7 +82,9 @@ const ALLOW_DOCS_PATHS = [
'script/toggle-ghae-feature-flags.js',
]

const REPO_REGEXP = /\/\/github\.com\/github\/(?!docs[/'"\n])([\w-.]+)/gi
// This regexp will capture the last segment of a GitHub repo name.
// E.g., it will capture `backup-utils.git` from `https://github.com/github/backup-utils.git`.
const REPO_REGEXP = /\/\/github\.com\/github\/([\w\-.]+)/gi

const IGNORE_PATHS = [
'.git',
Expand Down Expand Up @@ -129,7 +132,8 @@ describe('check if a GitHub-owned private repository is referenced', () => {
// the disk I/O is sufficiently small.
const file = fs.readFileSync(filename, 'utf8')
const matches = Array.from(file.matchAll(REPO_REGEXP))
.map(([, repoName]) => repoName)
// The referenced repo may or may not end with '.git', so ignore that extension.
.map(([, repoName]) => repoName.replace(/\.git$/, ''))
.filter((repoName) => !PUBLIC_REPOS.has(repoName))
.filter((repoName) => {
return !(
Expand Down

0 comments on commit 7956d9e

Please sign in to comment.