diff --git a/aria/contents/docs/libra/command/add/index.mdx b/aria/contents/docs/libra/command/add/index.mdx index 20d1eac66..d6f478352 100644 --- a/aria/contents/docs/libra/command/add/index.mdx +++ b/aria/contents/docs/libra/command/add/index.mdx @@ -2,3 +2,33 @@ title: The [add] Command description: --- + +# add + +**Add file contents to the index** + +### Usage + +libra add \[OPTIONS\] \[PATHSPEC\]... + +### Arguments + +- `[PATHSPEC]...` - Files & dirs to add content from + +### Description + +This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit. + +### Options + +- `-A`, `--all` + Update the index not only where the working tree has a file matching pathspec but also where the index already has an entry. + This adds, modifies, and removes index entries to match the working tree. + + If no pathspec is given when `-A` option is used, all files in the entire working tree are updated + +- `-u`, `--update` + Update the index just where it already has an entry matching **pathspec**. This removes as well as modifies index entries to match the working tree, but adds no new files + +- `-v`, `--verbose` + more detailed output \ No newline at end of file diff --git a/aria/contents/docs/libra/command/branch/index.mdx b/aria/contents/docs/libra/command/branch/index.mdx index f65ffa107..a58bda06f 100644 --- a/aria/contents/docs/libra/command/branch/index.mdx +++ b/aria/contents/docs/libra/command/branch/index.mdx @@ -2,3 +2,43 @@ title: The [branch] Command description: --- + +# branch + +**List, create, or delete branches** + +### Usage + +libra branch [OPTIONS] [NEW_BRANCH] [COMMIT_HASH] + +### Arguments + +- `[NEW_BRANCH]` - New branch name +- `[COMMIT_HASH]` - Base branch name or commit hash + +### Description + +If --list is given, or if there are no non-option arguments, existing local branches are listed; the current branch will be highlighted in green and marked with an asterisk, same as git. + +If a new branch name is given, a new branch is created that points to the given commit hash. If no commit hash is given, the new branch will point to the current commit. + +### Options + +- `-l`, `--list` + List all branches, don't include remote branches. The order is not guaranteed, mostly it is sorted by the created order. +- `-D`, `--delete ` + Force delete branch +- `-u`, `--set-upstream-to ` + Set up ``'s tracking information so `` is considered ``'s upstream branch. +- `--show-current` + Show current branch +- `-r`, `--remotes` + Show remote branches +- `-h`, `--help` + Print help + + + All parameters should align with Git’s behavior as closely as possible, but + there may be some differences. Refs https://git-scm.com/docs/git-branch for + more information. + diff --git a/aria/contents/docs/libra/command/clone/index.mdx b/aria/contents/docs/libra/command/clone/index.mdx index 9096c95ca..e8646ecee 100644 --- a/aria/contents/docs/libra/command/clone/index.mdx +++ b/aria/contents/docs/libra/command/clone/index.mdx @@ -2,3 +2,30 @@ title: The [clone] Command description: --- + +# clone + +**Clone a repository into a new directory** + +### Usage + +libra clone `` [LOCAL_PATH] + +### Arguments + +- `` - The remote repository location to clone from, current only support HTTP/HTTPS. +- `[LOCAL_PATH]` - The local path to clone the repository to. If not provided, the repository will be cloned to the current directory. + +### Description + +Clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository , and creates and checks out an initial branch that is forked from the cloned repository’s currently active branch. + +### Options + +- `-h`, `--help` Print help + + + Currently, libra only support clone from HTTP/HTTPS. SSH & Local path will + be supported in the future. git clone support more protocols and options, + refs https://git-scm.com/docs/git-clone for more information. + diff --git a/aria/contents/docs/libra/command/commit/index.mdx b/aria/contents/docs/libra/command/commit/index.mdx index f983784c4..adf8ed5c2 100644 --- a/aria/contents/docs/libra/command/commit/index.mdx +++ b/aria/contents/docs/libra/command/commit/index.mdx @@ -2,3 +2,35 @@ title: The [commit] Command description: --- + +# commit + +**Record changes to the repository** + +### Usage + +libra commit [OPTIONS] --message \ + +### Description + +Create a new commit containing the current contents of the index and the given log message describing the changes. The new commit is a direct child of HEAD, usually the current head of the current branch, or a single commit hash (detached HEAD). + +The content to be committed can be specified only by `libra add` & `libra rm` commands. (The git support other ways to add content to the index, for example, `--all` option in `git commit`, which is not supported in libra yet.) + +If the `--allow-empty` option is not given, the commit will be aborted if the index is empty. + +### Options: + +- `-m`, `--message ` +- `--allow-empty` + Allow commit with empty index. +- `--conventional` + Check if the commit message is conventional format, if not, the commit will be aborted. +- `-h`, `--help` Print help + + +The commit message should align with Git’s behavior as closely as possible, excpet the `--conventional` option, which is not supported in Git. Refs https://git-scm.com/docs/git-commit for more information. + +The `--conventional` option's format is based on the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. + + diff --git a/aria/contents/docs/libra/command/diff/index.mdx b/aria/contents/docs/libra/command/diff/index.mdx index e3975f047..6cff19c2a 100644 --- a/aria/contents/docs/libra/command/diff/index.mdx +++ b/aria/contents/docs/libra/command/diff/index.mdx @@ -2,3 +2,46 @@ title: The [diff] Command description: --- + +# diff + +**Show different between files** + +### Usage + +libra diff [OPTIONS] [PATHSPEC]... + +### Arguments + +- `[PATHSPEC]` - File or directory name with a path relative to current directory or a absolute path + +### Description + +Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees. + +If no arguments are given, the changes between the working tree and the index are shown. If the index don't have any changes, the changes between the working tree and the HEAD are shown. + +PATHSPEC can be a file or directory name with a path relative to current directory or a absolute path. (The git support relative path start from the repository root, which is not supported in libra yet.). Because what's you are diff may not in disk currently, libra didn't check if the path exists. + +{" "} + + + The diff command use `less` to show the result in unix-like system, and + simply print all the content in windows. If you are using unix-like system, + you need to ensure `less` is installed (usually it is installed by default). + + +### Options + +### Options: + +- `--old ` Old branch/commit, defaults is staged or HEAD +- `--new ` New branch/commit, default is working directory +- `--staged` Use stage as new commit. This option is conflict with --new. +- `--output ` Print the result to a file +- `-h`, `--help` Print help + + + Because of the `clap`'s limitation, the `diff` command's options are + different from git's `diff` command. + diff --git a/aria/contents/docs/libra/command/fetch/index.mdx b/aria/contents/docs/libra/command/fetch/index.mdx index 28d35ee0a..b0aa0dd7f 100644 --- a/aria/contents/docs/libra/command/fetch/index.mdx +++ b/aria/contents/docs/libra/command/fetch/index.mdx @@ -2,3 +2,36 @@ title: The [fetch] Command description: --- + +# fetch + +**Download objects and refs from another repository** + +### Usage + +libra fetch [OPTIONS] [REPOSITORY] [REFSPEC] + +### Arguments + +- `[REPOSITORY]` - Repository to fetch from +- `[REFSPEC]` - Refspec to fetch, usually a branch name + +### Description + +Fetch branches from one or more other repositories, along with the objects necessary to complete their histories. Remote-tracking branches are updated. + +When no remote is specified, by default the current branch's config remote is used (normally `origin`). If the current branch is not associated with a remote, the command fails. + +`fetch` is automatically invoked by `libra pull` and `libra push`. + +### Options + +- `-a`, `--all` + Fetch all remotes +- `-h`, `--help` + + + Git-fetch could also be used be fetch tags, but currently, libra didn't + support tag. Simple usage is same as git-fetch. Refs + https://git-scm.com/docs/git-fetch for more information. + diff --git a/aria/contents/docs/libra/command/index-pack/index.mdx b/aria/contents/docs/libra/command/index-pack/index.mdx index 626cc0c90..393ec8894 100644 --- a/aria/contents/docs/libra/command/index-pack/index.mdx +++ b/aria/contents/docs/libra/command/index-pack/index.mdx @@ -2,3 +2,27 @@ title: The [index-pack] Command description: --- + +# index-pack + +**Build pack index file for an existing packed archive** + +### Usage + +libra index-pack \[OPTIONS\] \ + +### Arguments + +- `` - Pack file path + +### Description + +Build pack index file for an existing packed archive. + +### Options + +- `-o`, `--output `
+ output index file path. Without this option the name of pack index file is constructed from the name of packed archive file by replacing `.pack` with `.idx` + +- `--index-version `
+ This is intended to be used by the test suite only. It allows to force the version for the generated pack index diff --git a/aria/contents/docs/libra/command/init/index.mdx b/aria/contents/docs/libra/command/init/index.mdx index 26e72809d..92ec1ec39 100644 --- a/aria/contents/docs/libra/command/init/index.mdx +++ b/aria/contents/docs/libra/command/init/index.mdx @@ -2,3 +2,20 @@ title: The [init] Command description: --- + +# init + +**Create an empty Libra repository** + +### Usage + +libra init + +### Description + +This command creates the necessary directories and files for a new Libra repository. +It also sets up the database and the initial configuration. + +### Options + +- `-h`, `--help` Print help \ No newline at end of file diff --git a/aria/contents/docs/libra/command/lfs/index.mdx b/aria/contents/docs/libra/command/lfs/index.mdx index 22a5a1286..52b6193e1 100644 --- a/aria/contents/docs/libra/command/lfs/index.mdx +++ b/aria/contents/docs/libra/command/lfs/index.mdx @@ -2,3 +2,57 @@ title: The [lfs] Command description: --- + +# lfs + +**Work with large files in Libra repositories** + +### Usage + +libra lfs \ \[\\] + +### Description + +Libra LFS is a system for managing and versioning large files in association with a Libra repository. + +Instead of storing the large files within the Libra repository as blobs, Libra LFS stores special "pointer files" in the repository, +while storing the actual file contents on an LFS server. + +The contents of the large file are downloaded automatically when needed, for example when a branch containing the large file is checked out. + +### Commands +#### track \[PATTERN\]... +View or add LFS paths to Libra Attributes (root)
+Start tracking the given patterns(s) through Libra LFS. The argument is +written to .libra_attributes. If no paths are provided, simply list the +currently-tracked paths.
+Like: `libra lfs track "*.png"` + +#### untrack \... +Remove LFS paths from Libra Attributes (root).
+Stop tracking the given pattern(s) through Libra LFS.
+Nothing will happen if the pattern is not currently being tracked (in .libra_attribute). + +#### locks +List currently "locked" files from the Libra LFS server.
+ +#### lock \ +Set a file as "locked" on the Libra LFS server.
+String path name of the locked file. This should be relative to the root of the repository working directory.
+Once locked, LFS will verify that Git pushes do not modify files locked by other users. + +#### unlock \ +Remove a "locked" file from the Libra LFS server.
+##### Options +- `-f`, `--force` - Tells the server to remove the lock, even if it's owned by another user. +- `-i `, `--id ` - Specifies a lock by its ID instead of path. + +#### ls-files +Show information about Libra LFS files in the index and working tree.
+ + + The `lfs` command only support root level tracking, and the root `.libra_attributes` file is used to store the tracking information. + + Libra LFS is mainly designed for monorepo, which has different LFS server discovery mechanism from git-lfs. + However, it made special support for GitHub and Gitee. + \ No newline at end of file diff --git a/aria/contents/docs/libra/command/log/index.mdx b/aria/contents/docs/libra/command/log/index.mdx index 53a862719..c45f7f439 100644 --- a/aria/contents/docs/libra/command/log/index.mdx +++ b/aria/contents/docs/libra/command/log/index.mdx @@ -2,3 +2,33 @@ title: The [log] Command description: --- + +# log + +**Show commit logs** + +### Usage + +libra log [OPTIONS] + +### Description + +List commits that are reachable by current local branch. The order is from the latest to the oldest. The commit hash, author, date, and commit message will be shown. + +{" "} + + The log command use `less` to show the result in unix-like system, and + simply print all the content in windows. If you are using unix-like system, + you need to ensure `less` is installed (usually it is installed by default). + + +### Options: + +- `-n`, `--number ` + Limit the number of output +- `-h`, `--help` + Print help + + + The order of the commits maybe different from Git's behavior. + diff --git a/aria/contents/docs/libra/command/merge/index.mdx b/aria/contents/docs/libra/command/merge/index.mdx index 2aafb1dc6..2bea59269 100644 --- a/aria/contents/docs/libra/command/merge/index.mdx +++ b/aria/contents/docs/libra/command/merge/index.mdx @@ -2,3 +2,25 @@ title: The [merge] Command description: --- + +# merge + +**Merge changes** + +### Usage + +libra merge `` + +### Arguments + +- `` - Branch name or commit hash, could be a local branch, remote branch or a commit hash. + +### Description + +Incorporates changes from the named commits. The `` could be a branch name (local or remote) or a commit hash. + +**Currently, libra only supports fast-forward merge.** + +### Options: + +- `-h`, `--help` Print help diff --git a/aria/contents/docs/libra/command/pull/index.mdx b/aria/contents/docs/libra/command/pull/index.mdx index 562f37a05..c687fa337 100644 --- a/aria/contents/docs/libra/command/pull/index.mdx +++ b/aria/contents/docs/libra/command/pull/index.mdx @@ -2,3 +2,30 @@ title: The [pull] Command description: --- + +# pull + +**Fetch from and integrate with another repository or a local branch** + +### Usage + +libra pull [REPOSITORY] [REFSPEC] + +### Arguments + +- `[REPOSITORY]` - Repository to fetch from +- `[REFSPEC]` - Refspec to fetch, usually a branch name + +### Description + +`pull` incorporates changes from a remote repository into the current branch. In its default mode, `pull` is shorthand for `fetch` followed by `merge FETCH_HEAD`. refs [fetch docs](../command/fetch) for more information. + +### Options + +- `-h`, `--help` + Print help + + + Simple usage is same as git-pull. Refs https://git-scm.com/docs/git-pull for + more information. + diff --git a/aria/contents/docs/libra/command/push/index.mdx b/aria/contents/docs/libra/command/push/index.mdx index e8df5fcbb..a4f483fb8 100644 --- a/aria/contents/docs/libra/command/push/index.mdx +++ b/aria/contents/docs/libra/command/push/index.mdx @@ -2,3 +2,30 @@ title: The [push] Command description: --- + +# push + +**Update remote refs along with associated objects** + +### Usage + +libra push \[OPTIONS\] \[REPOSITORY\] \[REFSPEC\] + +### Arguments + +- `[REPOSITORY]` - repository, e.g. origin +- `[REFSPEC]` - ref to push, e.g. master + +### Description + +Updates remote refs using local refs, while sending objects necessary to complete the given refs. + +When the command line does not specify where to push with the `` argument, `branch.*.remote` configuration for the current branch is consulted to determine where to push. + +When the command line does not specify what to push with `` argument, current branch is pushed. + +### Options + +- `-u`, `--set-upstream` + For every branch that is up to date or successfully pushed, add upstream (tracking) reference, + used by argument-less `libra pull` and other commands. \ No newline at end of file diff --git a/aria/contents/docs/libra/command/rebase/index.mdx b/aria/contents/docs/libra/command/rebase/index.mdx index 6f7087504..e916c1bd3 100644 --- a/aria/contents/docs/libra/command/rebase/index.mdx +++ b/aria/contents/docs/libra/command/rebase/index.mdx @@ -2,3 +2,7 @@ title: The [rebase] Command description: --- + + + **Currently, libra only supports fast-forward merge.** + diff --git a/aria/contents/docs/libra/command/remote/index.mdx b/aria/contents/docs/libra/command/remote/index.mdx index 6548027c0..4ed11aa33 100644 --- a/aria/contents/docs/libra/command/remote/index.mdx +++ b/aria/contents/docs/libra/command/remote/index.mdx @@ -2,3 +2,33 @@ title: The [remote] Command description: --- + +# remote + +**Manage set of tracked repositories** + +### Usage + +libra remote \ + +### Commands + +#### add + Add a remote named `` for the repository at `` + +#### remove + Remove the remote named `` + +#### -v + Be a little more verbose and show remote url after name. + +#### show + Show current remote repository + +### Options + +- `-h`, `--help` + Print help + + + diff --git a/aria/contents/docs/libra/command/restore/index.mdx b/aria/contents/docs/libra/command/restore/index.mdx index 45002e5e9..95fc086db 100644 --- a/aria/contents/docs/libra/command/restore/index.mdx +++ b/aria/contents/docs/libra/command/restore/index.mdx @@ -2,3 +2,38 @@ title: The [restore] Command description: --- + +# restore + +**Restore working tree files** + +### Usage + +libra restore \[OPTIONS\] \... + +### Arguments + +- `...` - files or dir to restore + +### Description + +Restore specified paths in the working tree with some contents from a restore source. +If a path is tracked but does not exist in the restore source, it will be removed to match the source. + +The command can also be used to restore the content in the index with `--staged`, +or restore both the working tree and the index with `--staged` `--worktree`. + +By default, if `--staged` is given, the contents are restored from `HEAD`, otherwise from the index. +Use `--source` to restore from a different commit. + +### Options + +- `-s `, `--source `
+ Restore the working tree files with the content from the given tree. It is common to specify the source tree by naming a commit, branch + or tag associated with it. + + If not specified, the contents are restored from HEAD if `--staged` is given, otherwise from the index. + +- `-W`, `--worktree`, `-S`, `--staged`
+ Specify the restore location. If neither option is specified, by default the working tree is restored. Specifying `--staged` will only + restore the index. Specifying both restores both. \ No newline at end of file diff --git a/aria/contents/docs/libra/command/rm/index.mdx b/aria/contents/docs/libra/command/rm/index.mdx index 0c4c3cd1a..c03173ed3 100644 --- a/aria/contents/docs/libra/command/rm/index.mdx +++ b/aria/contents/docs/libra/command/rm/index.mdx @@ -2,3 +2,31 @@ title: The [rm] Command description: --- + +# rm + +**Remove files from the working tree and from the index** + +### Usage + +libra rm \[OPTIONS\] \[PATHSPEC\]... + +### Arguments + +- `[PATHSPEC]...` - Files to remove.
+A leading directory name can be given to remove all files in the +directory, and recursively all sub-directories, but this requires the `-r` option to be explicitly given. + +### Description + +Remove files matching pathspec from the index, or from the working tree and the index. `libra rm` will not remove a file from just your working +directory. (There is no option to remove a file only from the working tree and yet keep it in the index; use system rm if you want to do +that.) + +### Options + +- `--cached`
+ Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone. + +- `-r`, `--recursive`
+ Allow recursive removal when a leading directory name is given. diff --git a/aria/contents/docs/libra/command/status/index.mdx b/aria/contents/docs/libra/command/status/index.mdx index 2be546760..00be89e3d 100644 --- a/aria/contents/docs/libra/command/status/index.mdx +++ b/aria/contents/docs/libra/command/status/index.mdx @@ -2,3 +2,22 @@ title: The [status] Command description: --- + +# status + +**Show the working tree status** + +### Usage + +libra status + +### Description + +Displays paths that have differences between the index file and the current HEAD commit, paths that have differences between the working +tree and the index file, and paths in the working tree that are not tracked by Libra. + + + `status` command doesn't support any options & arguments yet. + + See https://git-scm.com/docs/git-status for more information. + \ No newline at end of file diff --git a/aria/contents/docs/libra/command/switch/index.mdx b/aria/contents/docs/libra/command/switch/index.mdx index 5ca82fa6b..cbe789895 100644 --- a/aria/contents/docs/libra/command/switch/index.mdx +++ b/aria/contents/docs/libra/command/switch/index.mdx @@ -2,3 +2,49 @@ title: The [switch] Command description: --- + +# switch + +**Switch worktree to another branch** + +### Usage + +libra switch [OPTIONS] [BRANCH] + +### Arguments + +- `[BRANCH]` - Branch name or commit hash + +### Description + +Switch to a specified branch. The working tree and the index are updated to match the branch. You should make sure the working tree is clean before switching branches. Otherwise, the operation will be aborted. + +**Handle with remote branches** + +If you want to switch to a remote branch, you need to create a new branch based on the remote branch and switch to it. + +```shell +libra fetch origin +libra branch -r # see a new branch named origin/new-branch +libra branch new-branch origin/new-branch +libra switch new-branch +``` + +### Options + +- `-c`, `--create ` + Create a new branch based on the given branch or current HEAD, and switch to it. + +- `-d`, `--detach` + Switch to a commit. + + +The options of the switch command are same as git, but the behavior is different. + +1. Git has a feature that, when you switch to a branch didn't exist locally but exists remotely, it will create a new branch locally and track the remote branch. Libra doesn't support this feature yet. + +2. Git didn't require a clean index and working tree before switching branches, but libra does. + +Refs https://git-scm.com/docs/git-switch for more information. + + diff --git a/aria/contents/docs/libra/internal/scheme/index.mdx b/aria/contents/docs/libra/internal/scheme/index.mdx index 5922f7ad8..a512a8ee7 100644 --- a/aria/contents/docs/libra/internal/scheme/index.mdx +++ b/aria/contents/docs/libra/internal/scheme/index.mdx @@ -2,3 +2,73 @@ title: Libra Database Scheme description: --- + +### Introduction + +Libra use `sea-orm` to interact with sqlite database. The data model is defined in [`libra/src/internal/model`](https://github.com/web3infra-foundation/mega/tree/main/libra/src/internal/model), with two tables: `config` and `reference`. + +The `config` table is used to store the configuration of the project, which corresponds to the `config` file in git. The `reference` table is used to store the reference of the project, which corresponds to the `HEAD` and `refs/*` files in git. + +The relationship between the git file and the sqlite table is as follows: + +#### reference: + +| Category | Description | Database format | +| --------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| .git/HEAD | Current head pointer (branch or commit hash) | Reference(name=``; kind=HEAD;commit=null;remote=null)

Reference(name=null; kind=HEAD;commit=``;remote=null) | +| .git/refs/heads/`` | Branch name, can’t be “HEAD” | Reference(name=``, kind=Branch; commit=``; remote=null) | +| .git/refs/tags/` ` | Similar to branch | Reference(name=``, kind=Tag; commit=``; remote=null) | +| .git/refs/remotes/``/`` | Contains branch heads and HEAD*Remote HEAD can’t be detached.* | Reference(name=``, kind=Branch; commit=``; remote=``)

Reference(name=``; type=HEAD; commit=null; remote=``) | + +#### config: + +```ini +# config Example +[core] + filemode = true + ignorecase = false +[remote "origin"] + url = url.git + fetch = +refs/heads…… +``` + +| Category | Description | Database format | +| ------------ | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `.gitconfig` | Ini format configuration | Config(configuration=”core”; name=null; key=”filemode”;value=”true” )

Config(configuration=”core”; name=null; key=”ignorecase”;value=”false” )

Config(configuration=”remote”; name=”origin”; key=”url”;value=”url.git” )

Config(configuration=”remote”; name=”null”; key=”fetch”;value=”+refs……” ) | + +### Business Model Design + +For decoupling, the `sea-orm` model is not directly used in the code, and the business model is redefined (located in `libra/src/internal`), and common CRUD operations are implemented. + +Currently, the `config`, `head` and `reference` models are implemented. + +### SQL Statement + +```sql +CREATE TABLE IF NOT EXISTS `config` ( + `id` INTEGER PRIMARY KEY AUTOINCREMENT, + `configuration` TEXT NOT NULL, + `name` TEXT, + `key` TEXT NOT NULL, + `value` TEXT NOT NULL +); +CREATE TABLE IF NOT EXISTS `reference` ( + `id` INTEGER PRIMARY KEY AUTOINCREMENT, + -- name can't be '' + `name` TEXT CHECK (name <> '' OR name IS NULL), + `kind` TEXT NOT NULL CHECK (kind IN ('Branch', 'Tag', 'Head')), + `commit` TEXT, + -- remote can't be ''. If kind is Tag, remote must be NULL. + `remote` TEXT CHECK (remote <> '' OR remote IS NULL), + CHECK ( + (kind <> 'Tag' OR (kind = 'Tag' AND remote IS NULL)) + ) +); +-- (name, kind, remote) as unique key when remote is not null +CREATE UNIQUE INDEX idx_name_kind_remote ON `reference`(`name`, `kind`, `remote`) +WHERE `remote` IS NOT NULL; + +-- (name, kind) as unique key when remote is null +CREATE UNIQUE INDEX idx_name_kind ON `reference`(`name`, `kind`) +WHERE `remote` IS NULL; +``` diff --git a/libra/src/command/branch.rs b/libra/src/command/branch.rs index 71d866918..44c34a09a 100644 --- a/libra/src/command/branch.rs +++ b/libra/src/command/branch.rs @@ -17,7 +17,7 @@ pub struct BranchArgs { #[clap(requires = "new_branch")] commit_hash: Option, - /// list all branches + /// list all branches, don't include remote branches #[clap(short, long, group = "sub", default_value = "true")] list: bool, @@ -25,7 +25,7 @@ pub struct BranchArgs { #[clap(short = 'D', long, group = "sub")] delete: Option, - /// Set up current branch's tracking information + /// Set up `branchname`>`'s tracking information so `<`upstream`>` is considered `<`branchname`>`'s upstream branch. #[clap(short = 'u', long, group = "sub")] set_upstream_to: Option, @@ -53,7 +53,7 @@ pub async fn execute(args: BranchArgs) { } }; } else if args.list { - // 兜底list + // default behavior list_branches(args.remotes).await; } else { panic!("should not reach here") diff --git a/libra/src/command/commit.rs b/libra/src/command/commit.rs index 4e864fc04..a5edea29f 100644 --- a/libra/src/command/commit.rs +++ b/libra/src/command/commit.rs @@ -21,9 +21,11 @@ pub struct CommitArgs { #[arg(short, long)] pub message: String, + /// allow commit with empty index #[arg(long)] pub allow_empty: bool, + /// check if commit message follows conventional commits #[arg(long, requires("message"))] pub conventional: bool, } diff --git a/libra/src/command/diff.rs b/libra/src/command/diff.rs index 7f44af601..2c8976d05 100644 --- a/libra/src/command/diff.rs +++ b/libra/src/command/diff.rs @@ -33,21 +33,25 @@ use crate::utils::path_ext::PathExt; #[derive(Parser, Debug)] pub struct DiffArgs { - #[clap(long, help = "Old commit, defaults is staged or HEAD")] + /// Old commit, default is HEAD + #[clap(long, value_name = "COMMIT")] pub old: Option, - #[clap(long, help = "New commit, default is working directory")] + /// New commit, default is working directory + #[clap(long, value_name = "COMMIT")] #[clap(requires = "old", group = "op_new")] pub new: Option, - #[clap(long, help = "use stage as new commit")] + /// Use stage as new commit. This option is conflict with --new. + #[clap(long)] #[clap(group = "op_new")] pub staged: bool, #[clap(help = "Files to compare")] pathspec: Vec, - #[clap(long)] + // Print the result to file + #[clap(long, value_name = "FILENAME")] pub output: Option, } diff --git a/libra/src/command/fetch.rs b/libra/src/command/fetch.rs index 2f3a7f5f8..9b36ec0a2 100644 --- a/libra/src/command/fetch.rs +++ b/libra/src/command/fetch.rs @@ -28,8 +28,10 @@ const DEFAULT_REMOTE: &str = "origin"; #[derive(Parser, Debug)] pub struct FetchArgs { + /// Repository to fetch from pub repository: Option, + /// Refspec to fetch, usually a branch name #[clap(requires("repository"))] pub refspec: Option, diff --git a/libra/src/command/merge.rs b/libra/src/command/merge.rs index 1390561c6..f8fbb8b98 100644 --- a/libra/src/command/merge.rs +++ b/libra/src/command/merge.rs @@ -14,7 +14,7 @@ use super::{ #[derive(Parser, Debug)] pub struct MergeArgs { - /// The branch to merge into the current branch + /// The branch to merge into the current branch, could be remote branch pub branch: String, } diff --git a/libra/src/command/pull.rs b/libra/src/command/pull.rs index 8c60c30f4..11b432000 100644 --- a/libra/src/command/pull.rs +++ b/libra/src/command/pull.rs @@ -4,8 +4,10 @@ use super::{fetch, merge}; use clap::Parser; #[derive(Parser, Debug)] pub struct PullArgs { + /// The repository to pull from repository: Option, + /// The refspec to pull, usually a branch name #[clap(requires("repository"))] refspec: Option, } diff --git a/libra/src/command/switch.rs b/libra/src/command/switch.rs index d5bb03d40..445b6800b 100644 --- a/libra/src/command/switch.rs +++ b/libra/src/command/switch.rs @@ -14,12 +14,15 @@ use super::{ #[derive(Parser, Debug)] pub struct SwitchArgs { + /// branch name #[clap(required_unless_present("create"), required_unless_present("detach"))] branch: Option, + /// Create a new branch based on the given branch or current HEAD, and switch to it #[clap(long, short, group = "sub")] create: Option, + /// Switch to a commit #[clap(long, short, action, default_value = "false", group = "sub")] detach: bool, } diff --git a/libra/src/internal/protocol/lfs_client.rs b/libra/src/internal/protocol/lfs_client.rs index 9f14f1656..ed4207c5b 100644 --- a/libra/src/internal/protocol/lfs_client.rs +++ b/libra/src/internal/protocol/lfs_client.rs @@ -334,7 +334,7 @@ impl LFSClient { let mut is_chunked = false; // Chunk API - let mut chunk_size = None; // infer that all chunks are the same size! + let chunk_size; // infer that all chunks are the same size! let links = match self.fetch_chunks(&link.href).await { Ok(chunks) => { is_chunked = true; @@ -342,7 +342,10 @@ impl LFSClient { tracing::info!("LFS Chunk API supported."); chunks.into_iter().map(|c| c.link).collect() }, - Err(_) => vec![link.clone()], + Err(_) => { + chunk_size = Some(size as i64); + vec![link.clone()] + } }; let mut checksum = Context::new(&SHA256);