repository

package
v0.0.0-...-538f495 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2014 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAll

func AddAll(cloneDir string) error

func AddAllMock

func AddAllMock(testPath string) error

func Checkout

func Checkout(cloneDir, branch string, isNew bool) error

func CheckoutInNewBranch

func CheckoutInNewBranch(testPath, branch string) error

func Commit

func Commit(cloneDir, message string, author GitUser) error

func CreateBranchesOnTestRepository

func CreateBranchesOnTestRepository(tmpPath string, repo string, branches ...string) error

func CreateCommit

func CreateCommit(tmpPath, repo, file, content string) error

func CreateEmptyFile

func CreateEmptyFile(tmpPath, repo, file string) error

func CreateEmptyTestBareRepository

func CreateEmptyTestBareRepository(tmpPath, repo string) (func(), error)

func CreateEmptyTestRepository

func CreateEmptyTestRepository(tmpPath, repo string) (func(), error)

func CreateFile

func CreateFile(testPath, file, content string) error

func CreateFolder

func CreateFolder(tmpPath, repo, folder string) (string, error)

func CreateOrUpdateConfig

func CreateOrUpdateConfig(testPath, param, value string) error

func CreateTag

func CreateTag(testPath, tagname string) error

func CreateTestRepository

func CreateTestRepository(tmpPath, repo, file, content string, folders ...string) (func(), error)

func GetArchive

func GetArchive(repo, ref string, format ArchiveFormat) ([]byte, error)

GetArchive returns the contents for a given file in a given ref for the specified repository

func GetArchiveUrl

func GetArchiveUrl(repo, ref, format string) string

func GetDiff

func GetDiff(repo, previousCommit, lastCommit string) ([]byte, error)

func GetFileContents

func GetFileContents(repo, ref, path string) ([]byte, error)

GetFileContents returns the contents for a given file in a given ref for the specified repository

func GetLastHashCommit

func GetLastHashCommit(tmpPath, repo string) ([]byte, error)

func GetTree

func GetTree(repo, ref, path string) ([]map[string]string, error)

func GrantAccess

func GrantAccess(rNames, uNames []string, readOnly bool) error

GrantAccess gives full or read-only permission for users in all specified repositories. If any of the repositories/users does not exist, GrantAccess just skips it.

func InitBareRepository

func InitBareRepository(testPath string) error

func InitRepository

func InitRepository(testPath string) error

func MakeCommit

func MakeCommit(testPath, content string) error

func Push

func Push(cloneDir, branch string) error

func Remove

func Remove(name string) error

Remove deletes the repository from the database and removes it's bare Git repository.

func RevokeAccess

func RevokeAccess(rNames, uNames []string, readOnly bool) error

RevokeAccess revokes write permission from users in all specified repositories.

func SetCommitter

func SetCommitter(cloneDir string, committer GitUser) error

func StatusRepository

func StatusRepository(testPath string) error

func TempClone

func TempClone(repo string) (string, func(), error)

func Update

func Update(name string, newData Repository) error

Update update a repository data.

Types

type ArchiveFormat

type ArchiveFormat int
const (
	Zip ArchiveFormat = iota
	Tar
	TarGz
)

type ContentRetriever

type ContentRetriever interface {
	GetContents(repo, ref, path string) ([]byte, error)
	GetArchive(repo, ref string, format ArchiveFormat) ([]byte, error)
	GetTree(repo, ref, path string) ([]map[string]string, error)
	GetForEachRef(repo, pattern string) ([]Ref, error)
	GetBranches(repo string) ([]Ref, error)
	GetDiff(repo, lastCommit, previousCommit string) ([]byte, error)
	GetTags(repo string) ([]Ref, error)
	TempClone(repo string) (string, func(), error)
	SetCommitter(cloneDir string, committer GitUser) error
	Checkout(cloneDir, branch string, isNew bool) error
	AddAll(cloneDir string) error
	Commit(cloneDir, message string, author GitUser) error
	Push(cloneDir, branch string) error
	CommitZip(repo string, z *multipart.FileHeader, c GitCommit) (*Ref, error)
	GetLogs(repo, hash string, total int, path string) (*GitHistory, error)
}
var Retriever ContentRetriever

type GitCommit

type GitCommit struct {
	Message   string
	Author    GitUser
	Committer GitUser
	Branch    string
}

type GitContentRetriever

type GitContentRetriever struct{}

func (*GitContentRetriever) AddAll

func (*GitContentRetriever) AddAll(cloneDir string) error

func (*GitContentRetriever) Checkout

func (*GitContentRetriever) Checkout(cloneDir, branch string, isNew bool) error

func (*GitContentRetriever) Commit

func (*GitContentRetriever) Commit(cloneDir, message string, author GitUser) error

func (*GitContentRetriever) CommitZip

func (*GitContentRetriever) CommitZip(repo string, z *multipart.FileHeader, c GitCommit) (*Ref, error)

func (*GitContentRetriever) GetArchive

func (*GitContentRetriever) GetArchive(repo, ref string, format ArchiveFormat) ([]byte, error)

func (*GitContentRetriever) GetBranches

func (*GitContentRetriever) GetBranches(repo string) ([]Ref, error)

func (*GitContentRetriever) GetContents

func (*GitContentRetriever) GetContents(repo, ref, path string) ([]byte, error)

func (*GitContentRetriever) GetDiff

func (*GitContentRetriever) GetDiff(repo, previousCommit, lastCommit string) ([]byte, error)

func (*GitContentRetriever) GetForEachRef

func (*GitContentRetriever) GetForEachRef(repo, pattern string) ([]Ref, error)

func (*GitContentRetriever) GetLogs

func (*GitContentRetriever) GetLogs(repo, hash string, total int, path string) (*GitHistory, error)

func (*GitContentRetriever) GetTags

func (*GitContentRetriever) GetTags(repo string) ([]Ref, error)

func (*GitContentRetriever) GetTree

func (*GitContentRetriever) GetTree(repo, ref, path string) ([]map[string]string, error)

func (*GitContentRetriever) Push

func (*GitContentRetriever) Push(cloneDir, branch string) error

func (*GitContentRetriever) SetCommitter

func (*GitContentRetriever) SetCommitter(cloneDir string, committer GitUser) error

func (*GitContentRetriever) TempClone

func (*GitContentRetriever) TempClone(repo string) (cloneDir string, cleanUp func(), err error)

type GitHistory

type GitHistory struct {
	Commits []GitLog `json:"commits"`
	Next    string   `json:"next"`
}

func GetLogs

func GetLogs(repo, hash string, total int, path string) (*GitHistory, error)

type GitLog

type GitLog struct {
	Ref       string   `json:"ref"`
	Author    *GitUser `json:"author"`
	Committer *GitUser `json:"committer"`
	Subject   string   `json:"subject"`
	CreatedAt string   `json:"createdAt"`
	Parent    []string `json:"parent"`
}

type GitUser

type GitUser struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Date  string `json:"date"`
}

func (GitUser) String

func (gu GitUser) String() string
type Links struct {
	TarArchive string `json:"tarArchive"`
	ZipArchive string `json:"zipArchive"`
}

type MockContentRetriever

type MockContentRetriever struct {
	LastFormat     ArchiveFormat
	LastRef        string
	LastPath       string
	ResultContents []byte
	Tree           []map[string]string
	Ref            Ref
	Refs           []Ref
	LookPathError  error
	OutputError    error
	ClonePath      string
	CleanUp        func()
	History        GitHistory
}

func (*MockContentRetriever) AddAll

func (r *MockContentRetriever) AddAll(cloneDir string) error

func (*MockContentRetriever) Checkout

func (r *MockContentRetriever) Checkout(cloneDir, branch string, isNew bool) error

func (*MockContentRetriever) Commit

func (r *MockContentRetriever) Commit(cloneDir, message string, author GitUser) error

func (*MockContentRetriever) CommitZip

func (r *MockContentRetriever) CommitZip(repo string, z *multipart.FileHeader, c GitCommit) (*Ref, error)

func (*MockContentRetriever) GetArchive

func (r *MockContentRetriever) GetArchive(repo, ref string, format ArchiveFormat) ([]byte, error)

func (*MockContentRetriever) GetBranches

func (r *MockContentRetriever) GetBranches(repo string) ([]Ref, error)

func (*MockContentRetriever) GetContents

func (r *MockContentRetriever) GetContents(repo, ref, path string) ([]byte, error)

func (*MockContentRetriever) GetDiff

func (r *MockContentRetriever) GetDiff(repo, previousCommit, lastCommit string) ([]byte, error)

func (*MockContentRetriever) GetForEachRef

func (r *MockContentRetriever) GetForEachRef(repo, pattern string) ([]Ref, error)

func (*MockContentRetriever) GetLogs

func (r *MockContentRetriever) GetLogs(repo, hash string, total int, path string) (*GitHistory, error)

func (*MockContentRetriever) GetTags

func (r *MockContentRetriever) GetTags(repo string) ([]Ref, error)

func (*MockContentRetriever) GetTree

func (r *MockContentRetriever) GetTree(repo, ref, path string) ([]map[string]string, error)

func (*MockContentRetriever) Push

func (r *MockContentRetriever) Push(cloneDir, branch string) error

func (*MockContentRetriever) SetCommitter

func (r *MockContentRetriever) SetCommitter(cloneDir string, committer GitUser) error

func (*MockContentRetriever) TempClone

func (r *MockContentRetriever) TempClone(repo string) (string, func(), error)

type Ref

type Ref struct {
	Ref       string   `json:"ref"`
	Name      string   `json:"name"`
	Author    *GitUser `json:"author"`
	Committer *GitUser `json:"committer"`
	Links     *Links   `json:"_links"`
	Subject   string   `json:"subject"`
	CreatedAt string   `json:"createdAt"`
}

func CommitZip

func CommitZip(repo string, z *multipart.FileHeader, c GitCommit) (*Ref, error)

func GetBranches

func GetBranches(repo string) ([]Ref, error)

func GetForEachRef

func GetForEachRef(repo, pattern string) ([]Ref, error)

func GetTags

func GetTags(repo string) ([]Ref, error)

type Repository

type Repository struct {
	Name          string `bson:"_id"`
	Users         []string
	ReadOnlyUsers []string
	IsPublic      bool
}

Repository represents a Git repository. A Git repository is a record in the database and a directory in the filesystem (the bare repository).

func Get

func Get(name string) (Repository, error)

Get find a repository by name.

func New

func New(name string, users, readOnlyUsers []string, isPublic bool) (*Repository, error)

New creates a representation of a git repository. It creates a Git repository using the "bare-dir" setting and saves repository's meta data in the database.

func (*Repository) MarshalJSON

func (r *Repository) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Repository in json format.

func (*Repository) ReadOnlyURL

func (r *Repository) ReadOnlyURL() string

ReadOnly formats the git url and return it. If no host is configured in gandalf.conf, this method panics.

func (*Repository) ReadWriteURL

func (r *Repository) ReadWriteURL() string

ReadWriteURL formats the git ssh url and return it. If no remote is configured in gandalf.conf, this method panics.

Jump to

Keyboard shortcuts

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