GithubHelp home page GithubHelp logo

git-repo-version's Introduction

git-repo-version

Generates a version string based on the version specified in your package.json and the sha revision of the current commit/branch.

Install

Typically you will only need to install this as a devDependency as follows

npm install --save-dev git-repo-version

Usage

This plugin automatically exports a function that when called calculates return the version string with a sha of the given length (defaults to 8). You can also specify second parameter to include commit date in the output { includeDate: true }.

var getVersion = require('git-repo-version');
getVersion(); // "1.5.0+a1b2c3d4"
getVersion({ shaLength: 10 }); // "1.5.0+a1b2c3d4e5"
getVersion({ shaLength: 10, includeDate: true }); // "1.5.0+a1b2c3d4e5 2016-10-24T18:26:53.000Z"
getVersion({ shaLength: 0, includeDate: true }); // "1.5.0 2016-10-24T18:26:53.000Z"

The version number is determined by first valid condition:

  • If current commit is tagged and version number in app's package.json is not include in tag name, it will use tag name.
  • If app has a version number in its package.json, it will use version number in package.json and append the SHA of the current commit at the end (p.e. 1.5.0-beta.1+a1b2c3d4).
  • If current HEAD is a branch, it will use the name of the that branch and append the SHA (p.e. develop+a1b2c3d4).
  • It will use the string DETACHED_HEAD as fallback (p.e DETACHED_HEAD+1a2b3c4d)

Running tests

Simply run npm test

git-repo-version's People

Contributors

cibernox avatar jelhan avatar keithclinard avatar ondrejsevcik avatar rwjblue avatar slindberg avatar stefanpenner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

git-repo-version's Issues

Publish tags for v0.1.1 and v0.1.2?

Makes it easier to indicate what has changed to upstream packages (via GitHub's compare views: http://github.com/org/repo-name/compare/tag1...tag2).

Add the ability to include SHA date to the version

ember-cli-app-version has an issue and a PR to allow displaying SHA date in the version.

The current PR spawns a system process with a git call. It would be better to have git-repo-version optionally include the date in the version.

git-repo-info already provides authorDate we just need to include it.

Would you accept a PR with this functionality?

Caret version range results in breaking changes between versions

I wanted to flag up that this repo is depending on version ^1.0.4 of git-repo-info, which means that any version from 1.0.4 to <2.x is permitted to be installed.

Version 1.3.0 of git-repo-info contains a breaking change / bug, see rwjblue/git-repo-info#27.

This means that any upstream project who uses this module + has a git submodule is now getting errors in their build. We're using a pinned version of ember-cli-app-version which in turn uses a pinned version of git-repo-version, however we're currently unable to run our build without hacking in a force-pinned 1.2.0 version of git-repo-info.

Please consider using a smaller version range, or even a pinned version, in order to prevent these sorts of issues with downstream modules affecting everyone upstream.

Thanks for listening ๐Ÿ‘‹

`v` prefix on tags should be removed

If current commit is tagged, git-repo-version returns tag name. But it's common practice to prefix versions in tags with a v. In semver 1.0 this was part of spec:

When tagging releases in a version control system, the tag for a version MUST be โ€œvX.Y.Zโ€ e.g. โ€œv3.1.0โ€.

But the part about tagging was removed in 2.0. Nevertheless a v prefix should be removed from tag name.

Fails eslint node/no-unpublished-require validation

I noticed this in a project recently, the rule is documented here:
https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-unpublished-require.md

The issue seems clear to me that its simply missing both the the below requirements:

Rule Details

If a source code file satisfies all of the following conditions, the file is published.

  • "files" field of package.json includes the file or "files" field of package.json does not exist.
  • .npmignore does not include the file.

includeDate returns `null`

Just a heads up:

$ node -e "console.log(require('git-repo-version')({ shaLength: 10, includeDate: true }))"
0.0.1+aceae13b5b null
$ node --version
v9.4.0
$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.13
BuildVersion:	17A365

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.