mirror of
https://github.com/tiktok/sparo.git
synced 2024-11-14 19:35:12 -05:00
chore: support for cloning a specify branch
This commit is contained in:
parent
fe6e9ac69b
commit
b70a0c0ee0
3 changed files with 20 additions and 2 deletions
|
@ -45,6 +45,11 @@ export class CloneCommand implements ICommand<ICloneCommandOptions> {
|
|||
default: false,
|
||||
type: 'boolean'
|
||||
})
|
||||
.option('branch', {
|
||||
alias: 'b',
|
||||
describe: 'Specify a branch to clone',
|
||||
type: 'string'
|
||||
})
|
||||
.check((argv) => {
|
||||
if (!argv.repository) {
|
||||
return 'You must specify a repository to clone.';
|
||||
|
|
|
@ -9,6 +9,7 @@ import { TerminalService } from './TerminalService';
|
|||
export interface ICloneOptions {
|
||||
repository: string;
|
||||
directory: string;
|
||||
branch?: string;
|
||||
}
|
||||
|
||||
@Service()
|
||||
|
@ -64,7 +65,7 @@ an empty directory.`);
|
|||
terminal.writeDebugLine('full clone done');
|
||||
}
|
||||
|
||||
public bloblessClone({ repository, directory }: ICloneOptions): void {
|
||||
public bloblessClone({ repository, directory, branch }: ICloneOptions): void {
|
||||
const { terminal } = this._terminalService;
|
||||
|
||||
terminal.writeDebugLine('blobless clone start...');
|
||||
|
@ -73,6 +74,7 @@ an empty directory.`);
|
|||
'--filter=blob:none',
|
||||
'--sparse',
|
||||
'--single-branch',
|
||||
...(branch ? ['--branch', branch] : []),
|
||||
repository,
|
||||
directory
|
||||
];
|
||||
|
@ -85,7 +87,7 @@ an empty directory.`);
|
|||
terminal.writeDebugLine('blobless clone done');
|
||||
}
|
||||
|
||||
public treelessClone({ repository, directory }: ICloneOptions): void {
|
||||
public treelessClone({ repository, directory, branch }: ICloneOptions): void {
|
||||
const { terminal } = this._terminalService;
|
||||
|
||||
terminal.writeDebugLine('treeless clone start...');
|
||||
|
@ -94,6 +96,7 @@ an empty directory.`);
|
|||
'--filter=tree:0',
|
||||
'--sparse',
|
||||
'--single-branch',
|
||||
...(branch ? ['--branch', branch] : []),
|
||||
repository,
|
||||
directory
|
||||
];
|
||||
|
|
10
common/changes/sparo/main_2024-02-28-16-29.json
Normal file
10
common/changes/sparo/main_2024-02-28-16-29.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "sparo",
|
||||
"comment": "support for cloning a specify branch",
|
||||
"type": "none"
|
||||
}
|
||||
],
|
||||
"packageName": "sparo"
|
||||
}
|
Loading…
Reference in a new issue