-
We are using
Python 3.8
for development. -
install package from pypi
pip3 install degit==0.0.1
-
We are using
Ganache
to create a blockchain network at local environment for development and testing.Please head to the Ganache website and download it.
Once you have installed Ganache, you can simple click on quickstart and you should be able to call degit functions.
Remember to define the
RPC_SERVER
environment variable, by default the value ishttp://127.0.0.1:7545
which is the default network of Ganache.
Also please put your private key in the .key
file. Degit will automatically load the key and use it for git operations.
Or run degit login <key path>
under repository folder.
We have prepare a test.py
for your convenient.
Before you run the tests, you must put in two different private key to a.key
and b.key
under test/
.
(you can randomly pick 2 from Ganache).
You should obtain a console output similar to this one:
File last modified time on Owner machine: 2022-05-08 12:25:00
Initialized Repository. State file created in current directory.
Committed files:
Staged files:
test.txt
Commit 076bb1b40881a287b47ca56d7d17d2c54815dd36 was successful.
Contract deployed to chain, contract address: 0x7B9ef343909fD32b8Ad7c9667Dc49Dd4034e4742.
Pushed commits "076bb1b40881a287b47ca56d7d17d2c54815dd36" to repository "test".
Whitelisted user of address: 0xbe2545A975e8A6Efd0BA5c4600aE4CfA228DA8b5
Dumped repository config to ./repo_config.pkl.
Loaded repository config from ./repo_config.pkl
Replace your repository by commit 076bb1b40881a287b47ca56d7d17d2c54815dd36
File last modified time on friend machine: 2022-05-08 12:25:07
Process finished with exit code 0
This test.py
mimic two users (1 owner and 1 collaborator):
- The owner has written some code in
test.txt
- The owner runs
degit init test
(test
is the repository name) - The owner runs
degit add test.txt
- The owner runs
degit commit
- The owner runs
degit push
to pushtest.txt
to the blockchain network - The owner gets his friend account address and runs
degit whitelist_add_user <friend_address>
- The owner runs
degit dump_repository_config
- The friend runs
degit load_repository_config
- The friend runs
degit pull
- The friend now has the
test.txt
in his machine
The printed file last modified time shows that the file is truly replaced by the one pulled from the repository.
We have recorded a Youtube Demo for your convenient.
User A
mkdir repo_a
cd repo_a
# login to A account
degit login ../test/a.key
# Repo init
degit init new_project
# create files to add and commit
touch README.MD 1.txt
degit add README.MD 1.txt
degit reset README.MD
degit commit
# degit push <branch name>
degit push master
# add user to the repo whitelist
degit whitelist add 0x0513E128c27B6E306D980661F39d0535A4d7133f
# degit whitelist remove 0x0513E128c27B6E306D980661F39d0535A4d7133f
# dump ABI and contract address
degit dump_repository_config
User B
# create second folder to clone repo
mkdir ../repo_b/
cp ./repo_config.pkl ../repo_b/
cd ../repo_b/
degit login ../test/b.key
degit init tester
# restore abi and contract address
degit load_repository_config
degit pull
At the moment we are using HKUST provided endpoint to upload file and download file.
In the future, we might deploy a smart contract ourselves as a decentralized filestorage.
At the moment we have ./contracts/Repository.sol
only.
This is the template repository we defined to allow user to create repository with access control.
It is unfortunate that due to limited time and team members, we are unable to replicate git fully.