That’s a proposal to run Git directly on SAFE:
Add safe as a remote source in your repository:
git remote add origin safe://7ha7723672367a76a
Send your commits as usual (nothing different here):
git push origin master
Can I use it with my current repositories?
Yes. You can do this with your current git repositories, in normal, non-safe, folders. You won’t lose data doing that. It’s not required to move your current repos to a safe folder nor to re-create the repository, just add this new remote source.
What if I want to keep GitHub, and just use SafeGit as backup?
It’s possible and easy. Just replace “origin” by something else like “safe”. Then, use “git push origin” to send it to GitHub (or whatever your current remote source is), and “git push safe” to send it to safe.
What is this “7ha7723672367a76a”?
In this example, “7ha7723672367a76a” is a SD owned by you, the repo owner. This “7ha…” is a crypto hash (“sha1”) from a standardized string like “safegit_projects_n”, where “n” is the last available project + 1.
How to generate my own “7ha7723672367a76a”?
First, we need to discover “n”, the last available project + 1. To achieve this, we need to scan the network - a good algorithm would be the “half-interval”, that would allow us to find “n” very fast, it would require less than 40 SD lookups, even if this list has trillions of records.
But “7ha7723672367a76a” is to hard do memorize
To fix this, we can create a new SD with the key “safegit_organizations_xxx”, where “xxx” is your “organization” name (eg “maidsafe”).
Inside it, there’s a key-value hash with all repositories of the organization and its assigned repository SDs (“7ha…”).
With this, a “git remote add” command would be something like:
git remote add origin safe://maidsafe/crust
This command would look for a “safegit_organizations_maidsafe” SD, open it and look after a “crust” entry. This entry would have a crypto-hash like “272837287328”, which is the repository SD.
What about the “safe://” part of the git command? It will understand it?
Just as chrome/firefox needs a plugin to understand the safe protocol, git also needs a plugin (remote helper) to understand it:
Obviously, we still need to develop this git remote helper. But in short, we don’t need to make a fork of git tool, we just need to develop a plugin for it.
When the project-owner does a push, our git remote helper checks what was add (luckily, git does cumulative diffs, perfect to immutable data). Then, it creates a new immutable with that added data. Git also adds a new log record entry, pointing to this new added data - we store this in our “7ha…” SD.
My idea is to always save the immutable data encrypted, even for public repos. If it’s a public repo, the “7ha…” SD will contain the key to decrypt it. With this, if the repo-owner wants to delete its repo, he’ll just remove the SD or its key (as it’s not possible to delete immutable objects).
As default behavior, all created repos are private. If the project-owner wants to turn it public, the key to decrypt its data should be added in the SD.
- Project’s information (title, description, protocol’s version): it will be contained in the SD;
- Issues: we will use @seneca’s Project Decorum to manage this;
- Wiki: not available now (I’m not sure how to make it at this point);
- Pull requests: not available now, but the requester can create a new SD with the key “gitsafe_projects_id_pullrequests_n”, where “id” is the project number and “n” is the last pull request + 1. We still need to think on how the project owner would manage this (accepting/denying). Pull request discussion, can be managed by Seneca’s Decorum Project.
- Stars: Not available now, but each star can be a new SD created by the person which is starring it (gitsafe_projects_id_stars_n).
- Forks: Not available now, but we can implement the same way as “stars”.
- Watch: Not available now, but we can implement the same way as “stars”. Project owner should read this list and send a SAFE message for all followers.
The SafeHub website
A GitHub/GitLab clone website could be created (something like “safe://safehub.io”) on top of this protocol. To display projects, it would look for “safehub_projects_n”. Once a project is opened (safe://safehub.io/maidsafe/crust), it would use a JS library to read the git contents and display it to users (folder structure, commits, blame, history, etc.) in a friendly way. Extra elements would also be easy to be displayed.
We can use the same GitLab URL format to navigate inside a project (it’s folders/files/commits/issues/etc).
Search Engine: How to make a search for SafeGit projects using the “node library openal” keyword?
Permissions: owners, administrators, project being private but allowing to some people to see and change its code. How to implement this? Would be SD signatures sufficient to achieve that?
I’m calling “SafeHub” the “GitHub”/“GitLab” website clone, and “SafeGit” the protocol used to store git objects in the SAFE network. It’s somehow similar to Seneca’s Project Decorum (protocol) and the unnamed forum he’ll build using his protocol.
This doc doesn’t means that I’ll implement this by myself. It’s just an idea to anyone who wants to implement it. I can implement it, but I’m not making any promise