Giter Club home page Giter Club logo

go-borges's Introduction

GoDoc Build Status codecov.io Go Report Card

go-borges

This library abstracts read and write access to a set of go-git repositories. It comes with several implementations to support different storage methods:

  • plain: stored in the filesystem, supports transactions.
  • siva: rooted repositories in siva files, supports transactions. These files can be generated with gitcollector.
  • legacysiva: siva file generated by borges. This implementation only supports reading and does not support transactions.

When transactions are supported the writes to the repositories will be atomic and could only be seen by new readers when Commit function is called. That is, after opening a repository in read only mode any writes to it by another thread or process won't modify its contents. This is useful when the storage that is being used for reading repositories is being updated at the same time. More information and example in siva package documentation.

Installation

go-borges supports go modules and can be added to your project with:

$ go get github.com/src-d/go-borges

Example of utilization

This example lists the repositories downloaded by gitcollector.

package main

import (
	"fmt"
	"os"

	"github.com/src-d/go-borges"
	"github.com/src-d/go-borges/siva"
	"gopkg.in/src-d/go-billy.v4/osfs"
)

func main() {
	if len(os.Args) != 2 {
		fmt.Println("you need to provide the path of your siva files")
		os.Exit(1)
	}
	fs := osfs.New(os.Args[1])

	lib, err := siva.NewLibrary("library", fs, &siva.LibraryOptions{
		Bucket:        2,
		RootedRepo:    true,
		Transactional: true,
	})
	if err != nil {
		panic(err)
	}

	repos, err := lib.Repositories(borges.ReadOnlyMode)
	if err != nil {
		panic(err)
	}

	err = repos.ForEach(func(r borges.Repository) error {
		id := r.ID().String()
		head, err := r.R().Head()
		if err != nil {
			return err
		}

		fmt.Printf("repository: %v, HEAD: %v\n", id, head.Hash().String())
		return nil
	})
}

Contribute

Contributions are more than welcome, if you are interested please take a look to our Contributing Guidelines.

Code of Conduct

All activities under source{d} projects are governed by the source{d} code of conduct.

License

Apache License Version 2.0, see LICENSE.

go-borges's People

Contributors

jfontan avatar mcarmonaa avatar mcuadros avatar lwsanty avatar

Watchers

James Cloos 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.