This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore[ee]: improved single-branch cloning feature as optional (#10273)
- Loading branch information
1 parent
f410ceb
commit a4b3a82
Showing
1 changed file
with
14 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,11 +46,13 @@ cli.enable('status') | |
const options = cli.parse({ | ||
manifestURL: [false, 'Manifest URL', 'string'], | ||
branch: ['b', 'Branch', 'string', 'main'], | ||
replace: ['r', 'Replace existing project?', 'string', 'no'] | ||
replace: ['r', 'Replace existing project?', 'string', 'no'], | ||
singleBranch: ['s', 'Clone repos in a single branch?', 'string', 'no'] | ||
}) as { | ||
manifestURL?: string | ||
branch?: string | ||
replace?: string | ||
singleBranch?: string | ||
} | ||
|
||
/** | ||
|
@@ -93,7 +95,7 @@ interface PackageManifest_V_1_0_0 { | |
} | ||
|
||
const installManifest = async () => { | ||
const { branch } = options // ?? 'main' -> unnecessary coalescing operator, leveraging default value from cli settings instead | ||
const { branch, singleBranch } = options // ?? 'main' -> unnecessary coalescing operator, leveraging default value from cli settings instead | ||
const manifest = (await fetchManifest()) as PackageManifest_V_1_0_0 | ||
const replacing = options.replace?.toLowerCase() === 'yes' || options.replace?.toLowerCase() === 'y' | ||
if (!manifest) throw new Error('No manifest found') | ||
|
@@ -143,7 +145,7 @@ const installManifest = async () => { | |
const curatedURL = url.replace('https://github.com/', '[email protected]:') | ||
console.log(`Cloning ${curatedURL}`) | ||
// Improving performance by cloning the code from the expected branch in a single step | ||
await execPromise(`git clone -b ${branch} --single-branch ${curatedURL}`, { | ||
await execPromise(`git clone -b ${branch} ${singleBranch === 'yes' ? '--single-branch' : ''} ${curatedURL}`, { | ||
cwd: path.resolve(appRootPath.path, 'packages/projects/projects') | ||
}) | ||
|
||
|
@@ -159,9 +161,18 @@ const installManifest = async () => { | |
*/ | ||
}) | ||
) | ||
|
||
await execPromise(`ls`, { | ||
cwd: path.resolve(appRootPath.path, 'packages/projects/projects') | ||
}) | ||
|
||
if (singleBranch === 'yes') { | ||
console.log(`You enabled cloning a single branch, the only branch currently available in your local environment | ||
is "${branch}", in case you need to checkout a different remote branch, run the following commands in your terminal: | ||
$ git fetch origin [branch] | ||
$ git checkout FETCH_HEAD -b [branch]`) | ||
} | ||
} | ||
|
||
cli.main(async () => { | ||
|