Skip to content

Commit

Permalink
Template working
Browse files Browse the repository at this point in the history
  • Loading branch information
rafinskipg committed Dec 17, 2016
1 parent 725208c commit e980427
Show file tree
Hide file tree
Showing 16 changed files with 604 additions and 493 deletions.
11 changes: 5 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# my name
<img width="300px" src="https:/rafinskipg/git-changelog/raw/master/images/git-changelog-logo.png" />

## ( )
# Git changelog

_Git changelog is a utility tool for generating changelogs. It is free and opensource. :)_

## Bug Fixes
## ( )


## Bug Fixes
- **git tag**

- get latest tag, regardless of branch for workflows that rely on git-flow releases (48800306fa5ac19b7e9a4c6d7f2f432ee8ae4d84)





<sub><sup>*Generated with [git-changelog](https:/rafinskipg/git-changelog). If you have any problems or suggestions, create an issue.* :) **Thanks** </sub></sup>
420 changes: 148 additions & 272 deletions EXTENDEDCHANGELOG.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module.exports = function(grunt) {
tag1: {
options: {
app_name : 'Since tag 1 changelog',
intro: 'This changelog is from the previous tag',
file: 'output/tag1.md',
logo : 'https:/rafinskipg/git-changelog/raw/master/images/git-changelog-logo.png',
version : 'squeezy potatoe',
Expand Down
272 changes: 272 additions & 0 deletions output/customTemplate.md

Large diffs are not rendered by default.

119 changes: 48 additions & 71 deletions output/tag1.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,59 @@
<img width="300px" src="https:/rafinskipg/git-changelog/raw/master/images/git-changelog-logo.png" />

__Since tag 1 changelog__
# Since tag 1 changelog

# squeezy potatoe (2016-07-29)
_This changelog is from the previous tag_

## v0.0.1 ( )


---

## Bug Fixes
- Fix generation of logs (cddb2408fa3017be704acac51dabbba9f477a547
- correctly get branch name from the command line (4baa075bd93f878ee708817f911fe89c102dec02
- correctly detect when running under grunt on Windows (4205ea49a893e4d1807a39268739c13754d40cf2
- fixed tests (2e60172a4666c70d27e66d15dad297b89fff9583
- Stream didn't close properly (99f228cfa5cb26c46ef9e3b00171a5e3d38fd844
- Github commit url (c186f2d877e7907305953610bcaaef331406178a
- **checkpath**
- add missing require('path') (e5dab826062bd22dd37c8c3d3c24a4d9b4701f6d)
- **generate**
- create path to file if it does not already exist (62f6210f6895bcf5f9984b26948178b1a93cbc9e)
- **git log**
- Ignores letter case (d4cff0a86c5ce46405f3c0dd03f9c49a7d620792, Closes: [#54](https:/rafinskipg/git-changelog/issues/54))
- **git tag**
- get latest tag, regardless of branch for workflows that rely on git-flow releases (48800306fa5ac19b7e9a4c6d7f2f432ee8ae4d84)
- **git_changelog_generate**
- pass tag if it exists to gitReadLog (7c801927672792fc9a818653b74c78d77c7bff9e, Closes: [#5](https:/rafinskipg/git-changelog/issues/5))
- **nested lists**
- nested list fix. Closes #9 (2285551810919bd4d8a749ae3ddd88f9cedcdd0e, Closes: [#9](https:/rafinskipg/git-changelog/issues/9))
- **options**
- use repo_url instead of url (346b39491923a49a3421f174a566b204d5fc7db9)
- **package.json**
- move q to dependancies since it is required to run (257119cf2bb6d8f341a5d65a2f47bcf803dff205)
- **params**
- Restores versionName in CLI (1d97f952bd5d37f67c1febdf161f4ce9b310eebf)

- Fix generation of logs
([cddb2408](https:/rafinskipg/git-changelog/commit/cddb2408fa3017be704acac51dabbba9f477a547))
- correctly get branch name from the command line
([4baa075b](https:/rafinskipg/git-changelog/commit/4baa075bd93f878ee708817f911fe89c102dec02))
- correctly detect when running under grunt on Windows
([4205ea49](https:/rafinskipg/git-changelog/commit/4205ea49a893e4d1807a39268739c13754d40cf2))
- fixed tests
([2e60172a](https:/rafinskipg/git-changelog/commit/2e60172a4666c70d27e66d15dad297b89fff9583))
- Stream didn't close properly
([99f228cf](https:/rafinskipg/git-changelog/commit/99f228cfa5cb26c46ef9e3b00171a5e3d38fd844))
- Github commit url
([c186f2d8](https:/rafinskipg/git-changelog/commit/c186f2d877e7907305953610bcaaef331406178a))
- **checkpath:** add missing require('path')
([e5dab826](https:/rafinskipg/git-changelog/commit/e5dab826062bd22dd37c8c3d3c24a4d9b4701f6d))
- **generate:** create path to file if it does not already exist
([62f6210f](https:/rafinskipg/git-changelog/commit/62f6210f6895bcf5f9984b26948178b1a93cbc9e))
- **git log:** Ignores letter case
([d4cff0a8](https:/rafinskipg/git-changelog/commit/d4cff0a86c5ce46405f3c0dd03f9c49a7d620792),
[#54](https:/rafinskipg/git-changelog/issues/54))
- **git_changelog_generate:** pass tag if it exists to gitReadLog
([7c801927](https:/rafinskipg/git-changelog/commit/7c801927672792fc9a818653b74c78d77c7bff9e),
[#5](https:/rafinskipg/git-changelog/issues/5))
- **nested lists:** nested list fix. Closes #9
([22855518](https:/rafinskipg/git-changelog/commit/2285551810919bd4d8a749ae3ddd88f9cedcdd0e),
[#9](https:/rafinskipg/git-changelog/issues/9))
- **options:** use repo_url instead of url
([346b3949](https:/rafinskipg/git-changelog/commit/346b39491923a49a3421f174a566b204d5fc7db9))
- **package.json:** move q to dependancies since it is required to run
([257119cf](https:/rafinskipg/git-changelog/commit/257119cf2bb6d8f341a5d65a2f47bcf803dff205))
- **params:** Restores versionName in CLI
([1d97f952](https:/rafinskipg/git-changelog/commit/1d97f952bd5d37f67c1febdf161f4ce9b310eebf))


## Pull requests merged

- Merge pull request #55 from kerimdzhanov/patch-1
([31d13896](https:/rafinskipg/git-changelog/commit/31d1389637b59ac3a6c68c3f8fca99045675c36c))
- Merge pull request #50 from rafinskipg/changelogrc
([fd07a4bf](https:/rafinskipg/git-changelog/commit/fd07a4bf039c7c8ddbb496c644dfd5fcc1627904))
- Merge pull request #41 from pmiossec/fix_branch_option
([6247118a](https:/rafinskipg/git-changelog/commit/6247118a573259cbe71c6fdd28cb53dcb7f1b855))
- Merge pull request #45 from xcambar/versionName
([2e50373a](https:/rafinskipg/git-changelog/commit/2e50373a6f42e53598612f0e474c008624d6e80c))
- Merge pull request #47 from Sjors/patch-1
([d786fd08](https:/rafinskipg/git-changelog/commit/d786fd084d7c1c250c866bec3c5d0c73b9abe271))
- Merge pull request #46 from zoner14/master
([0485a1fd](https:/rafinskipg/git-changelog/commit/0485a1fd4bf01662f50b93098c6b535eb7c527eb))
- Merge pull request #37 from richardthombs/fix-grunt-on-windows
([5f024339](https:/rafinskipg/git-changelog/commit/5f02433963b5b603c5763bd5c1a37cf8ca9e3598))
- Merge pull request #33 from richardthombs/fix-typos
([2656d150](https:/rafinskipg/git-changelog/commit/2656d150eb95c6ad9326e4265ba64edf8e49a11c))
- Merge pull request #30 from JohnnyEstilles/refactor/get-stream
([a52b1169](https:/rafinskipg/git-changelog/commit/a52b1169a2510d83d6d4fd5113ce157f30c4d4d0))
- Merge pull request #25 from JohnnyEstilles/code-climate
([28053b92](https:/rafinskipg/git-changelog/commit/28053b9292d3d61fb33a004f6088c244e653b76b))
- Merge pull request #23 from JohnnyEstilles/docs/readme-updates
([3079151a](https:/rafinskipg/git-changelog/commit/3079151a8d5f90d0830aab4437a65dff4d837b2a))
- Merge pull request #20 from JohnnyEstilles/feature/code-refactoring
([be209f04](https:/rafinskipg/git-changelog/commit/be209f04c22f1ce2cb82e6412c4ddf117897a9e7))
- Merge pull request #12 from jodybrewster/master
([219ea809](https:/rafinskipg/git-changelog/commit/219ea8091ac81a55b0210c9a7fd41a7f0ee5660f))
- Merge pull request #7 from colegleason/fix-tags
([1d4f6043](https:/rafinskipg/git-changelog/commit/1d4f604363094d4eee3b4d7b1ca01133edaad344))
- Merge pull request #6 from colegleason/add-q
([2a712b9c](https:/rafinskipg/git-changelog/commit/2a712b9cfd912f36b6f7f70d16b336575881881a))



---
<sub><sup>*Generated with [git-changelog](https:/rafinskipg/git-changelog). If you have any problems or suggestions, create an issue.* :) **Thanks** </sub></sup>
- Merge pull request #60 from seivan/feature/latest_tag_regardless_of_branch (1ff50d0dc03f8c0db9961c034945c3ef8f4268f7
- Merge pull request #58 from olamothe/master (3fed727077168815f24aad7bbf5768913e3843ab
- Merge pull request #55 from kerimdzhanov/patch-1 (31d1389637b59ac3a6c68c3f8fca99045675c36c
- Merge pull request #50 from rafinskipg/changelogrc (fd07a4bf039c7c8ddbb496c644dfd5fcc1627904
- Merge pull request #41 from pmiossec/fix_branch_option (6247118a573259cbe71c6fdd28cb53dcb7f1b855
- Merge pull request #45 from xcambar/versionName (2e50373a6f42e53598612f0e474c008624d6e80c
- Merge pull request #47 from Sjors/patch-1 (d786fd084d7c1c250c866bec3c5d0c73b9abe271
- Merge pull request #46 from zoner14/master (0485a1fd4bf01662f50b93098c6b535eb7c527eb
- Merge pull request #37 from richardthombs/fix-grunt-on-windows (5f02433963b5b603c5763bd5c1a37cf8ca9e3598
- Merge pull request #33 from richardthombs/fix-typos (2656d150eb95c6ad9326e4265ba64edf8e49a11c
- Merge pull request #30 from JohnnyEstilles/refactor/get-stream (a52b1169a2510d83d6d4fd5113ce157f30c4d4d0
- Merge pull request #25 from JohnnyEstilles/code-climate (28053b9292d3d61fb33a004f6088c244e653b76b
- Merge pull request #23 from JohnnyEstilles/docs/readme-updates (3079151a8d5f90d0830aab4437a65dff4d837b2a
- Merge pull request #20 from JohnnyEstilles/feature/code-refactoring (be209f04c22f1ce2cb82e6412c4ddf117897a9e7
- Merge pull request #12 from jodybrewster/master (219ea8091ac81a55b0210c9a7fd41a7f0ee5660f
- Merge pull request #7 from colegleason/fix-tags (1d4f604363094d4eee3b4d7b1ca01133edaad344
- Merge pull request #6 from colegleason/add-q (2a712b9cfd912f36b6f7f70d16b336575881881a



<sub><sup>*Generated with [git-changelog](https:/rafinskipg/git-changelog). If you have any problems or suggestions, create an issue.* :) **Thanks** </sub></sup>
2 changes: 1 addition & 1 deletion tasks/lib/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function generateFromCommits(commits, sections) {
this.log('debug', 'Parsed', commits.length, 'commits');
this.log('info','Generating changelog to', this.options.file || 'stdout', '(', this.options.version, ')');

return this.writeChangelog(this.options, commits, sections);
return this.writeChangelog(commits, sections);
}

function generateFromTag(tag) {
Expand Down
2 changes: 1 addition & 1 deletion tasks/lib/get-previous-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function getPreviousTag() {
debug('calling git tag command');
child.exec(module.cmd.gitTag, cmdDone.bind(null, resolve, reject));
}
})
});
}

module.exports = getPreviousTag;
2 changes: 1 addition & 1 deletion tasks/lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function init(params, loadRC) {

module.log('info', ' - The APP name is', module.options.app_name);
module.log('info', ' - The output file is', module.options.file);
module.log('template', ' - The template file is', module.options.template);
module.log('info', ' - The template file is', module.options.template);

module.options.grep_commits = module.options.sections.map(function(section) {
return section.grep;
Expand Down
29 changes: 16 additions & 13 deletions tasks/lib/load-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ function readTemplateFile(template, logger) {
debug('finding template file');

if(!template){
return q.reject();
return Promise.resolve(null);
}

var dfd = q.defer();

fs.readFile(template, 'utf8' ,function (err, data) {
if (err) {
logger('error', 'No template found', err);
dfd.reject(err);
dfd.resolve(null);
}else{
logger('info', 'Found template rc');
dfd.resolve(data);
Expand All @@ -35,26 +35,29 @@ function loadTemplateFile(data) {

var viewHelpers = {
getCommitLinks: function(commit){
return module.linkToCommit(commit.hash)
return module.linkToCommit(commit.hash);
},
getCommitCloses: function(commit){
return commit.closes.map(module.linkToIssue, module)
return commit.closes.map(module.linkToIssue, module);
}
}
};

_.extend(data, viewHelpers);

return readTemplateFile(this.options.template, this.log.bind(this))
.then(function(contents){
try{
var fn = _.template(contents, data);
var tpl = fn(data)
return tpl
}catch(e){
module.log('warn', 'Invalid template file', e);
throw 'Invalid template file \n' + e
if(contents){
try{
var fn = _.template(contents, data);
var tpl = fn(data);
return tpl;
}catch(e){
module.log('warn', 'Invalid template file', e);
throw 'Invalid template file \n' + e;
}
}else{
return null;
}

});
}

Expand Down
21 changes: 12 additions & 9 deletions tasks/lib/organize-commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function organizeCommit(sections, commit) {
section.commitsCount++;

if(component === this.emptyComponent){
section.commits.push(commit)
section.commits.push(commit);
}else{
section.components[component] = section.components[component] || [];
section.components[component].push(commit);
Expand All @@ -44,7 +44,7 @@ function organizeCommit(sections, commit) {
};

if(component === this.emptyComponent){
sections.BREAKING.commits.push(breakingCommit)
sections.BREAKING.commits.push(breakingCommit);
}else{
sections.BREAKING.components[component] = sections.BREAKING.components[component] || [];
sections.BREAKING.components[component].push(breakingCommit);
Expand All @@ -53,17 +53,19 @@ function organizeCommit(sections, commit) {
}

function organizeCommits(commits, defaultSections) {
commits = commits ? commits : [];

var sections = {
BREAKING : {
components: {},
commitsCount: 0,
title: 'Breaking Changes',
commits: [],
type: 'BREAKING'
type: 'BREAKING',
printCommitLinks: false
}
};


defaultSections.forEach(function(sectionInfo){
var sectionType = sectionInfo.grep.replace('^', '');

Expand All @@ -72,7 +74,8 @@ function organizeCommits(commits, defaultSections) {
components: {},
commits: [],
commitsCount: 0,
type: sectionType
type: sectionType,
printCommitLinks: sectionInfo.printCommitLinks === false ? false : true
};
});

Expand All @@ -81,16 +84,16 @@ function organizeCommits(commits, defaultSections) {
commits.forEach(organizeCommit.bind(this, sections), this);

return _.compact(Object.keys(sections).map(function(key){
var section = sections[key]
var section = sections[key];

section.components = Object.keys(section.components).sort().map(function(key){
return { name: key,
commits: section.components[key]
}
})
};
});

return section.commitsCount > 0 ? section : null;
}))
}));
}

module.exports = organizeCommits;
39 changes: 22 additions & 17 deletions tasks/lib/print-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,41 @@ function printCommit(stream, printCommitLinks, prefix, commit) {
}
}

function printComponent(stream, section, printCommitLinks, name) {
function printComponent(stream, printCommitLinks, component) {
var prefix = '-';
var nested = section[name].length > 1;

if (name !== this.emptyComponent) {
if (nested) {
stream.write(format('- **%s:**\n', name));
prefix = ' -';
} else {
prefix = format('- **%s:**', name);
}

var nested = component.commits.length > 1;
if (nested) {
stream.write(format('- **%s:**\n', component.name));
prefix = ' -';
} else {
prefix = format('- **%s:**', component.name);
}

section[name].forEach(printCommit.bind(this, stream, printCommitLinks, prefix), this);
component.commits.forEach(printCommit.bind(this, stream, printCommitLinks, prefix), this);
}

function printSection(stream, title, section, printCommitLinks) {
function printSection(stream, section) {
try{

debug('printing section ...');
printCommitLinks = printCommitLinks === undefined ? true : printCommitLinks;
var components = Object.keys(section.commits).sort();

if (!components.length) {
if (!section.commits.length && !section.components.length) {
return;
}

stream.write(format('\n## %s\n\n', title));

components.forEach(printComponent.bind(this, stream, section.commits, printCommitLinks), this);
stream.write(format('\n## %s\n\n', section.title));

section.commits.forEach(printCommit.bind(this, stream, section.printCommitLinks, '-'), this);

section.components.forEach(printComponent.bind(this, stream, section.printCommitLinks), this);

stream.write('\n');

}catch(e){
console.log(e);
}
}

module.exports = printSection;
Loading

0 comments on commit e980427

Please sign in to comment.