gitup

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2017 License: MIT Imports: 6 Imported by: 0

README

GitUp

Automatically checks and updates if wished the latest tag of a Git repository.

Features

You can use 3 level of strategy: Noop, Manual and Auto. The first, does anything. The second asks a confirmation to the user on the standard input and the last, automatically updates the repository with the latest available tag.

Usage

See the GitUp test for an example of using.

Use SemVer for the version tag name

The tag name must be compliant to the Semantic Versioning 2.0. As example, v2.0.0-beta is a valid version tag but not 2.0.

Documentation

Overview

Example

Example shows how to use GitUp to check and automatically update this repository.

package main

import (
	"fmt"
	up "github.com/rvflash/gitup"
	"os"
)

func main() {
	// Defines the strategy to use in case of update.
	sup := up.UpdateStrategy{}
	sup.AddStrategy(up.MajorVersion, up.Auto)

	// Gets the path of the current repository and ignores the errors just for the demo.
	pwd, _ := os.Getwd()

	// Applies update strategy on current Git repository.
	repo, _ := up.NewRepo(pwd)
	if repo.InDemand(sup) {
		repo.Update(sup)
	}
	fmt.Println("You are on the last version of GitUp.")
}
Output:

You are on the last version of GitUp.

Index

Examples

Constants

View Source
const (
	Noop   = iota // 0
	Manual        // 1
	Auto          // 2
)

Update mode.

View Source
const (
	MajorVersion      = iota // 0
	MinorVersion             // 1
	PatchVersion             // 2
	PreReleaseVersion        // 3
	BuildMetadata            // 4
)

Version tags.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitFlow

type GitFlow interface {
	LocalTag() (string, error)
	LastTag() (string, error)
	CheckoutTag(string) error
}

GitFlow returns the current state of the repository.

type Repo

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

Repo represents a Git repository.

func NewRepo

func NewRepo(path string) (*Repo, error)

NewRepo starts a new Git repository.

func (*Repo) InDemand

func (r *Repo) InDemand(s UpdateStrategy) bool

InDemand returns true if the Git repository needs to be updated because it is not on the latest tag.

func (*Repo) Update

func (r *Repo) Update(s UpdateStrategy) error

Update returns an error if it can not to update Git repository with the latest tag.

type UpdateStrategy

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

UpdateStrategy represents the update mode.

func (*UpdateStrategy) AddStrategy

func (s *UpdateStrategy) AddStrategy(version, action uint8) (err error)

AddStrategy starts a new Git repository.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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