Coder Social home page Coder Social logo

git-buildnumber's Introduction

About git-buildnumber

git-buildnumber produces versions strings for Git repositories in a W.X.Y.Z format, such that:

W - Number of years since the start of the repo
X - Month of year of a git commit
Y - Day of the month of a git commit
Z - Order (the number) of the git commit that day

By default, git-buildnumber calculates W as the number of calendar years since the repo's initial commit, but can be changed via a command-line option (see below).

Use-case

git-buildnumber produces standardized version strings in a human-readable form for use with rolling release cycles, or when a lexicographically-ordered build number is desirable. Version strings generated by git-buildnumber are not meant as a replacement for standard short/long Git commit hashes.

Installing

Install in the usual Go way:

$ go get -u github.com/brankas/git-buildnumber

Using

The following examples are for the HEAD of a Git repo created in 2014, and where the latest commit (ie, the 0th) was made on March 3rd, 2015:

# general (from within the git worktree)
$ cd /path/to/repo
$ git-buildnumber
v1.2.3.0

# specify path to repo
$ git-buildnumber /path/to/repo
v1.2.3.0

# short form (trims last ".0")
$ git-buildnumber -short
v1.2.3

# use 2000 as year offset
$ git-buildnumber -year 2000
v15.2.3.0

# use 2015 as year offset
$ git-buildnumber -year 2015
v0.2.3.0

# short form and 2000 as year offset
$ git-buildnumber -short -year 2000
v15.2.3

# short form and 0 as year offset
$ git-buildnumber -short -year 0
v2015.2.3

# inverse
$ git-buildnumber -inverse v1.2.3.0
a3efd74543d3402b62184081ed93bfdf2c65421d

Command-line parameters

Usage of git-buildnumber:
  -inverse string
    	string to inverse
  -prefix string
    	prefix (default "v")
  -rev string
    	git revision (default "HEAD")
  -sep string
    	field separator (default ".")
  -short
    	trim last "<sep>0" from version
  -year string
    	start year offset

Note: when -year is not specified, then an attempt is made to use the year of the first commit in the repository. If the year cannot be determined, then no offset calculation will be performed.

git-buildnumber's People

Contributors

kenshaw avatar mvdan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

git-buildnumber's Issues

Performance

I've just given git-buildnumber a try.
It's a great concept, but the performance leaves a little to be desired:

$ git count
total 8888

$ time git buildnumber 
v20.4.11.0

real  15m1.018s
user  19m13.620s
sys    0m28.517s

Quarter of an hour :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.