storage

package module
v0.0.0-...-af7dc04 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 7 Imported by: 0

README

go-git-sql

An SQL-backed storage implementation for go-git.

[!WARNING]

This project is currently a work in progress, and may not include the functionality you expect. Please refer to this milestone for more details.

Creating SQL tables

CREATE TABLE IF NOT EXISTS "objects" (
  object_type BIGINT,
  object_hash VARCHAR,
  object_size BIGINT
  cont BYTEA,
);

CREATE TABLE IF NOT EXISTS "refs" (
  ref_type BIGINT,
  ref_hash VARCHAR,
  ref_name VARCHAR,
  target VARCHAR
);

Documentation

Overview

Package storage is an SQL-backed storage implementation for go-git.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ObjectStorage

type ObjectStorage struct {
	// contains filtered or unexported fields
}

func (*ObjectStorage) AddAlternate

func (o *ObjectStorage) AddAlternate(remote string) error

AddAlternate is not currently implemented.

func (*ObjectStorage) EncodedObject

func (o *ObjectStorage) EncodedObject(objType plumbing.ObjectType, objHash plumbing.Hash) (plumbing.EncodedObject, error)

EncodedObject returns the object with the specified hash and matching object type. If AnyObject is passed as the object type, only the object hash will be used in this lookup.

func (*ObjectStorage) EncodedObjectSize

func (o *ObjectStorage) EncodedObjectSize(hash plumbing.Hash) (int64, error)

EncodedObjectSize returns the size of the contents stored against the object with the specified hash.

func (*ObjectStorage) HasEncodedObject

func (o *ObjectStorage) HasEncodedObject(hash plumbing.Hash) error

HasEncodedObject checks if an object with the specified hash exists, returning nil if the object does exist, and an error if it does not.

func (*ObjectStorage) IterEncodedObjects

func (o *ObjectStorage) IterEncodedObjects(objType plumbing.ObjectType) (storer.EncodedObjectIter, error)

IterEncodedObjects returns an iterator that traverses all of the available objects of the specified type.

func (*ObjectStorage) NewEncodedObject

func (o *ObjectStorage) NewEncodedObject() plumbing.EncodedObject

NewEncodedObject returns a new copy of the default plumbing.MemoryObject.

func (*ObjectStorage) SetEncodedObject

func (o *ObjectStorage) SetEncodedObject(obj plumbing.EncodedObject) (plumbing.Hash, error)

SetEncodedObject stores the object provided.

If the object contents cannot be read, or the object fails to be written to the database, a ZeroHash will be returned with the appropriate wrapped error.

type ReferenceStorage

type ReferenceStorage struct {
	// contains filtered or unexported fields
}

func (*ReferenceStorage) CheckAndSetReference

func (r *ReferenceStorage) CheckAndSetReference(new, old *plumbing.Reference) error

func (*ReferenceStorage) CountLooseRefs

func (r *ReferenceStorage) CountLooseRefs() (int, error)

func (*ReferenceStorage) IterReferences

func (r *ReferenceStorage) IterReferences() (storer.ReferenceIter, error)

IterReferences returns an iterator capable of walking through all available Git references.

func (*ReferenceStorage) PackRefs

func (r *ReferenceStorage) PackRefs() error

PackRefs is not currently implemented.

func (*ReferenceStorage) Reference

Reference loads a Git reference from storage.

func (*ReferenceStorage) RemoveReference

func (r *ReferenceStorage) RemoveReference(name plumbing.ReferenceName) error

RemoveReference deletes a Git reference from storage by its unique name.

func (*ReferenceStorage) SetReference

func (r *ReferenceStorage) SetReference(ref *plumbing.Reference) error

SetReference writes a Git reference to storage.

type Storage

type Storage struct {
	ObjectStorage
	ReferenceStorage

	// The following structs are duplicated from the go-git memory storage
	// implementation, however they are omitted from the declaration below.
	memory.ConfigStorage
	memory.IndexStorage
	memory.ModuleStorage
	memory.ShallowStorage
}

func NewStorage

func NewStorage(client *sql.DB) *Storage

NewStorage creates a new SQL-backed storage interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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