githttp

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

README

Source: https://github.com/AaronO/go-git-http Original code released under Apache License 2.0

Changes: add "git/" prefix to all routes

Documentation

Index

Constants

View Source
const (
	TAG = iota + 1
	PUSH
	FETCH
	PUSH_FORCE
)

Possible event types

View Source
const VERSION = "1.0.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorNoAccess

type ErrorNoAccess struct {
	// Path to directory of repo accessed
	Dir string
}

func (*ErrorNoAccess) Error

func (e *ErrorNoAccess) Error() string

type Event

type Event struct {
	// One of tag/push/fetch
	Type EventType `json:"type"`

	// SHA of commit
	Commit string `json:"commit"`

	// Path to bare repo
	Dir string

	////
	// Set for pushes or tagging
	////
	Tag    string `json:"tag,omitempty"`
	Last   string `json:"last,omitempty"`
	Branch string `json:"branch,omitempty"`

	// Error contains the error that happened (if any)
	// during this action/event
	Error error

	// Http stuff
	Request *http.Request
}

An event (triggered on push/pull)

type EventType

type EventType int

func (EventType) MarshalJSON

func (e EventType) MarshalJSON() ([]byte, error)

func (EventType) String

func (e EventType) String() string

func (EventType) UnmarshalJSON

func (e EventType) UnmarshalJSON(data []byte) error

type GitHttp

type GitHttp struct {
	// Root directory to serve repos from
	ProjectRoot string

	// Path to git binary
	GitBinPath string

	// Access rules
	UploadPack  bool
	ReceivePack bool

	// Event handling functions
	EventHandler func(ev Event)
}

func New

func New(root string) *GitHttp

Shorthand constructor for most common scenario

func (*GitHttp) Init

func (g *GitHttp) Init() (*GitHttp, error)

Build root directory if doesn't exist

func (*GitHttp) ServeHTTP

func (g *GitHttp) ServeHTTP(w http.ResponseWriter, r *http.Request)

Implement the http.Handler interface

type GitReader

type GitReader struct {
	// Underlying reader (to relay calls to)
	io.Reader

	// Error
	GitError error
}

GitReader scans for errors in the output of a git command

func (*GitReader) Read

func (g *GitReader) Read(p []byte) (n int, err error)

Implement the io.Reader interface

type HandlerReq

type HandlerReq struct {
	Rpc  string
	Dir  string
	File string
	// contains filtered or unexported fields
}

type RpcReader

type RpcReader struct {
	// Underlying reader (to relay calls to).
	io.Reader

	// Rpc type (receive-pack or upload-pack).
	Rpc string

	// List of events RpcReader has picked up through scanning.
	// These events do not have the Dir field set.
	Events []Event
	// contains filtered or unexported fields
}

RpcReader scans for events in the incoming rpc request data.

func (*RpcReader) Read

func (r *RpcReader) Read(p []byte) (n int, err error)

Read implements the io.Reader interface.

type Service

type Service struct {
	Method  string
	Handler func(HandlerReq) error
	Rpc     string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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