gitversion

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: MIT Imports: 7 Imported by: 0

README

gitversion

Semantic like project versioning using git.

The "version" is

  1. The git tag if it exists, if not 'v0.0.0'
  2. The git commit hash.
  3. The string "uncommitted" if the current git repo is not committed.

For example:

1.0.2 136540c6f09ba9783c6d6de89a7d9f2e038f6c26 uncommitted

It's recommend git tag's value be set to the semantic version.

For example git tag 0.0.1 will result in:

0.0.1 ef8f94357058ce9cba81909016b138e6d54c0381

Go Quickstart

Godoc

import github.com/zamicol/gitversion

Why when there's go mod?

  • go mod does not use git's hashes in total for versioning.
  • There is no command to easily get the current project's mod information.
  • For running binaries on deployment servers.
  • Does not rehash the project.

Documentation

Overview

Package gitversion uses git to generate a version string useful for binary versioning.

Index

Constants

View Source
const DefaultFile string = "VERSION"

DefaultFile is the default name for where version informaion is kept.

Variables

This section is empty.

Functions

func Get

func Get(f string) (version string, date string, err error)

Get gets the current version from the VERSION file

func Now

func Now() string

Now returns time like the go mod format.

yyyymmddhhmmss

Usefull for knowing build date.

func Write

func Write(f string) (err error)

Write writes out a version file. A version file looks like this:

0.0.1 ef8f94357058ce9cba81909016b138e6d54c0381 uncommitted
2017-02-28T19:49:11-0700

Where the first line is the version, the second line is build date.

Types

This section is empty.

Jump to

Keyboard shortcuts

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