Skip to content

Commit

Permalink
Merge pull request #216 from genedna/main
Browse files Browse the repository at this point in the history
Update the README.md and upgrade Cargo.toml
  • Loading branch information
genedna authored Nov 5, 2023
2 parents d6f6522 + 02a18eb commit 411e10c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
5 changes: 2 additions & 3 deletions craft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
32 changes: 25 additions & 7 deletions craft/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<key_path>]
- 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"]
Expand Down
10 changes: 8 additions & 2 deletions craft/src/main.rs
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>", 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)]
Expand Down
2 changes: 1 addition & 1 deletion git/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 411e10c

Please sign in to comment.