Skip to content

Commit

Permalink
feat: CLI option with git-changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
rafinskipg committed Nov 23, 2014
1 parent 9d60038 commit 50af9f0
Show file tree
Hide file tree
Showing 12 changed files with 318 additions and 132 deletions.
8 changes: 1 addition & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<a name="">Git changelog</a>
# (2014-10-11)


## Features

- **options:** Added ignore tags option
([95362e8b](https://github.com/rafinskipg/git-changelog/commits/95362e8b57a673e810ffe54ff3337de1ea5109a8))
# (2014-11-23)



Expand Down
10 changes: 9 additions & 1 deletion EXTENDEDCHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<a name="">Git changelog extended</a>
# (2014-10-11)
# (2014-11-23)


## Bug Fixes
Expand Down Expand Up @@ -27,6 +27,8 @@
([6422e055](https://github.com/rafinskipg/git-changelog/commits/6422e0552b30f6e94d11b03310a23c1342aa5965))
- **options:** Added ignore tags option
([95362e8b](https://github.com/rafinskipg/git-changelog/commits/95362e8b57a673e810ffe54ff3337de1ea5109a8))
- **package:** Added global install so you can run via command
([86eae3f0](https://github.com/rafinskipg/git-changelog/commits/86eae3f013ace1c5c23afc32b2e8f878a69629f1))


## Refactor
Expand All @@ -37,6 +39,12 @@
- Added docs


## Chore

- package json version 1.1.3
- **package:** Package json version


## Documentation

- Added docs
Expand Down
9 changes: 8 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ module.exports = function(grunt) {
git_changelog: {
minimal: {
options: {
repo_url: 'https://github.com/rafinskipg/git-changelog',
appName : 'Git changelog'
}
},
tag1: {
options: {
app_name : 'Since tag 1 changelog',
file: 'outputs/tag1.md',
tag: 'v0.0.1',
debug: true
}
},
extended: {
options: {
repo_url: 'https://github.com/rafinskipg/git-changelog',
Expand Down
46 changes: 43 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# git-changelog

## NEWS!
There are new options available, check them out, now available as CLI

> A git changelog based on ANGULAR JS commit standards. [NPM page](https://www.npmjs.org/package/git-changelog)
You can see an example generated changelog [here](https://github.com/rafinskipg/git-changelog/blob/master/CHANGELOG.md)

It works as a **grunt plugin** or **CLI**, see options below

## Getting Started
This plugin requires Grunt `~0.4.1`
Expand Down Expand Up @@ -49,12 +53,48 @@ grunt.initConfig({
### Options | Defaults

* **branch_name** : The name of the branch. Defaults to ` `
* **repo_url**: The url of the project. For issues and commits links. Defaults to ` `
* **repo_url** : The url of the project. For issues and commits links. Defaults to `git config --get remote.origin.url`
* **version**: The version of the project. Defaults to ` `,
* **file**: The name of the file that will be generated. Defaults to `CHANGELOG.md`,
* **appName** : The name of the project. Defaults to `My App - Changelog`
* **ignore_tags** : Ignore tags, read from the beggining of the history. Defaults to `false`
* **appName** (DEPRECATED: Use app_name) : The name of the project. Defaults to `My App - Changelog`
* **app_name** : The name of the project. Defaults to `My App - Changelog`
* **ignore_tags** (DEPRECATED, use tag option): Ignore tags, read from the beggining of the history. Defaults to `false`
* **grep_commits**: The commits that will be picked. Defaults to `'^fix|^feat|^docs|^refactor|^chore|BREAKING'`
* **tag**: You can select from which tag to generate the log, it defaults to the last one. Set it to false for log since the beggining of the project
* **debug**: Debug mode, false by default

### Command Line
Install it globally

```
npm install -g git-changelog
```
See commands
```
git-changelog -h
```

Use it directly with the common options
```
Usage: git-changelog [options]
Options:
-h, --help output usage information
-V, --version output the version number
-e, --extended Extended log
-a, --app_name [app_name] Name [app_name]
-b, --branch [branch_name] Branch name [branch_name]
-f, --file [file] File [file]
-r, --repo_url [url] Repo url [url]
-t, --tag [tag] Since tag [tag]
-g, --grep [grep] Grep commits for [grep]
-d, --debug Debugger
```



## Git Commit Guidelines - Source : "Angular JS"

Expand Down
7 changes: 7 additions & 0 deletions outputs/tag1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<a name="">Since tag 1 changelog</a>
# (2014-11-23)



---
<sub><sup>*Generated with [git-changelog](https://github.com/rafinskipg/git-changelog). If you have any problem or suggestion, create an issue.* :) **Thanks** </sub></sup>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"dependencies": {
"commander": "^2.5.0",
"lodash": "^2.4.1",
"q": "~0.9.7"
},
"preferGlobal": "true",
Expand Down
68 changes: 68 additions & 0 deletions tasks/command.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env node


'use strict';
var _ = require('lodash');
var program = require('commander');
var git_changelog = require('./git_changelog_generate');
var options = _.cloneDeep(require('./defaults'));

program
.version('0.1.3')
.option('-e, --extended', 'Extended log')
.option('-a, --app_name [app_name]', 'Name [app_name]')
.option('-b, --branch [branch_name]', 'Branch name [branch_name]')
.option('-f, --file [file]', 'File [file]')
.option('-r, --repo_url [url]', 'Repo url [url]')
.option('-t, --tag [tag]', 'Since tag [tag]')
.option('-g, --grep [grep]', 'Grep commits for [grep]')
.option('-d, --debug', 'Debugger')
.parse(process.argv);

console.log('Executing git changelog:');
if (program.extended){
console.log(' - Extended, getting log since the BigBang');
options.ignore_tags = true;
}

if (program.app_name){
options.app_name = program.app_name;
}

if (program.branch_name){
options.branch_name = program.branch_name;
console.log(' - Branch %s', program.branch);
}
if (program.debug){
console.log('Debug enabled');
options.debug = program.debug;
}

if (program.file){
options.file = program.file;
}
if (program.url){
options.repo_url = program.url;
console.log(' - With URL %s', program.url);
}

if (program.tag != undefined){
options.tag = program.tag;

if(program.tag === false){
console.log(' - No tag, getting log since the BigBang');
}else{
console.log(' - Generating log since tag %s', program.tag);
}
}

if (program.grep){
options.grep_commits = program.grep;
}

console.log(' - The APP name is %s', options.app_name);
console.log(' - The output file is %s', options.file);

git_changelog.generate(options).then(function(){
console.log('Finished generating log Yai!')
});
49 changes: 49 additions & 0 deletions tasks/defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//Defaults options
module.exports = {
branch_name : '',
//[G]ithub [B]itbucket supported at the momment
repo_url: '',
version : '',
file: 'CHANGELOG.md',
app_name : 'My app - Changelog',
grep_commits: '^fix|^feat|^docs|BREAKING',
tag: null,
debug: false,
//TODO : remove ignore tags
ignore_tags: false,
sections: [
{
title: 'Bug Fixes',
grep: '^fix'
},
{
title: 'Features',
grep: '^feat'
},
{
title: 'Documentation',
grep: '^docs'
},
{
title: 'Breaking changes',
grep: 'BREAKING'
},
{
title: 'Refactor',
grep: '^refactor'
},
{
title: 'Style',
grep: '^style'
},
{
title: 'Test',
grep: '^test'
},
{
title: 'Chore',
grep: '^chore'
}
]

};
50 changes: 1 addition & 49 deletions tasks/git_changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,18 @@ module.exports = function(grunt) {
//Separated Logic in other file
var git_changelog = require('./git_changelog_generate');

var defaults = {
branch_name : '',
//[G]ithub [B]itbucket supported at the momment
repo_url: '',
version : '',
file: 'CHANGELOG.md',
appName : 'My app - Changelog',
grep_commits: '^fix|^feat|^docs|BREAKING',
sections: [
{
title: 'Bug Fixes',
grep: '^fix'
},
{
title: 'Features',
grep: '^feat'
},
{
title: 'Documentation',
grep: '^docs'
},
{
title: 'Breaking changes',
grep: 'BREAKING'
},
{
title: 'Refactor',
grep: '^refactor'
},
{
title: 'Style',
grep: '^style'
},
{
title: 'Test',
grep: '^test'
},
{
title: 'Chore',
grep: '^chore'
}
]

};
var defaults = require('./defaults');

grunt.registerMultiTask('git_changelog', 'A git changelog based on ANGULAR JS commit standards', function() {

var done = this.async();
// Options object
var options = this.options(defaults);

if(options.repo_url.length === 0 ){ return;}

git_changelog.generate(options).then(function(){
done();
});

});




};
Loading

0 comments on commit 50af9f0

Please sign in to comment.