Skip to content
This repository was archived by the owner on Dec 6, 2017. It is now read-only.

Commit

Permalink
chore(changelog): added changelog and script to generate it
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelgj committed Apr 16, 2014
1 parent c38aefd commit 6f05402
Show file tree
Hide file tree
Showing 3 changed files with 253 additions and 1 deletion.
55 changes: 55 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 0.0.37

Combined with previous release (0.0.36) injector is on average 2x faster.

```
VM:
DynamicInjectorBenchmark(RunTime): 231.93784065870346 us.
StaticInjectorBenchmark(RunTime): 107.05491917353602 us.
dart2js:
DynamicInjectorBenchmark(RunTime): 2175 us.
StaticInjectorBenchmark(RunTime): 765.1109410864575 us.
```

After:

VM:
```
DynamicInjectorBenchmark(RunTime): 156.3721657544957 us.
StaticInjectorBenchmark(RunTime): 54.246114622040196 us.
dart2js:
DynamicInjectorBenchmark(RunTime): 1454.5454545454545 us.
StaticInjectorBenchmark(RunTime): 291.9281856663261 us.
```

## Bug Fixes

- **warnings:** refactored injector to fix analyzer warnings
([7d374b19](https://github.com/angular/di.dart/commit/7d374b196e795d9799c95a4e63cf497267604de9))

## Performance Improvements

- **injector:**
- Make resolving a linked-list stored with the frame
([c588e662](https://github.com/angular/di.dart/commit/c588e662ab0f33dc645c8e170492c0c25c1085a5))
- Do not closurize methods.
([5f47cbd0](https://github.com/angular/di.dart/commit/5f47cbd0dc28cb16e497baf5cfda3c6499f56eb5))
- Do not check the circular dependency until we are 30 deep.
([1dedf6e3](https://github.com/angular/di.dart/commit/1dedf6e38fec4c3fc882ef59b4c4bf439d19ce0a))
- Track resolving keys with the frame.
([17aeb4df](https://github.com/angular/di.dart/commit/17aeb4df59465c22cd73ae5c601cb8d0f872c57b))
- **resolvedTypes:** minor performance inmprovement in resolvedTypes
([ba16bde5](https://github.com/angular/di.dart/commit/ba16bde5084eb3a2291ca3d2fb38de06ac734b03))


# 0.0.36

## Performance Improvements

- **injector:**
- skip _checkKeyConditions in dart2js
([6763552a](https://github.com/angular/di.dart/commit/6763552adccdc41ef1043930ea50e0425509e6c5))
- +29%. Use an array for type lookup instead of a map.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.0.0",
"description": "A prototype of Dependency Injection framework.",
"main": "index.js",
"dependencies": {},
"dependencies": {
"qq": "*"
},
"devDependencies": {
"grunt": "~0.4",
"grunt-contrib-watch": "~0.3"
Expand Down
195 changes: 195 additions & 0 deletions scripts/changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
#!/usr/bin/env node

// TODO(vojta): pre-commit hook for validating messages
// TODO(vojta): report errors, currently Q silence everything which really sucks

var child = require('child_process');
var fs = require('fs');
var util = require('util');
var q = require('qq');

var GIT_LOG_CMD = 'git log --grep="%s" -E --format=%s %s';
var GIT_TAG_CMD = 'git describe --tags --abbrev=0';

var HEADER_TPL = '<a name="%s"></a>\n# %s (%s)\n\n';
var LINK_ISSUE = '[#%s](https://github.com/angular/di.dart/issues/%s)';
var LINK_COMMIT = '[%s](https://github.com/angular/di.dart/commit/%s)';

var EMPTY_COMPONENT = '$$';


var warn = function() {
console.log('WARNING:', util.format.apply(null, arguments));
};


var parseRawCommit = function(raw) {
if (!raw) return null;

var lines = raw.split('\n');
var msg = {}, match;

msg.hash = lines.shift();
msg.subject = lines.shift();
msg.closes = [];
msg.breaks = [];

lines.forEach(function(line) {
match = line.match(/(?:Closes|Fixes)\s#(\d+)/);
if (match) msg.closes.push(parseInt(match[1]));
});

match = raw.match(/BREAKING CHANGE:([\s\S]*)/);
if (match) {
msg.breaking = match[1];
}


msg.body = lines.join('\n');
match = msg.subject.match(/^(.*)\((.*)\)\:\s(.*)$/);

if (!match || !match[1] || !match[3]) {
warn('Incorrect message: %s %s', msg.hash, msg.subject);
return null;
}

msg.type = match[1];
msg.component = match[2];
msg.subject = match[3];

return msg;
};


var linkToIssue = function(issue) {
return util.format(LINK_ISSUE, issue, issue);
};


var linkToCommit = function(hash) {
return util.format(LINK_COMMIT, hash.substr(0, 8), hash);
};


var currentDate = function() {
var now = new Date();
var pad = function(i) {
return ('0' + i).substr(-2);
};

return util.format('%d-%s-%s', now.getFullYear(), pad(now.getMonth() + 1), pad(now.getDate()));
};


var printSection = function(stream, title, section, printCommitLinks) {
printCommitLinks = printCommitLinks === undefined ? true : printCommitLinks;
var components = Object.getOwnPropertyNames(section).sort();

if (!components.length) return;

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

components.forEach(function(name) {
var prefix = '-';
var nested = section[name].length > 1;

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

section[name].forEach(function(commit) {
if (printCommitLinks) {
stream.write(util.format('%s %s\n (%s', prefix, commit.subject, linkToCommit(commit.hash)));
if (commit.closes.length) {
stream.write(',\n ' + commit.closes.map(linkToIssue).join(', '));
}
stream.write(')\n');
} else {
stream.write(util.format('%s %s', prefix, commit.subject));
}
});
});

stream.write('\n');
};


var readGitLog = function(grep, from) {
var deferred = q.defer();

// TODO(vojta): if it's slow, use spawn and stream it instead
console.log(util.format(GIT_LOG_CMD, grep, '%H%n%s%n%b%n==END==', from));
child.exec(util.format(GIT_LOG_CMD, grep, '%H%n%s%n%b%n==END==', from), function(code, stdout, stderr) {
var commits = [];

stdout.split('\n==END==\n').forEach(function(rawCommit) {
var commit = parseRawCommit(rawCommit);
if (commit) commits.push(commit);
});

deferred.resolve(commits);
});

return deferred.promise;
};


var writeChangelog = function(stream, commits, version) {
var sections = {
fix: {},
feat: {},
perf: {},
breaks: {}
};

sections.breaks[EMPTY_COMPONENT] = [];

commits.forEach(function(commit) {
var section = sections[commit.type];
var component = commit.component || EMPTY_COMPONENT;

if (section) {
section[component] = section[component] || [];
section[component].push(commit);
}

if (commit.breaking) {
sections.breaks[component] = sections.breaks[component] || [];
sections.breaks[component].push({
subject: util.format("due to %s,\n %s", linkToCommit(commit.hash), commit.breaking),
hash: commit.hash,
closes: []
});
};
});

stream.write(util.format(HEADER_TPL, version, version, currentDate()));
printSection(stream, 'Bug Fixes', sections.fix);
printSection(stream, 'Features', sections.feat);
printSection(stream, 'Performance Improvements', sections.perf);
printSection(stream, 'Breaking Changes', sections.breaks, false);
}


var generate = function(tagRange, file) {
console.log('Reading git log for', tagRange);
readGitLog('^fix|^feat|^perf|BREAKING', tagRange).then(function(commits) {
console.log('Parsed', commits.length, 'commits');
console.log('Generating changelog to', file || 'stdout', '(', tagRange, ')');
writeChangelog(file ? fs.createWriteStream(file) : process.stdout, commits, tagRange);
});
};


// publish for testing
exports.parseRawCommit = parseRawCommit;

// hacky start if not run by jasmine :-D
if (process.argv.join('').indexOf('jasmine-node') === -1) {
generate(process.argv[2], process.argv[3]);
}

0 comments on commit 6f05402

Please sign in to comment.