SafeGit - Git protocol on SAFE

That’s a proposal to run Git directly on SAFE:

Usage:
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

Much better.

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:

https://www.kernel.org/pub/software/scm/git/docs/gitremote-helpers.html

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.

Internals
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.

Extra elements

  • 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).

Unresolved questions

  1. Search Engine: How to make a search for SafeGit projects using the “node library openal” keyword?

  2. 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?

Observations

  1. 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.

  2. 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 :wink:


Thoughts anyone?

19 Likes

[quote=“dyates, post:1, topic:7243”]
I can implement it, but I’m not making any promise
[/quote]If you can make something like Github, make it. It’s a joke that Github can be taken down, so that’s a unique selling point that you’ll have with a SAFE Network powered counterpart.

If your looking for an investor I’m on board with this one, you could monetize this product easily.

It would be fun if you can import your existing code into SAFEhub, but I think that’s what you mean with this question:

Sorry if I sound pessimistic, but if you can’t solve search you got a “big problem”, for now you could have the firstmover advantage with this one, so keep in mind that time is ticking.

1 Like

sorry to say but i don’t think you could monetize it that easy :wink: … github uses git … but e.g. I have a git repo on my small private server too … not that it would make sense … i don’t even know right now what i uploaded there … it isn’t hard to set it up and for using it with the safenet it seems to be “not a big deal” if you do have the plugin … if people use it in the command line you don’t have a chance to show any ads, you don’t even have a chance to know how many people use your service :wink:

Extremely cool idea!!! @dyates
git on safenet will be awesome!!!

2 Likes

Sorry, I think my title was a little misleading. I started with GitHub in mind, but it’s actually a Git tool. It’s a more basic piece of software, that you can use to build GitHub like websites on top of it (and monetize it by offering a search engine, by creating an alt-currency to pay developers, or by offering another kind of extra features). It was all mixed up in my post (Git+GitHub).

I believe this will be useful not only to build GitHub clones, but even for direct use. For example, the Popcorn team could have pushed their app to “safe://popcorn/popcorn” and it would be still running, with anonymous contributions. Since people know the url required to access a repo, it won’t be a problem to not have a website like github.

I’ll change the title (remove the “SafeHub”/“GitHub” references) to make things more clear.

2 Likes

I’m not pro with these things, but here are a couple of free & opensourced Github Clones:

It would just be nice to have a Github on the SAFE Network. Mind you that it would be something that would attract devs and companies who don’t want to wait for days before Github gets online again. We all know, that it’s a promise that attacks on Github will only get worse in the future. So if you can avoid some headache and lost of time & money :grinning: Somehow it doesn’t seem logic to have the SAFE Network, but to have it’s code still on the current internet.

[quote=“riddim, post:3, topic:7243”]
sorry to say but i don’t think you could monetize it that easy
[/quote]I think everything can be monetized, proof:

https://www.google.nl/search?q=bottled+water&oq=bottled+w&aqs=chrome.1.69i57j0l5.4977j0j4&sourceid=chrome&es_sm=93&ie=UTF-8

:stuck_out_tongue:

1 Like

I agree. Right off the top of my head, I can think on 2 ways:

  1. Each star is a contribution. In the repo SD, the owner can set its wallet address to receive safe or alt coins;
  2. Each download requires a payment. All data is encrypted. To get the key, is necessary to make a deposit (using an alt coin) and send a SAFE message. A bunch of miners would be listing for messages and will resolve your request by duplicating the repo with a new key where only the downloader have access;

With this both developer and the organization behind it (us) would receive money.

But is this really a good thing?

1 Like

oh - ok - you are right Oo … there are ways =D

[quote=“19eddyjohn75, post:5, topic:7243”]

[/quote] wh0000t?! :grinning: :smile:

I live in cornwall, if you can get the advertising done, i can get to bottling some of this fresh fresh air :stuck_out_tongue:

3 Likes

just have a variation on this, it’s not rocket science :rocket:

2 Likes

It creates movement and a new use case for the crypto-economy seen as a reward program ,
besides adding an additional layer of data safety and persistence . What would be of help
are measures to account well for the price differences , that is , to fetch an average price of a coin …
Initially , I’d say that safecoin is the best digital cash equivalent by design proposal , but it’s not ready yet , so , in the meantime , one could accept via a partnership all kind of payments that such a partnering service would offers … some allow for a great variety , and getting signed up two or three of such services should cover pretty much all use cases with enough generosity … :ant:

Awesome. Build it, and they will come.

5 Likes

This is AWESOME! I think that it would be nice to have a pretty web interface for the repos, like Gitlab…

3 Likes

Finally, SAFEhub is coming to Life!

I see more and more of the “Potential Apps” coming to life every day.

Very exciting times! From dreams to reality!

2 Likes

But just to clarify: this is not “the” safe version of git or github. It’s just “a” version. I do not own the “git on safe” idea and I do not intend to. It’s not because I present its technical details first, that I have any kind of ownership or leadership of “git on safe” ideas. I think I’m stating the obvious, but it’s good to remember. Maybe on future, we’ll have many “git on safe” protocols, some free, some paid - each one with its own strengths and features. At least, it’s what I hope (the same with all other kind of projects - social networks, search engines, and so on). Please guys, feel free to present and/or implement your own git+safe idea.

1 Like

It would be fun to just have a crazy combination of these three amigo’s

Github pages could check that the freelancer does what is asked to code and autopay the freelancer.
Learners could pay or freely learn how to make a site
Learning/coding/hiring on one page and like @whiteoutmashups after that push your app to SAFEhub. Maybe if you can let coders record or display in real-time what they are doing, just let your imagination run wild…

Coding/learning and creating content to upload to let’s say safe://f@#kyou.tube (the fun thing is this domain name would just work)

Maybe we shouldn’t mirror the current internet, but take a different look at it, like Google glass and hyper augment our reality.
That’s enough of me :stuck_out_tongue:

3 Likes

Back to the technical aspects, That’s how I intend to address the “permissions” issue:

The permission feature will be based on GitLab/GitHub.

  1. Each organization (it can also be called as “namespace” or “group”) has members;
  2. Each member can be a developer (write permissions), a guest (read permissions even on private/encrypted projects), or an owner (read/write permissions + can remove/add new members).
  3. Trying to keep it simple, at this early stage we’ll have only 1 owner per organization;

Proposal #1

  • the project SD will contain a list of developers and a list of guests (a list of their safe ids);
  • the above lists keep track of all staff changes over time. We can check if an user were on the list in a given time;
  • git logs (commit history) won’t be stored at project’s SD anymore. Instead, each log entry will be stored at its own SD (“safegit_projects_n_logs_m”, where “m” is a number from 1 to the last commit);
  • the git client, when rebuilding project’s git logs, will need to get each log SD, ignoring the ones with unauthorized owners at the time they were created;

Problems with proposal #1

  • client needs to download many SDs. If the project has 1k commits, it will be required 1k downloads in order to rebuild the git logs. And it’s very usual to have much more than 1k commits, even in personal projects. Big projects like linux, have more than 500k commits, so 500,000 downloads - which is unpractical for a web interface;
  • vulnerability to attacks: an attacker can create many “safegit_projects_n_logs_m” SDs, filling them with trash. Although the client will ignore them (because their SD owner is not authorized), it will still be necessary to download all of them in order to discover if they are invalid or not.

Proposal #2

  • we have the same developers/guest lists as proposal #1 (also time-tracked);
  • each developer should create a new SD owned by itself (“safegit_projects_n_developers_o”, where “o” is developer’s safe id);
  • this developer’s SD will contain the whole git logs, from all developers;
  • each time a developer pushes his commits to safe, safe client will read all others developers SDs (plus the owner one) looking for the most updated one, then, it will add this new commits and save it on the developer SD;
  • each time a client pulls the project, it should read all developers SDs (plus the owner one), and use the most updated one;
  • each time the owner changes developer list, he should update his own git log’s SD;

Problems with proposal #2

  • it fixes all problems of proposal #1, but still needs to read some SDs (few). It’s not really a problem, since even big projects like linux have few committers (if I’m not wrong, only Linus can commit on linux). In big projects, it’s more usual to merge pull requests, than have developers committing directly in the repo.

So, I think proposal #2 is good enough to handle permissions.

I love this idea. There was a decentralized version of Github built on top of Bitcoin being developed (on Github of course!) called Gitchain, but the developer could not keep it up. I think SafeGit would take a lot less dev time to build, since Maidsafe has so much of the file transfer & storage covered.

Devs, feel free to have a look at the attempt – perhaps there are ideas to steal. GitHub - gitchain/gitchain: Decentralized, peer-to-peer Git repositories aka "Git meets Bitcoin"

4 Likes