Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: support for cloning a specify branch #29

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/sparo-lib/src/cli/commands/clone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
7 changes: 5 additions & 2 deletions apps/sparo-lib/src/services/GitCloneService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { TerminalService } from './TerminalService';
export interface ICloneOptions {
repository: string;
directory: string;
branch?: string;
}

@Service()
Expand Down Expand Up @@ -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...');
Expand All @@ -73,6 +74,7 @@ an empty directory.`);
'--filter=blob:none',
'--sparse',
'--single-branch',
...(branch ? ['--branch', branch] : []),
repository,
directory
];
Expand All @@ -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...');
Expand All @@ -94,6 +96,7 @@ an empty directory.`);
'--filter=tree:0',
'--sparse',
'--single-branch',
...(branch ? ['--branch', branch] : []),
repository,
directory
];
Expand Down
10 changes: 10 additions & 0 deletions common/changes/sparo/main_2024-02-28-16-29.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "sparo",
"comment": "support for cloning a specify branch",
"type": "none"
}
],
"packageName": "sparo"
}
Loading