mirror of
https://github.com/tiktok/sparo.git
synced 2024-11-27 09:36:04 -05:00
commit
40d68a0687
9 changed files with 61 additions and 28 deletions
|
@ -11,7 +11,7 @@ import { GitCheckoutCommand } from './git-checkout';
|
|||
import { GitFetchCommand } from './git-fetch';
|
||||
import { GitPullCommand } from './git-pull';
|
||||
import { InitProfileCommand } from './init-profile';
|
||||
// import { PullCommand } from './pull';
|
||||
import { PullCommand } from './pull';
|
||||
|
||||
// When adding new Sparo subcommands, remember to update this doc page:
|
||||
// https://github.com/tiktok/sparo/blob/main/apps/website/docs/pages/commands/overview.md
|
||||
|
@ -23,8 +23,7 @@ export const COMMAND_LIST: Constructable[] = [
|
|||
CloneCommand,
|
||||
CheckoutCommand,
|
||||
FetchCommand,
|
||||
// Should be introduced after sparo merge|rebase
|
||||
// PullCommand,
|
||||
PullCommand,
|
||||
|
||||
// The commands customized by Sparo require a mirror command to Git
|
||||
GitCloneCommand,
|
||||
|
|
|
@ -8,35 +8,35 @@ import type { ICommand } from './base';
|
|||
import type { TerminalService } from '../../services/TerminalService';
|
||||
|
||||
export interface IPullCommandOptions {
|
||||
branch?: string;
|
||||
remote?: string;
|
||||
profile?: string[];
|
||||
addProfile?: string[];
|
||||
}
|
||||
|
||||
@Command()
|
||||
export class PullCommand implements ICommand<IPullCommandOptions> {
|
||||
public cmd: string = 'pull [remote] [branch]';
|
||||
public cmd: string = 'pull';
|
||||
public description: string = 'Incorporates changes from a remote repository into the current branch.';
|
||||
|
||||
@inject(GitService) private _gitService!: GitService;
|
||||
@inject(SparoProfileService) private _sparoProfileService!: SparoProfileService;
|
||||
|
||||
public builder(yargs: Argv<{}>): void {
|
||||
public builder = (yargs: Argv<{}>): void => {
|
||||
/**
|
||||
* sparo pull [remote] [branch] --profile <profile_name> --add-profile <profile_name> --no-profile
|
||||
* sparo pull [repository] [refsepc...] [--profile <profile_name> | --no-profile]
|
||||
*
|
||||
* sparo pull origin
|
||||
*
|
||||
* sparo pull origin master
|
||||
*/
|
||||
yargs
|
||||
.positional('remote', { type: 'string' })
|
||||
.positional('branch', { type: 'string' })
|
||||
.string('remote')
|
||||
.string('branch')
|
||||
.boolean('full')
|
||||
.array('profile')
|
||||
.default('profile', [])
|
||||
.array('add-profile')
|
||||
.default('add-profile', []);
|
||||
}
|
||||
.parserConfiguration({ 'unknown-options-as-args': true })
|
||||
.usage(
|
||||
'$0 pull [options] [repository] [refsepc...] [--profile <profile_name> | --no-profile]' +
|
||||
'\n\n' +
|
||||
this.description
|
||||
);
|
||||
};
|
||||
|
||||
public handler = async (
|
||||
args: ArgumentsCamelCase<IPullCommandOptions>,
|
||||
|
@ -46,17 +46,12 @@ export class PullCommand implements ICommand<IPullCommandOptions> {
|
|||
const { terminal } = terminalService;
|
||||
|
||||
terminal.writeDebugLine(`got args in pull command: ${JSON.stringify(args)}`);
|
||||
const pullArgs: string[] = ['pull'];
|
||||
|
||||
const { branch, remote } = args;
|
||||
|
||||
if (branch && remote) {
|
||||
pullArgs.push(remote, branch);
|
||||
}
|
||||
// Collect anything that is not related to profile, pass down them to native git pull
|
||||
const pullArgs: string[] = args._ as string[];
|
||||
|
||||
const { isNoProfile, profiles, addProfiles } = await sparoProfileService.preprocessProfileArgs({
|
||||
profilesFromArg: args.profile ?? [],
|
||||
addProfilesFromArg: args.addProfile ?? []
|
||||
addProfilesFromArg: []
|
||||
});
|
||||
|
||||
// invoke native git pull command
|
||||
|
|
|
@ -91,6 +91,6 @@ export class LocalState {
|
|||
if (!repoRoot) {
|
||||
throw new Error('Running outside of the git repository folder');
|
||||
}
|
||||
return path.join(this._gitService.getRepoInfo().root, '.git/info/local-state.json');
|
||||
return path.join(repoRoot, '.git/info/local-state.json');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@ Sparo has four kinds of subcommands:
|
|||
- `sparo checkout`
|
||||
- `sparo clone`
|
||||
- `sparo fetch`
|
||||
- `sparo pull` _(not implemented yet; currently mirrors `git pull`)_
|
||||
- `sparo pull`
|
||||
|
||||
3. **Renamed subcommands** are the mirrored versions of the four enhanced subcommands. They are renamed to add a `git-` prefix:
|
||||
- `sparo git-checkout`
|
||||
- `sparo git-clone`
|
||||
- `sparo git-fetch`
|
||||
- `sparo git-pull` _(not implemented yet)_
|
||||
- `sparo git-pull`
|
||||
|
||||
4. **Auxiliary subcommands** are new subcommands that provide Sparo-specific functionality. They are:
|
||||
- `sparo auto-config`
|
||||
|
|
11
apps/website/docs/pages/commands/sparo_git-pull.md
Normal file
11
apps/website/docs/pages/commands/sparo_git-pull.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
title: sparo git-pull
|
||||
---
|
||||
|
||||
This is the [mirrored subcommand](./overview.md) for `git pull`. It has the same functionality as the corresponding Git subcommand, but supports Sparo's optional anonymous timing metrics collection.
|
||||
|
||||
```
|
||||
sparo git-pull [<options>] [<repository> [<refspec>…]]
|
||||
```
|
||||
|
||||
See [git pull](https://git-scm.com/docs/git-pull) in the Git documentation for details.
|
14
apps/website/docs/pages/commands/sparo_pull.md
Normal file
14
apps/website/docs/pages/commands/sparo_pull.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
title: sparo pull
|
||||
---
|
||||
|
||||
```
|
||||
sparo pull [options] [repository] [refsepc...] [--profile <profile_name> |
|
||||
--no-profile]
|
||||
|
||||
Incorporates changes from a remote repository into the current branch.
|
||||
|
||||
Options:
|
||||
--help Show help [boolean]
|
||||
--profile [array] [default: []]
|
||||
```
|
|
@ -62,9 +62,11 @@ const sidebars = {
|
|||
'pages/commands/sparo_checkout',
|
||||
'pages/commands/sparo_clone',
|
||||
'pages/commands/sparo_fetch',
|
||||
'pages/commands/sparo_pull',
|
||||
'pages/commands/sparo_git-checkout',
|
||||
'pages/commands/sparo_git-clone',
|
||||
'pages/commands/sparo_git-fetch',
|
||||
'pages/commands/sparo_git-pull',
|
||||
'pages/commands/sparo_init-profile',
|
||||
'pages/commands/sparo_list-profiles'
|
||||
]
|
||||
|
|
|
@ -20,6 +20,8 @@ Commands:
|
|||
HEAD to set the specified branch as the
|
||||
current branch.
|
||||
sparo fetch [remote] [branch] fetch remote branch to local
|
||||
sparo pull Incorporates changes from a remote
|
||||
repository into the current branch.
|
||||
sparo git-clone original git clone command
|
||||
sparo git-checkout original git checkout command
|
||||
sparo git-fetch original git fetch command
|
||||
|
|
10
common/changes/sparo/feat-sparo-pull_2024-04-09-23-05.json
Normal file
10
common/changes/sparo/feat-sparo-pull_2024-04-09-23-05.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "sparo",
|
||||
"comment": "Add \"sparo pull\" command",
|
||||
"type": "minor"
|
||||
}
|
||||
],
|
||||
"packageName": "sparo"
|
||||
}
|
Loading…
Reference in a new issue