gitgo

package module
v0.0.0-...-9921b28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2016 License: Apache-2.0 Imports: 13 Imported by: 2

README

gitgo 
========
[![GoDoc](https://godoc.org/github.com/ChimeraCoder/gitgo?status.svg)](https://godoc.org/github.com/ChimeraCoder/gitgo)
[![Build Status](https://travis-ci.org/ChimeraCoder/gitgo.svg?branch=master)](https://travis-ci.org/ChimeraCoder/gitgo)


Gitgo provides Go functions for interacting with Git repositories.

Unlike libgit2, which is written in C, Gitgo is written in pure Go, and can be compiled and cross-compiled easily for all platforms supported by Go.


Installation
--------------

`
$ go get github.com/ChimeraCoder/gitgo
`


Usage
---------

Full documentation is available on [GoDoc](https://godoc.org/github.com/ChimeraCoder/gitgo).

Gitgo is a library intended to be used by other applications, rather than a replacement for the `git` command-line tools. However, gitgo does provide the `gitgo` binary, which is used for testing the gitgo library functions and demonstrating their functionality:

````
$ cd $GOPATH/src/github.com/ChimeraCoder/gitgo
$ gitgo log 1d833eb5b6c5369c0cb7a4a3e20ded237490145f
commit 1d833eb5b6c5369c0cb7a4a3e20ded237490145f
Author: aditya <dev@chimeracoder.net>
Date:   Mon Apr 6 15:49:15 2015 -0400

    Parse git object into struct and add corresponding test
    
commit a7f92c920ce85f07a33f948aa4fa2548b270024f
Author: aditya <dev@chimeracoder.net>
Date:   Fri Apr 3 12:38:24 2015 -0400

    Add CatFile function and corresponding test
    
commit 97eed02ebe122df8fdd853c1215d8775f3d9f1a1
Author: aditya <dev@chimeracoder.net>
Date:   Fri Apr 3 11:45:00 2015 -0400

    First commit. Create .gitignore

````

Note that the `gitgo` binary does not support all (or even most) of the functions provided by the gitgo library; it is intended for demonstration purposes and testing only.

Documentation

Index

Constants

View Source
const (
	OBJ_COMMIT packObjectType
	OBJ_TREE
	OBJ_BLOB
	OBJ_TAG

	OBJ_OFS_DELTA
	OBJ_REF_DELTA
)
View Source
const (
	RFC2822 = "Mon Jan 2 15:04:05 2006 -0700"
)

Variables

This section is empty.

Functions

func CatFile

func CatFile(name SHA) (io.Reader, error)

CatFile implements git cat-file for the command-line tool. Currently it supports only the -t fiag

func ScanLinesNoTrim

func ScanLinesNoTrim(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanLinesNoTrim is exactly like bufio.ScanLines, except it does not trim the newline

func ScanNullLines

func ScanNullLines(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanNullLines is like bufio.ScanLines, except it uses the null character as the delimiter instead of a newline

func VerifyPack

func VerifyPack(pack io.ReadSeeker, idx io.Reader) ([]*packObject, error)

VerifyPack returns the pack objects contained in the packfile and corresponding index file.

Types

type Blob

type Blob struct {
	Contents []byte
	// contains filtered or unexported fields
}

A Blob compresses content from a file

func (Blob) Type

func (b Blob) Type() string

type Commit

type Commit struct {
	Name          SHA
	Tree          string
	Parents       []SHA
	Author        string
	AuthorDate    time.Time
	Committer     string
	CommitterDate time.Time
	Message       []byte
	// contains filtered or unexported fields
}

func Log

func Log(name SHA, basedir *os.File) ([]Commit, error)

Log is equivalent to `git log <SHA>`. If basedir is non-nil and points to a valid git respository, the command will be run using that repository.

func (Commit) Type

func (c Commit) Type() string

type GitObject

type GitObject interface {
	Type() string
}

GitObject represents a commit, tree, or blob. Under the hood, these may be objects stored directly or through packfiles

func NewObject

func NewObject(input SHA, basedir os.File) (obj GitObject, err error)

type Repository

type Repository struct {
	Basedir os.File
	// contains filtered or unexported fields
}

func (*Repository) Object

func (r *Repository) Object(input SHA) (obj GitObject, err error)

type SHA

type SHA string

SHA represents the SHA-1 hash used by git

type Tree

type Tree struct {
	Blobs []objectMeta
	Trees []objectMeta
	// contains filtered or unexported fields
}

func (Tree) Type

func (t Tree) Type() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL