vcsapi

package
v0.0.0-...-5c7ce4c Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Check will verify that the repository type is supported by this implementation
	Check() bool

	// VCSType returns the version control system type (git, ...)
	VCSType() string

	// VCSRemote returns the primary remote (server)
	VCSRemote() string

	// VCSHostServer returns the host of the primary remote
	VCSHostServer(remote string) string

	// VCSHostType returns the type of the host
	VCSHostType(server string) string

	// VCSRefToInternalRef converts the reference to the internal notation used by the VCS
	VCSRefToInternalRef(ref VCSRef) string

	// VCSHead returns the current head of the repository (refType and refName)
	VCSHead() (ref VCSRef, err error)

	// GetTags returns all tags
	GetTags() (tags []VCSRef)

	// GetTagsByHash returns all tags of the given commit hash
	GetTagsByHash(hash string) []VCSRef

	// FindCommitByHash will query a commit by hash, additionally includes changes made by the commit
	FindCommitByHash(hash string, includeChanges bool) (Commit, error)

	// FindCommitsBetween finds all commits between two references (might need to use GetReference to get the proper ref name)
	FindCommitsBetween(from *VCSRef, to *VCSRef, includeChanges bool, limit int) ([]Commit, error)

	// Diff returns the diff between two references (might need to use GetReference to get the proper ref name)
	Diff(from *VCSRef, to *VCSRef) ([]VCSDiff, error)

	// FindLatestRelease finds the latest release starting from the current repo HEAD
	FindLatestRelease(stable bool) (VCSRelease, error)

	// CreateBranch creates a new local branch from the current head and checks it out
	CreateBranch(branch string) error

	// IsClean returns true if the repository is clean (no uncommitted changes)
	IsClean() (bool, error)

	// UncommittedChanges returns a list of all files with uncommitted changes
	UncommittedChanges() ([]string, error)
}

Client is the common interface for all vcs repo implementations

type Commit

type Commit struct {
	ShortHash   string            `json:"hash_short"`
	Hash        string            `json:"hash"`
	Message     string            `json:"message"`
	Description string            `json:"description"`
	Author      CommitAuthor      `json:"author"`
	Committer   CommitAuthor      `json:"committer"`
	Changes     []CommitChange    `json:"changes,omitempty"`
	Tags        []VCSRef          `json:"tags"`
	AuthoredAt  time.Time         `json:"authored_at"`
	CommittedAt time.Time         `json:"committed_at"`
	Context     map[string]string `json:"context,omitempty"`
}

type CommitAuthor

type CommitAuthor struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

type CommitChange

type CommitChange struct {
	Type     string     `json:"type"`
	FileFrom CommitFile `json:"file_from"`
	FileTo   CommitFile `json:"file_to"`
	Patch    string     `json:"patch"`
}

type CommitFile

type CommitFile struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
	Hash string `json:"hash"`
	Mode string `json:"mode,omitempty"`
}

type VCSDiff

type VCSDiff struct {
	FileFrom CommitFile    `json:"file_from"`
	FileTo   CommitFile    `json:"file_to"`
	Lines    []VCSDiffLine `json:"lines,omitempty"`
}

type VCSDiffLine

type VCSDiffLine struct {
	Operation int    `json:"operation"`
	Content   string `json:"content"`
}

func Diff

func Diff(srcContent string, dstContent string) []VCSDiffLine

type VCSRef

type VCSRef struct {
	Type  string `json:"type"`
	Value string `json:"value"`
	Hash  string `json:"hash,omitempty"`
}

func NewVCSRefFromString

func NewVCSRefFromString(input string) (*VCSRef, error)

NewVCSRefFromString parses the input string and returns a VCSRef

type VCSRelease

type VCSRelease struct {
	Type    string `json:"type"`
	Value   string `json:"value"`
	Version string `json:"version"`
	Hash    string `json:"hash,omitempty"`
}

Jump to

Keyboard shortcuts

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