Skip to content

Commit 6f05402

Browse files
committed
chore(changelog): added changelog and script to generate it
1 parent c38aefd commit 6f05402

File tree

3 files changed

+253
-1
lines changed

3 files changed

+253
-1
lines changed

CHANGELOG.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# 0.0.37
2+
3+
Combined with previous release (0.0.36) injector is on average 2x faster.
4+
5+
```
6+
VM:
7+
DynamicInjectorBenchmark(RunTime): 231.93784065870346 us.
8+
StaticInjectorBenchmark(RunTime): 107.05491917353602 us.
9+
10+
dart2js:
11+
DynamicInjectorBenchmark(RunTime): 2175 us.
12+
StaticInjectorBenchmark(RunTime): 765.1109410864575 us.
13+
```
14+
15+
After:
16+
17+
VM:
18+
```
19+
DynamicInjectorBenchmark(RunTime): 156.3721657544957 us.
20+
StaticInjectorBenchmark(RunTime): 54.246114622040196 us.
21+
22+
dart2js:
23+
DynamicInjectorBenchmark(RunTime): 1454.5454545454545 us.
24+
StaticInjectorBenchmark(RunTime): 291.9281856663261 us.
25+
```
26+
27+
## Bug Fixes
28+
29+
- **warnings:** refactored injector to fix analyzer warnings
30+
([7d374b19](https://github.com/angular/di.dart/commit/7d374b196e795d9799c95a4e63cf497267604de9))
31+
32+
## Performance Improvements
33+
34+
- **injector:**
35+
- Make resolving a linked-list stored with the frame
36+
([c588e662](https://github.com/angular/di.dart/commit/c588e662ab0f33dc645c8e170492c0c25c1085a5))
37+
- Do not closurize methods.
38+
([5f47cbd0](https://github.com/angular/di.dart/commit/5f47cbd0dc28cb16e497baf5cfda3c6499f56eb5))
39+
- Do not check the circular dependency until we are 30 deep.
40+
([1dedf6e3](https://github.com/angular/di.dart/commit/1dedf6e38fec4c3fc882ef59b4c4bf439d19ce0a))
41+
- Track resolving keys with the frame.
42+
([17aeb4df](https://github.com/angular/di.dart/commit/17aeb4df59465c22cd73ae5c601cb8d0f872c57b))
43+
- **resolvedTypes:** minor performance inmprovement in resolvedTypes
44+
([ba16bde5](https://github.com/angular/di.dart/commit/ba16bde5084eb3a2291ca3d2fb38de06ac734b03))
45+
46+
47+
# 0.0.36
48+
49+
## Performance Improvements
50+
51+
- **injector:**
52+
- skip _checkKeyConditions in dart2js
53+
([6763552a](https://github.com/angular/di.dart/commit/6763552adccdc41ef1043930ea50e0425509e6c5))
54+
- +29%. Use an array for type lookup instead of a map.
55+

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"version": "0.0.0",
44
"description": "A prototype of Dependency Injection framework.",
55
"main": "index.js",
6-
"dependencies": {},
6+
"dependencies": {
7+
"qq": "*"
8+
},
79
"devDependencies": {
810
"grunt": "~0.4",
911
"grunt-contrib-watch": "~0.3"

scripts/changelog.js

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
#!/usr/bin/env node
2+
3+
// TODO(vojta): pre-commit hook for validating messages
4+
// TODO(vojta): report errors, currently Q silence everything which really sucks
5+
6+
var child = require('child_process');
7+
var fs = require('fs');
8+
var util = require('util');
9+
var q = require('qq');
10+
11+
var GIT_LOG_CMD = 'git log --grep="%s" -E --format=%s %s';
12+
var GIT_TAG_CMD = 'git describe --tags --abbrev=0';
13+
14+
var HEADER_TPL = '<a name="%s"></a>\n# %s (%s)\n\n';
15+
var LINK_ISSUE = '[#%s](https://github.com/angular/di.dart/issues/%s)';
16+
var LINK_COMMIT = '[%s](https://github.com/angular/di.dart/commit/%s)';
17+
18+
var EMPTY_COMPONENT = '$$';
19+
20+
21+
var warn = function() {
22+
console.log('WARNING:', util.format.apply(null, arguments));
23+
};
24+
25+
26+
var parseRawCommit = function(raw) {
27+
if (!raw) return null;
28+
29+
var lines = raw.split('\n');
30+
var msg = {}, match;
31+
32+
msg.hash = lines.shift();
33+
msg.subject = lines.shift();
34+
msg.closes = [];
35+
msg.breaks = [];
36+
37+
lines.forEach(function(line) {
38+
match = line.match(/(?:Closes|Fixes)\s#(\d+)/);
39+
if (match) msg.closes.push(parseInt(match[1]));
40+
});
41+
42+
match = raw.match(/BREAKING CHANGE:([\s\S]*)/);
43+
if (match) {
44+
msg.breaking = match[1];
45+
}
46+
47+
48+
msg.body = lines.join('\n');
49+
match = msg.subject.match(/^(.*)\((.*)\)\:\s(.*)$/);
50+
51+
if (!match || !match[1] || !match[3]) {
52+
warn('Incorrect message: %s %s', msg.hash, msg.subject);
53+
return null;
54+
}
55+
56+
msg.type = match[1];
57+
msg.component = match[2];
58+
msg.subject = match[3];
59+
60+
return msg;
61+
};
62+
63+
64+
var linkToIssue = function(issue) {
65+
return util.format(LINK_ISSUE, issue, issue);
66+
};
67+
68+
69+
var linkToCommit = function(hash) {
70+
return util.format(LINK_COMMIT, hash.substr(0, 8), hash);
71+
};
72+
73+
74+
var currentDate = function() {
75+
var now = new Date();
76+
var pad = function(i) {
77+
return ('0' + i).substr(-2);
78+
};
79+
80+
return util.format('%d-%s-%s', now.getFullYear(), pad(now.getMonth() + 1), pad(now.getDate()));
81+
};
82+
83+
84+
var printSection = function(stream, title, section, printCommitLinks) {
85+
printCommitLinks = printCommitLinks === undefined ? true : printCommitLinks;
86+
var components = Object.getOwnPropertyNames(section).sort();
87+
88+
if (!components.length) return;
89+
90+
stream.write(util.format('\n## %s\n\n', title));
91+
92+
components.forEach(function(name) {
93+
var prefix = '-';
94+
var nested = section[name].length > 1;
95+
96+
if (name !== EMPTY_COMPONENT) {
97+
if (nested) {
98+
stream.write(util.format('- **%s:**\n', name));
99+
prefix = ' -';
100+
} else {
101+
prefix = util.format('- **%s:**', name);
102+
}
103+
}
104+
105+
section[name].forEach(function(commit) {
106+
if (printCommitLinks) {
107+
stream.write(util.format('%s %s\n (%s', prefix, commit.subject, linkToCommit(commit.hash)));
108+
if (commit.closes.length) {
109+
stream.write(',\n ' + commit.closes.map(linkToIssue).join(', '));
110+
}
111+
stream.write(')\n');
112+
} else {
113+
stream.write(util.format('%s %s', prefix, commit.subject));
114+
}
115+
});
116+
});
117+
118+
stream.write('\n');
119+
};
120+
121+
122+
var readGitLog = function(grep, from) {
123+
var deferred = q.defer();
124+
125+
// TODO(vojta): if it's slow, use spawn and stream it instead
126+
console.log(util.format(GIT_LOG_CMD, grep, '%H%n%s%n%b%n==END==', from));
127+
child.exec(util.format(GIT_LOG_CMD, grep, '%H%n%s%n%b%n==END==', from), function(code, stdout, stderr) {
128+
var commits = [];
129+
130+
stdout.split('\n==END==\n').forEach(function(rawCommit) {
131+
var commit = parseRawCommit(rawCommit);
132+
if (commit) commits.push(commit);
133+
});
134+
135+
deferred.resolve(commits);
136+
});
137+
138+
return deferred.promise;
139+
};
140+
141+
142+
var writeChangelog = function(stream, commits, version) {
143+
var sections = {
144+
fix: {},
145+
feat: {},
146+
perf: {},
147+
breaks: {}
148+
};
149+
150+
sections.breaks[EMPTY_COMPONENT] = [];
151+
152+
commits.forEach(function(commit) {
153+
var section = sections[commit.type];
154+
var component = commit.component || EMPTY_COMPONENT;
155+
156+
if (section) {
157+
section[component] = section[component] || [];
158+
section[component].push(commit);
159+
}
160+
161+
if (commit.breaking) {
162+
sections.breaks[component] = sections.breaks[component] || [];
163+
sections.breaks[component].push({
164+
subject: util.format("due to %s,\n %s", linkToCommit(commit.hash), commit.breaking),
165+
hash: commit.hash,
166+
closes: []
167+
});
168+
};
169+
});
170+
171+
stream.write(util.format(HEADER_TPL, version, version, currentDate()));
172+
printSection(stream, 'Bug Fixes', sections.fix);
173+
printSection(stream, 'Features', sections.feat);
174+
printSection(stream, 'Performance Improvements', sections.perf);
175+
printSection(stream, 'Breaking Changes', sections.breaks, false);
176+
}
177+
178+
179+
var generate = function(tagRange, file) {
180+
console.log('Reading git log for', tagRange);
181+
readGitLog('^fix|^feat|^perf|BREAKING', tagRange).then(function(commits) {
182+
console.log('Parsed', commits.length, 'commits');
183+
console.log('Generating changelog to', file || 'stdout', '(', tagRange, ')');
184+
writeChangelog(file ? fs.createWriteStream(file) : process.stdout, commits, tagRange);
185+
});
186+
};
187+
188+
189+
// publish for testing
190+
exports.parseRawCommit = parseRawCommit;
191+
192+
// hacky start if not run by jasmine :-D
193+
if (process.argv.join('').indexOf('jasmine-node') === -1) {
194+
generate(process.argv[2], process.argv[3]);
195+
}

0 commit comments

Comments
 (0)