chore: support for cloning a specify branch

This commit is contained in:
qun 2024-02-28 16:29:49 +00:00
parent fe6e9ac69b
commit b70a0c0ee0
3 changed files with 20 additions and 2 deletions

View file

@ -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.';

View file

@ -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
];

View file

@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "sparo",
"comment": "support for cloning a specify branch",
"type": "none"
}
],
"packageName": "sparo"
}