versions

package
v0.0.0-...-0caaa62 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2017 License: GPL-3.0-or-later Imports: 10 Imported by: 0

Documentation

Overview

Package versions checks and updates vcs packages. Only git supported.

Index

Constants

This section is empty.

Variables

View Source
var (
	ArgsFetch        = "fetch"
	ArgsRev          = "rev-parse {location}"        // HEAD  or origin
	ArgsCountCommits = "rev-list --count {location}" //
	ArgsDeltaLog     = "log {format} {location}"     // -n {limit}
	ArgsUpdate       = "pull --ff-only"
)

Git commands args.

View Source
var (
	// LogFormat defines the format for ShowVersions: just show commits title (one line).
	LogFormat = "--pretty=format:%s"
)

Functions

This section is empty.

Types

type Repo

type Repo struct {
	Name    string // Repository name.
	Dir     string // Location of repo on the filesystem.
	GotData bool   // true if data was successfully pulled.

	Log   string // Commit messages for new commits.
	Delta int    // Delta of revisions between server and local.

	// template display fields.
	NewLocal int  //  Number of unmerged patch in local dir.
	Zero     bool // True if revisions are the same.
	// contains filtered or unexported fields
}

Repo checks and updates a VCS sources repository.

func NewRepo

func NewRepo(log cdtype.Logger, repo, dir string) *Repo

NewRepo creates a source repo with name and dir.

func (*Repo) Update

func (repo *Repo) Update() (delta int, logstr string, e error)

Update updates the local repo to server version, returns the count and log.

type VCS

type VCS struct {
	Cmd string
	Dir string
}

VCS get informations and acts on a git repository.

func New

func New(repoRoot string) (*VCS, error)

New creates a git client for the repo.

func NewFetched

func NewFetched(repoRoot string) (*VCS, error)

NewFetched creates a git client for the repo and updates server info.

func (*VCS) CountCommits

func (v *VCS) CountCommits(location string) (int, error)

CountCommits gives the total number of commits of the branch at location.

func (*VCS) DeltaLog

func (v *VCS) DeltaLog(location string) (string, error)

DeltaLog shows logs for location (or query).

func (*VCS) Fetch

func (v *VCS) Fetch() error

Fetch downloads server informations (apt-get update).

func (*VCS) Rev

func (v *VCS) Rev(location string) (rev string, e error)

Rev returns the current commit ID for location.

func (*VCS) RunOutput

func (v *VCS) RunOutput(dir string, cmd string, keyval ...string) ([]byte, error)

RunOutput is like run but returns the output of the command.

func (*VCS) Update

func (v *VCS) Update() (new int, e error)

Update updates the local branch and returns the number of new commmits.

type Versions

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

Versions handles version checking on multiple VCS repositories.

func NewVersions

func NewVersions(callResult func(int, error), repos ...*Repo) *Versions

NewVersions creates a multiple versions checker with some repos.

func (*Versions) AddSources

func (ver *Versions) AddSources(repos ...*Repo) *Versions

AddSources adds repositories to the managed list.

func (*Versions) Check

func (ver *Versions) Check()

Check is the callback for poller. TODO: need to better handle errors.

func (*Versions) Clear

func (ver *Versions) Clear(repos ...*Repo) *Versions

Clear clears the repositories list.

func (*Versions) CountNew

func (ver *Versions) CountNew() int

CountNew returns the number of new commits.

func (*Versions) SetCountNew

func (ver *Versions) SetCountNew(countNew int)

SetCountNew sets the number of new commits.

func (*Versions) Sources

func (ver *Versions) Sources() []*Repo

Sources lists managed repositories.

Jump to

Keyboard shortcuts

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