-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mcfly-io/yana/test-cli
- Loading branch information
Showing
9 changed files
with
269 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
'use strict'; | ||
global.Promise = require('bluebird'); | ||
|
||
const git = require('simple-git')(); | ||
const _ = require('lodash'); | ||
|
||
var getCurrentBranch = function() { | ||
return Promise | ||
.fromCallback((cb) => { | ||
git.branch(cb); | ||
}) | ||
.then(branches => { | ||
return branches.current; | ||
}); | ||
}; | ||
|
||
var commitVersion = function(version) { | ||
return Promise | ||
.fromCallback((cb) => { | ||
git | ||
.add('./*') | ||
.commit('docs(changelog): version ' + version) | ||
.addAnnotatedTag(version, 'v' + version) | ||
.push('origin', 'master') | ||
.pushTags('origin', cb); | ||
}); | ||
}; | ||
|
||
var getRemoteRepository = function() { | ||
return Promise | ||
.fromCallback((cb) => { | ||
git | ||
.getRemotes(true, cb); | ||
}) | ||
.then(remotes => { | ||
return _.chain(remotes) | ||
.find(remote => { | ||
return remote.name === 'origin'; | ||
}) | ||
.value(); | ||
}) | ||
.then(remote => { | ||
if (!remote) { | ||
throw new Error('"origin" remote repository is not configured'); | ||
} | ||
var repoUrl = remote.refs.push; | ||
var ownerRepo = repoUrl.split('/').slice(-2); | ||
return { | ||
url: repoUrl, | ||
owner: ownerRepo[0], | ||
repo: ownerRepo[1] | ||
}; | ||
}); | ||
}; | ||
|
||
var isClean = function() { | ||
return Promise | ||
.fromCallback(cb => { | ||
git.status(cb); | ||
}) | ||
.then(res => { | ||
return res.deleted.length + res.modified.length + res.created.length + res.conflicted.length <= 0; | ||
}); | ||
}; | ||
|
||
module.exports = { | ||
getCurrentBranch, | ||
commitVersion, | ||
getRemoteRepository, | ||
isClean | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.