Skip to content

Commit cde78cc

Browse files
authored
Merge branch 'main' into getdocs-shallow-clone
Signed-off-by: gerbsen <1186245+gerbsen@users.noreply.github.com>
2 parents ce1a3b1 + 7c475d6 commit cde78cc

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

getDocs.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ const reposJson = fs
1010
const repos = JSON.parse(reposJson)
1111
const ghUrl = 'https://github.com/'
1212

13+
// Resolve a repo entry to a clone URL.
14+
// A full URL (e.g. a GitHub or GitLab repo) is used as-is; a bare
15+
// "owner/name" is treated as a GitHub shorthand for backwards compatibility.
16+
const cloneUrl = (repo) =>
17+
/^(https?:\/\/|git@)/.test(repo) ? repo : ghUrl + repo
18+
1319
// Clone each repository, remove git folders and README files, and copy the docs to the target directory
1420
repos.forEach((repo) => {
1521
const repoDir = `repo_to_be_edited/${repo.label}`
1622

1723
// Clone the repository (shallow, single branch — we only need a snapshot of the docs)
18-
const cloneCommand = `git clone --single-branch --depth 1 ${
19-
ghUrl + repo.repo
20-
} ${repoDir}`
24+
const cloneCommand = `git clone --single-branch --depth 1 ${cloneUrl(repo.repo)} ${repoDir}`
2125
execSync(cloneCommand)
2226

2327
// Remove git folders

0 commit comments

Comments
 (0)