Code Monkey home page Code Monkey logo

gitex's Introduction

Gitex Build Status

See API documentation at http://hexdocs.pm/gitex.

  • Reference implementation in pure Elixir of the Git object model and storage, including optimized pack-refs and pack-objects/deltas).
  • Protocol over Git codec and backend to customize them and reuse the same versioning logic in a completely different environment and use case: JSON into Riak for instance.

TODO:

  • test it (only for regression, currently it works on many open source git repo, so it can be considered as tested)
  • add a Gitex.merge helper to help you construct a commit tree from multiple trees
  • add impl Gitex.Repo for Pid as a GenServer RPC
  • implementation example of previous GenServer maintaining ETS LRU cache of standard git fs objects and deltas
  • add some useful alternative implementations, currently only standard object encoding and storage

Usage example

r = Gitex.Git.open #Gitex.Git is the .git fs object storage
Gitex.get("master",r) #get commit
Gitex.get("myannotatedtag",r) #get tag object
Gitex.get("master",r,"/path/to/dir")  #get tree object
Gitex.get("master",r,"/path/to/file") #get blob

# get all commits from master to 1st January 2015
Gitex.history("master",r) 
|> Enum.take_while(& &1.committer.utc_time > {{2015,1,1},{0,0,0}})

# get the stream of version history of a given file
Gitex.history("master",r) 
|> Stream.map(&Gitex.get_hash(&1,r,"/path/to/file")) 
|> Stream.dedup
|> Stream.map(&Gitex.object(&1,r))

# commit history stream is powerful, play with it

Gitex.get("master",r) # return commit
|> Gitex.put(r,"/some/path/file1","file1 content") #put new trees and return new root tree hash
|> Gitex.put(r,"/some/other/path/file2","file2 content") ##put new trees and return new root tree hash
|> Gitex.commit(r,"master","some commit message") #save tree in a commit with "master" parent then update "master" and return commit hash 
|> Gitex.tag(r,"mytag") # save this commit to a soft tag return commit_tag
|> Gitex.tag(r,"myannotatedtag","my message") # save this commit to a tag object with comment, return tag hash

# Currently "put" is the only helper to construct a new "tree", for merging you have to construct the tree yourself

A nice function Gitex.align_history allows you to lazily add an index number to your history stream in order to construct a pretty visualizer very easily (d3.js for instance)

Gitex.history(:head,repo) |> Gitex.align_history

The Gitex.Repo protocol

Any repo implementing the Gitex.Repo protocol : (basically object codec, ref setter/resolver, binary get/put) can be managed with the Gitex API.

gitex's People

Contributors

awetzel avatar ronanh avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.