Skip to content

Commit

Permalink
remove depdendency on cibernox/git-repo-version and directly use rwjb…
Browse files Browse the repository at this point in the history
…lue/git-repo-info

previously this used cibernox/git-repo-version and rwjblue/git-repo-info was used by cibernox/git-repo-version.
Now the code from cibernox/git-repo-version was migrated to this repo effectifly cutting the middleman.
  • Loading branch information
luxzeitlos authored and Turbo87 committed Jan 14, 2019
1 parent fdba338 commit 987748a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
34 changes: 33 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
'use strict';

const getGitInfo = require('git-repo-info');
const path = require('path');

function gitRepoVersion(options) {
options = options || {};
var shaLength = options.shaLength != null ? options.shaLength : 8;
var includeDate = options.includeDate || false;
var projectPath = options.projectPath || process.cwd();
var info = getGitInfo(projectPath);
var packageVersion = require(path.join(projectPath, 'package.json')).version;

var prefix;
if (info.tag && !(packageVersion && info.tag.includes(packageVersion))) {
prefix = info.tag;
} else if (packageVersion) {
prefix = packageVersion;
} else if (info.branch) {
prefix = info.branch;
} else {
prefix = 'DETACHED_HEAD';
}

var sha = '';
if (shaLength > 0 && info.sha) {
sha = '+' + info.sha.substring(0, shaLength);
}

var authorDate = includeDate ? ' ' + info.authorDate : '';

return prefix + sha + authorDate;
};

module.exports = {
name: 'ember-cli-app-version',
config(env, baseConfig) {
Expand All @@ -16,7 +48,7 @@ module.exports = {
return config;
}

let version = require('git-repo-version')(null, this.project.root);
let version = gitRepoVersion(null, this.project.root);
if (version && baseConfig.APP) {
baseConfig.APP.version = version;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
],
"dependencies": {
"ember-cli-babel": "^6.12.0",
"git-repo-version": "^1.0.2"
"git-repo-info": "^2.1.0"
},
"ember-addon": {
"configPath": "tests/dummy/config"
Expand Down
17 changes: 4 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3576,19 +3576,10 @@ git-read-pkt-line@0.0.8:
bops "0.0.3"
through "~2.2.7"

git-repo-info@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/git-repo-info/-/git-repo-info-1.4.1.tgz#2a072823254aaf62fcf0766007d7b6651bd41943"

git-repo-info@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/git-repo-info/-/git-repo-info-2.0.0.tgz#2e7a68ba3d0253e8e885c4138f922e6561de59bb"

git-repo-version@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/git-repo-version/-/git-repo-version-1.0.2.tgz#2c8e9bee5d970cafc0dd58480f9dc56d9afe8e4f"
dependencies:
git-repo-info "^1.4.1"
git-repo-info@^2.0.0, git-repo-info@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/git-repo-info/-/git-repo-info-2.1.0.tgz#13d1f753c75bc2994432e65a71e35377ff563813"
integrity sha512-+kigfDB7j3W80f74BoOUX+lKOmf4pR3/i2Ww6baKTCPe2hD4FRdjhV3s4P5Dy0Tak1uY1891QhKoYNtnyX2VvA==

git-transport-protocol@^0.1.0:
version "0.1.0"
Expand Down

0 comments on commit 987748a

Please sign in to comment.