From 02a18eb32a319e0ae4c67647bb722097a62b4881 Mon Sep 17 00:00:00 2001 From: Quanyi Ma Date: Sat, 4 Nov 2023 22:49:56 +0800 Subject: [PATCH] Update the README.md and upgrade Cargo.toml Signed-off-by: Quanyi Ma --- craft/Cargo.toml | 5 ++--- craft/README.md | 32 +++++++++++++++++++++++++------- craft/src/main.rs | 10 ++++++++-- git/Cargo.toml | 2 +- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/craft/Cargo.toml b/craft/Cargo.toml index 80ceb8b6..53058644 100644 --- a/craft/Cargo.toml +++ b/craft/Cargo.toml @@ -12,6 +12,5 @@ edition = "2021" anyhow = "1.0.75" pgp = "0.10.2" rand = "0.8.5" -smallvec = "1.10.0" -clap = { version = "4.4.0", features = ["derive"] } - +smallvec = "1.11.1" +clap = { version = "4.4.7", features = ["derive"] } \ No newline at end of file diff --git a/craft/README.md b/craft/README.md index 8b544bdf..69592c0b 100644 --- a/craft/README.md +++ b/craft/README.md @@ -1,13 +1,33 @@ -# Git-craft v0.1.0 +# Craft - Git Extension of Mega -Git-craft is a extension for git, it can encrypt the content when submitting code in Git, and rewrite the content of the Blob object and code decryption when reading the Blob content, with filter. +Craft is a Git plugin for Mega, a Large File Storage (LFS) client, encryption and decryption of code, and generation of AI/LLM training data or model data, among other functionalities. As an integral part of the Mega service, it is installed locally in the developers' environment and incorporated with the server to enhance developer experiences. -## Prepare +## Quick Started for developing and testing craft on MacOS + +1. Install Rust on your MacOS. + + ```bash + $ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + ``` + +2. Clone mega repository and build it. + + ```bash + $ git clone https://github.com/web3infra-foundation/mega.git + $ cd mega/craft + $ cargo build --release + ``` + +## Encryption and Decryption of Source Code + + + +### Prepare 1. cd mega/craft 2. modify all the key file path, KEY_FILE_PATH, MSG_FILE_NAME and filter to match your project 3. cargo build --release -## Usage +### Usage 1. git-craft generate-key - git-craft will default generate a public key to /key_files/pub.asc and a secret key to /key_files/sec.asc @@ -21,10 +41,8 @@ Git-craft is a extension for git, it can encrypt the content when submitting cod - git-craft will list keys name, key's fingerprint and id, it should be used without key path now, because I set a default key path 6. git-craft delete-key [key_name] [Option] - git-craft will show you what keys you have now, then remove keys by key name you entered, it should be used without key path now, because I set a default key path - - -## About Filter +### About Filter 1. edit .git/config "../craft/key_files/sec.asc" is a default key, you can use another key. - [filter "crypt"] diff --git a/craft/src/main.rs b/craft/src/main.rs index 96245a1a..a62bb087 100644 --- a/craft/src/main.rs +++ b/craft/src/main.rs @@ -1,11 +1,17 @@ - +//! +//! +//! +//! +//! use anyhow::{ Result, Ok}; -use git_craft::{pgp_key::{list_keys, delete_key}, crypt::{generate_key, encrypt_blob, decrypt_blob, generate_key_full}}; use clap::Parser; +use git_craft::{pgp_key::{list_keys, delete_key}, crypt::{generate_key, encrypt_blob, decrypt_blob, generate_key_full}}; + #[derive(Parser)] #[command(author = "Jiajun Li ", version = "0.1.0")] #[command(about = "Git crypt tool", long_about= "Usage: generate-key, generate-key-full [primary_id] [key_name], encrypt [public_key_path], decrypt [secret_key_path], list-keys , delete-key [key_name]")] + struct CraftOptions { //accept mutiple values, it needs 1 value at least #[clap(num_args=1..,required=true)] diff --git a/git/Cargo.toml b/git/Cargo.toml index d0b74bb3..a9642ddb 100644 --- a/git/Cargo.toml +++ b/git/Cargo.toml @@ -22,7 +22,7 @@ storage = { path = "../storage" } kvcache = { path = "../kvcache" } build-bazel-tool = { path = "../build-bazel-tool" } anyhow = "1.0.75" -bstr = "1.5.0" +bstr = "1.7.0" chrono = "0.4.24" colored = "2.0.0" deflate = "1.0.0"