From 4642442a956c016b3d15fc534971f7871ae4c9b2 Mon Sep 17 00:00:00 2001 From: Pete Gonzalez <4673363+octogonz@users.noreply.github.com> Date: Fri, 1 Mar 2024 00:19:27 -0800 Subject: [PATCH 1/5] Add CLI docs --- .../sparo-lib/src/cli/commands/ci-checkout.ts | 2 +- .../docs/pages/ci_commands/overview.md | 19 ++++ .../pages/ci_commands/sparo-ci_checkout.md | 17 +++ .../docs/pages/ci_commands/sparo-ci_clone.md | 18 +++ apps/website/docs/pages/commands/overview.md | 22 ++-- .../docs/pages/commands/sparo_auto-config.md | 34 ++++++ .../docs/pages/commands/sparo_checkout.md | 23 ++++ .../docs/pages/commands/sparo_clone.md | 24 ++++ .../docs/pages/commands/sparo_fetch.md | 16 +++ .../docs/pages/commands/sparo_git-checkout.md | 17 +++ .../docs/pages/commands/sparo_git-clone.md | 19 ++++ .../docs/pages/commands/sparo_git-fetch.md | 15 +++ .../docs/pages/commands/sparo_init-profile.md | 13 +++ .../pages/commands/sparo_list-profiles.md | 14 +++ .../docs/pages/guide/sparo_profiles.md | 103 ++++++++++++++++++ apps/website/docs/pages/support/help.md | 4 +- apps/website/sidebars.js | 23 +++- 17 files changed, 371 insertions(+), 12 deletions(-) create mode 100644 apps/website/docs/pages/ci_commands/overview.md create mode 100644 apps/website/docs/pages/ci_commands/sparo-ci_checkout.md create mode 100644 apps/website/docs/pages/ci_commands/sparo-ci_clone.md create mode 100644 apps/website/docs/pages/commands/sparo_auto-config.md create mode 100644 apps/website/docs/pages/commands/sparo_checkout.md create mode 100644 apps/website/docs/pages/commands/sparo_clone.md create mode 100644 apps/website/docs/pages/commands/sparo_fetch.md create mode 100644 apps/website/docs/pages/commands/sparo_git-checkout.md create mode 100644 apps/website/docs/pages/commands/sparo_git-clone.md create mode 100644 apps/website/docs/pages/commands/sparo_git-fetch.md create mode 100644 apps/website/docs/pages/commands/sparo_init-profile.md create mode 100644 apps/website/docs/pages/commands/sparo_list-profiles.md diff --git a/apps/sparo-lib/src/cli/commands/ci-checkout.ts b/apps/sparo-lib/src/cli/commands/ci-checkout.ts index aef30a8..fc7452f 100644 --- a/apps/sparo-lib/src/cli/commands/ci-checkout.ts +++ b/apps/sparo-lib/src/cli/commands/ci-checkout.ts @@ -13,7 +13,7 @@ export interface ICICheckoutCommandOptions { export class CICheckoutCommand implements ICommand { public cmd: string = 'checkout'; public description: string = - 'Special checkout command for CI. It only accepts project selector suchs as --to and --from now.'; + 'Special checkout command for CI. It only accepts project selector such as --to and --from now.'; @inject(GitSparseCheckoutService) private _gitSparseCheckoutService!: GitSparseCheckoutService; public builder(yargs: Argv): void { yargs diff --git a/apps/website/docs/pages/ci_commands/overview.md b/apps/website/docs/pages/ci_commands/overview.md new file mode 100644 index 0000000..ab79a0b --- /dev/null +++ b/apps/website/docs/pages/ci_commands/overview.md @@ -0,0 +1,19 @@ +--- +title: Overview +--- + +Everyday development involves a variety of Git operations such as switching between branches, fetching incremental changes from the server, and browsing history. By contrast, when a continuous integration (CI) pipeline checks out a Git branch, it is typically a much simpler operation, and the folder or entire virtual machine image may be discarded as soon as the job completes. Therefore, different approaches for optimizing Git require required for these two use cases. + +Sparo provides a separate command line `sparo-ci` that is specifically optimized for CI pipelines. The current implementation takes this approach: + +- It uses [treeless clone](https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/) instead of **blobless clone**, under the assumption that Git history will be rarely needed. + + _Shallow clone is a common alternative, however it has trouble supporting operations such as incremental build or publishing that require comparison with a base branch._ + +- Spare checkout is configured, and the [skeleton folders](../reference/skeleton_folders.md) are included. + +Currently two subcommands are supported for CI: + +- `sparo-ci checkout` +- `sparo-ci clone` + diff --git a/apps/website/docs/pages/ci_commands/sparo-ci_checkout.md b/apps/website/docs/pages/ci_commands/sparo-ci_checkout.md new file mode 100644 index 0000000..6e020fc --- /dev/null +++ b/apps/website/docs/pages/ci_commands/sparo-ci_checkout.md @@ -0,0 +1,17 @@ +--- +title: sparo-ci checkout +--- + +``` +sparo-ci checkout + +Special checkout command for CI. It only accepts project selector such as --to +and --from now. + +Options: + --help Show help [boolean] + -t, --to See https://rushjs.io/pages/developer/selecting_subsets/#--to for + more details. [array] + -f, --from See https://rushjs.io/pages/developer/selecting_subsets/#--from + for more details. [array] +``` diff --git a/apps/website/docs/pages/ci_commands/sparo-ci_clone.md b/apps/website/docs/pages/ci_commands/sparo-ci_clone.md new file mode 100644 index 0000000..a5453b3 --- /dev/null +++ b/apps/website/docs/pages/ci_commands/sparo-ci_clone.md @@ -0,0 +1,18 @@ +--- +title: sparo-ci clone +--- + +``` +sparo-ci clone [directory] + +Positionals: + repository The remote repository to clone from. [string] [required] + directory The name of a new directory to clone into. The "humanish" part of + the source repository is used if no directory is explicitly given + (repo for /path/to/repo.gitService and foo for + host.xz:foo/.gitService). Cloning into an existing directory is + only allowed if the directory is empty [string] + +Options: + --help Show help [boolean] +``` diff --git a/apps/website/docs/pages/commands/overview.md b/apps/website/docs/pages/commands/overview.md index 07514bc..a445edb 100644 --- a/apps/website/docs/pages/commands/overview.md +++ b/apps/website/docs/pages/commands/overview.md @@ -9,25 +9,27 @@ Sparo has four kinds of subcommands: 1. **Mirrored subcommands** such as `sparo branch` and `sparo revert` directly invoke the corresponding `git` version of that subcommand. The motivation for using mirrored subcommands is to enable Sparo to provide advice about parameters that may cause performance issues. Additionally, you can optionally configure Sparo to collect anonymized usage metrics to help you measure the experience in your repository. (Collected data is sent to your own service. It is not accessible by any other party.) 2. **Enhanced subcommands** follow the same basic design as their `git` counterparts, but with adaptations for sparse checkout profiles and more efficient defaults. There are four enhanced commands: - - `sparo clone` - `sparo checkout` + - `sparo clone` - `sparo fetch` - - `sparo pull` + - `sparo pull` (not implemented yet; currently mirrors `git pull`) 3. **Renamed subcommands** are the mirrored versions of the four enhanced subcommands. They are renamed to add a `git-` prefix: - - `sparo git-clone` - `sparo git-checkout` + - `sparo git-clone` - `sparo git-fetch` - - `sparo git-pull`. + - `sparo git-pull` (not implemented yet) 4. **Auxiliary subcommands** are new subcommands that provide Sparo-specific functionality. They are: - - `sparo purge` - - `sparo list-profiles` + - `sparo auto-config` - `sparo init-profile` + - `sparo list-profiles` + - `sparo inspect` (not implemented yet, reports working directory status and diagnostics) + - `sparo reclone` (not implemented yet, will efficiently revert to a clean clone) ## Mirrored commands -Each subcommand has its own page in this documentation, except for the mirrored commands which are already covered by the Git documentation. For convenience, their names are listed in the table below. +Each subcommand has its own page in this documentation, except for the mirrored commands which are already covered by the Git documentation. For convenience, the most essential ["porcelain"](https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain) subcommands are listed in the table below, however every Git subcommand is supported. | Subcommand | Summary | | --- | --- | @@ -71,4 +73,8 @@ Each subcommand has its own page in this documentation, except for the mirrored | [git stash](https://git-scm.com/docs/git-stash) | Stash the changes in a dirty working directory away | | [git status](https://git-scm.com/docs/git-status) | Show the working tree status | | [git submodule](https://git-scm.com/docs/git-submodule) | Initialize, update or inspect submodules | -| [git switch](https://git-scm.com/docs/git-switch) | +| [git switch](https://git-scm.com/docs/git-switch) | Switch branches | +| [git tag](https://git-scm.com/docs/git-tag) | Create, list, delete or verify a tag object signed with GPG | +| [git worktree](https://git-scm.com/docs/git-worktree) | Manage multiple working trees | +| . . . | _...and many other subcommands including any custom commands found in the shell `PATH`_ | + diff --git a/apps/website/docs/pages/commands/sparo_auto-config.md b/apps/website/docs/pages/commands/sparo_auto-config.md new file mode 100644 index 0000000..8165a10 --- /dev/null +++ b/apps/website/docs/pages/commands/sparo_auto-config.md @@ -0,0 +1,34 @@ +--- +title: sparo auto-config +--- + +``` +sparo auto-config + +Automatic setup optimized git config + +Options: + --help Show help [boolean] + --overwrite [boolean] [default: false] +``` + +You do not normally need to invoke `sparo auto-config`. As the name implies, it is automatically applied by `sparo clone`. This command is provided for reapplying the configuration in a situation where the user may have manually altered Sparo's configuration. It is a good first step when investigating problems. + +## Auto-config settings + +The implementation can be found in [GitService.ts](https://github.com/tiktok/sparo/blob/main/apps/sparo-lib/src/services/GitService.ts). Below is a summary of the currently applied settings: + +``` +pull.rebase=true +fetch.prune=true +fetch.showForcedUpdates=false +feature.manyFiles=true +core.fsmonitor=true +core.fscache=true +core.untrackedcache=true +om-my-zsh.hide-status=1 +on-my-zsh.hide-dirty=1 +lfs.allowincompletepush=true +lfs.concurrenttransfers=32 +push.autoSetupRemote=true +``` diff --git a/apps/website/docs/pages/commands/sparo_checkout.md b/apps/website/docs/pages/commands/sparo_checkout.md new file mode 100644 index 0000000..e28608c --- /dev/null +++ b/apps/website/docs/pages/commands/sparo_checkout.md @@ -0,0 +1,23 @@ +--- +title: sparo checkout +--- + +``` +sparo checkout [branch] [start-point] + +Updates files in the working tree to match the version in the index or the +specified tree. If no pathspec was given, git checkout will also update HEAD to +set the specified branch as the current branch. + +Positionals: + branch [string] + start-point [string] + +Options: + --help Show help [boolean] + -b Create a new branch and start it at [boolean] + -B Create a new branch and start it at ; if it + already exists, reset it to [boolean] + --profile [array] [default: []] + --add-profile [array] [default: []] +``` diff --git a/apps/website/docs/pages/commands/sparo_clone.md b/apps/website/docs/pages/commands/sparo_clone.md new file mode 100644 index 0000000..f06de92 --- /dev/null +++ b/apps/website/docs/pages/commands/sparo_clone.md @@ -0,0 +1,24 @@ +--- +title: sparo clone +--- + +``` +sparo clone [directory] + +Positionals: + repository The remote repository to clone from. [string] [required] + directory The name of a new directory to clone into. The "humanish" part of + the source repository is used if no directory is explicitly given + (repo for /path/to/repo.gitService and foo for + host.xz:foo/.gitService). Cloning into an existing directory is + only allowed if the directory is empty [string] + +Options: + --help Show help [boolean] + -s, --skip-git-config By default, Sparo automatically configures the + recommended git settings for the repository you are + about to clone. If you prefer not to include this step, + you can use the input parameter --skip-git-config + [boolean] [default: false] + -b, --branch Specify a branch to clone [string] +``` \ No newline at end of file diff --git a/apps/website/docs/pages/commands/sparo_fetch.md b/apps/website/docs/pages/commands/sparo_fetch.md new file mode 100644 index 0000000..d81d586 --- /dev/null +++ b/apps/website/docs/pages/commands/sparo_fetch.md @@ -0,0 +1,16 @@ +--- +title: sparo fetch +--- + +``` +sparo fetch [remote] [branch] + +fetch remote branch to local + +Positionals: + remote [string] + branch [string] + +Options: + --help Show help [boolean] +``` \ No newline at end of file diff --git a/apps/website/docs/pages/commands/sparo_git-checkout.md b/apps/website/docs/pages/commands/sparo_git-checkout.md new file mode 100644 index 0000000..fdda909 --- /dev/null +++ b/apps/website/docs/pages/commands/sparo_git-checkout.md @@ -0,0 +1,17 @@ +--- +title: sparo git-checkout +--- + +This is the [mirrored subcommand](./overview.md) for `git checkout`. It has the same functionality as the corresponding Git subcommand, but supports Sparo's optional anonymous timing metrics collection. + +``` +sparo git-checkout [-q] [-f] [-m] [] +sparo git-checkout [-q] [-f] [-m] --detach [] +sparo git-checkout [-q] [-f] [-m] [--detach] +sparo git-checkout [-q] [-f] [-m] [[-b|-B|--orphan] ] [] +sparo git-checkout [-f|--ours|--theirs|-m|--conflict=