From 7311dfd34b92a2d4e3a090c6da471a1fcc4ecfb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 27 Mar 2014 08:47:09 -0400 Subject: [PATCH] Changelog: Upgrade to changelogplease 1.1.0 This upgrade keeps commits in chronological order within components. Ref gh-28 --- node_modules/changelogplease/README.md | 10 +++++- node_modules/changelogplease/index.js | 34 +++++++++++++++---- .../node_modules/git-tools/package.json | 6 +++- node_modules/changelogplease/package.json | 12 +++---- package.json | 2 +- 5 files changed, 49 insertions(+), 15 deletions(-) diff --git a/node_modules/changelogplease/README.md b/node_modules/changelogplease/README.md index b69685b..e00a038 100644 --- a/node_modules/changelogplease/README.md +++ b/node_modules/changelogplease/README.md @@ -14,11 +14,18 @@ npm install changelogplease ```javascript var changelog = require( "changelogplease" ); -var parsed = changelog({ +changelog({ ticketUrl: "https://github.com/scottgonzalez/changelogplease/issues/{id}", commitUrl: "https://github.com/scottgonzalez/changelogplease/commit/{id}", repo: "/path/to/repo", committish: "1.2.3..1.2.4" +}, function( error, log ) { + if ( error ) { + console.log( error ); + return; + } + + console.log( log ); }); ``` @@ -31,6 +38,7 @@ var parsed = changelog({ * `commitUrl (String)`: Template for commit URLs; `{id}` will be replaced with the commit hash. * `repo` (String): Path to the repository. * `committish` (String): The range of commits for the changelog. + * `sort` (Boolean, Function): Function for sorting commits. By default commits are sorted alphabetically so they are grouped by component. A value of `false` disables sorting. * `callback` (Function; `function( error, log )`): Function to invoke after generating the changelog. * `log` (String): Generated changelog, written in markdown. diff --git a/node_modules/changelogplease/index.js b/node_modules/changelogplease/index.js index 1cbf0b3..682e311 100644 --- a/node_modules/changelogplease/index.js +++ b/node_modules/changelogplease/index.js @@ -51,18 +51,40 @@ Changelog.prototype.getLog = function( callback ) { callback ); }; +Changelog.prototype.sort = function( commits ) { + if ( this.options.sort === false ) { + return commits; + } + + if ( typeof this.options.sort === "function" ) { + return this.options.sort( commits ); + } + + // Sort commits so that they're grouped by component + var component = /^(.+):/; + return commits.sort(function( a, b ) { + var aMatch = a.match( component ), + bMatch = b.match( component ); + + if ( aMatch && bMatch) { + return aMatch[ 1 ].localeCompare( bMatch[ 1 ] ); + } + + return a.localeCompare( b ); + }); +}; + Changelog.prototype.parseCommits = function( commits ) { commits = commits.split( "__COMMIT__\n" ); commits.shift(); - return commits + // Parse each individual commit + commits = commits.map( this.parseCommit ); - // Parse each individual commit - .map( this.parseCommit ) + // Sort commits + commits = this.sort( commits ); - // Sort commits so that they're grouped by component - .sort() - .join( "\n" ) + "\n"; + return commits.join( "\n" ) + "\n"; }; Changelog.prototype.parseCommit = function( commit ) { diff --git a/node_modules/changelogplease/node_modules/git-tools/package.json b/node_modules/changelogplease/node_modules/git-tools/package.json index a24419f..8fb790b 100644 --- a/node_modules/changelogplease/node_modules/git-tools/package.json +++ b/node_modules/changelogplease/node_modules/git-tools/package.json @@ -28,5 +28,9 @@ "readme": "# node-git-tools\n\nTools for parsing data out of git repositories.\n\nSupport this project by [donating on Gittip](https://www.gittip.com/scottgonzalez/).\n\n## About\n\nThe goal of node-git-tools is to provide a set of tools that can be used to\neasily write custom git commands or other scripts that are tightly integrated\nwith git.\n\nI expect the API to grow over time and will happily entertain any feature\nrequests. If there is anything you'd like added, just file an issue.\n\n## Installation\n\n```sh\nnpm install git-tools\n```\n\n## Usage\n\n```js\nvar Repo = require( \"git-tools\" );\nvar repo = new Repo( \"path/to/repo\" );\nrepo.authors(function( error, authors ) {\n\tconsole.log( authors );\n});\n```\n\n\n\n## API\n\n### Repo.clone( options, callback )\n\nClones a repository and returns the new `Repo` instance.\n\n* `options` (Object): Options for cloning the repository.\n * `repo` (String): The repository to clone from.\n * `path` (String): The path to clone into.\n * extra: Additional options can be provided, as documented below.\n* `callback` (Function; `function( error, repo )`): Function to invoke after cloning the repository.\n * `repo` (Object): A new `Repo` instance for the cloned repository.\n\nThis function accepts arbitrary options to pass to `git clone`.\nFor example, to create a bare repository:\n\n```js\nRepo.clone({\n\trepo: \"git://github.com/scottgonzalez/node-git-tools.git\",\n\tdir: \"/tmp/git-tools\",\n\tbare: true\n});\n```\n\nOr to create a repo with limited history:\n\n```js\nRepo.clone({\n\trepo: \"git://github.com/scottgonzalez/node-git-tools.git\",\n\tdir: \"/tmp/git-tools\",\n\tdepth: 5\n});\n```\n\n\n\n### Repo.isRepo( path, callback )\n\nDetermines if the specified path is a git repository.\n\n* `path` (String): The path to check.\n* `callback` (Function; `function( error, isRepo )`): Function to invoke after determining if the path is a git repository.\n * `isRepo` (Boolean): Whether the path is a git repository.\n\n*Note: This is equivalent to creating a `Repo` instance with `path` and calling `isRepo()` on the instance.*\n\n\n\n### activeDays( [committish], callback )\n\nGets the number of active days (unique days of authorship). Includes activity\nby day, month, year, and the entire history.\n\n* `committish` (String; default: `\"master\"`): Committish range to analyze.\n* `callback` (Function; `function( error, activeDays )`): Function to invoke after getting active days.\n * `activeDays` (Object): Summary of active days.\n\nThe `activeDays` object has the following form:\n\n```js\n{\n\tactiveDays: Number,\n\tcommits: Number,\n\tdates: {\n\t\t\"YYYY-MM-DD\": Number( commits ),\n\t\t...\n\t},\n\tyears: {\n\t\t\"YYYY\": {\n\t\t\tactiveDays: Number,\n\t\t\tcommits: Number,\n\t\t\tmonths: {\n\t\t\t\t\"M\": {\n\t\t\t\t\tactiveDays: Number,\n\t\t\t\t\tcommits: Number,\n\t\t\t\t\tdays: {\n\t\t\t\t\t\t\"D\": {\n\t\t\t\t\t\t\tcommits: Number\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t...\n\t\t\t}\n\t\t},\n\t\t...\n\t}\n}\n```\n\n\n\n### age( callback )\n\nGets the age of the repository.\n\n* `callback` (Function; `function( error, age )`): Function to invoke after getting the age.\n * `age` (String): The age of the repository.\n\n\n\n### authors( [committish], callback )\n\nGets all authors, sorted by number of commits.\n\n* `committish` (String; default: `\"master\"`): Committish range to analyze.\n* `callback` (Function; `function( error, authors )`): Function to invoke after getting authors.\n * `authors` (Array): All authors, sorted by number of commits.\n\nEach author object contains the following properties:\n\n* `email` (String): Author's email address.\n* `name` (String): Author's name.\n* `commits` (Number): Number of commits.\n* `commitsPercent` (Number): Percentage of commits.\n\n\n\n### blame( options, callback )\n\nDetermine what revision and author last modified each line of a file.\n\n* `options` (Object): Options for the blame.\n * `path` (String): The path to the file to run the blame for.\n * `committish` (String; default: `\"HEAD\"`): Revision or range to blame against.\n* `callback` (Function; `function( error, blame )`): Function to invoke after blaming the file.\n * `blame` (Array): Commit information for each line.\n\nEach blame item contains the following properties:\n\n* `commit`: SHA of commit that most recently modified the line.\n* `path`: Path to the file at the time of the most recent modification to the line.\n* `lineNumber`: Line number within the file.\n* `content`: Contents of the line.\n\n\n\n### branches( callback )\n\nGets all branches in order of most recent commit.\n\n* `callback` (Function; `function( error, branches )`): Function to invoke after getting branches.\n * `branches` (Array): All branches, sorted by most recent commit date.\n\nEach branch object contains the following properties:\n\n* `name` (String): Branch name.\n* `sha` (String): SHA-1 of most recent commit.\n* `date` (Date): Author date of most recent commit.\n* `subject` (String): Subject (first line) of most recent commit.\n* `author` (Object): Author of most recent commit.\n * `email` (String): Author's email address.\n * `name` (String): Author's name.\n\n\n\n### config( name, callback )\n\nGets the value of a configuration option.\n\n* `name` (String): The name of the configuration option.\n* `callback` (Function; `function( error, value )`): Function to invoke after getting the configuration option.\n * `value` (String|null): The value for the configuration option, or `null` if no value is set.\n\n\n\n### currentBranch( callback )\n\nGets the name of the currently checked out branch, if any.\n\n* `callback` (Function; `function( error, branch )`): Function to invoke after getting the branch.\n * `branch` (String|null): Branch name, or `null` if in detached HEAD state.\n\n\n\n### isRepo( callback )\n\nDetermines if the specified path is a git repository.\n\n* `callback` (Function; `function( error, isRepo )`): Function to invoke after determining if the path is a git repository.\n * `isRepo` (Boolean): Whether the path is a git repository.\n\n\n\n### remotes( callback )\n\nGets all remote repositories.\n\n* `callback` (Function; `function( error, remotes )`): Function to invoke after getting the remotes.\n * `remotes` (Array): All remote repositories.\n\nEach remote object contains the following properties:\n\n* `name` (String): Remote name.\n* `url` (String): URL for the remote repository.\n\n\n\n### resolveCommittish( committish, callback )\n\nResolves a committish to a SHA1.\n\n* `committish` (String): Any committish to resolve.\n* `callback` (Function; `function( error, sha )`): Function to invoke after resolving the comittish.\n * `sha`: SHA1 of the resolved committish.\n\n\n\n### tags( callback )\n\nGets all tags in reverse chronological order.\n\nLightweight tags are sorted by author date and annotated tags are sorted by tagger date.\n\n* `callback` (Function; `function( error, tags )`): Function to invoke after getting tags.\n * `tags` (Array): All tags, sorted by date.\n\nEach tag object contains the following properties:\n\n* `name` (String): Tag name.\n* `sha` (String): SHA-1 for the tag. For lightweight tags, this is the SHA-1 of the commit.\n* `date` (Date): Author date for ligthweight tags, tagger date for annotated tags.\n\n\n\n## License\n\nCopyright 2013 Scott González. Released under the terms of the MIT license.\n\n---\n\nSupport this project by [donating on Gittip](https://www.gittip.com/scottgonzalez/).\n", "readmeFilename": "README.md", "_id": "git-tools@0.1.0", - "_from": "git-tools@0.1.0" + "dist": { + "shasum": "42709aabce667e87ee789f8167dbe0191db9a10b" + }, + "_from": "git-tools@0.1.0", + "_resolved": "https://registry.npmjs.org/git-tools/-/git-tools-0.1.0.tgz" } diff --git a/node_modules/changelogplease/package.json b/node_modules/changelogplease/package.json index cd018ba..14cb444 100644 --- a/node_modules/changelogplease/package.json +++ b/node_modules/changelogplease/package.json @@ -1,6 +1,6 @@ { "name": "changelogplease", - "version": "1.0.1", + "version": "1.1.0", "description": "Generate changelogs from git commit messages", "author": { "name": "Scott González", @@ -30,12 +30,12 @@ "devDependencies": { "nodeunit": "0.8.6" }, - "readme": "# Changelog, please\n\nGenerate changelogs from git commit messages using node.js. The generated changelogs are written in markdown.\n\nSupport this project by [donating on Gittip](https://www.gittip.com/scottgonzalez/).\n\n## Installation\n\n```\nnpm install changelogplease\n```\n\n## Usage\n\n```javascript\nvar changelog = require( \"changelogplease\" );\nvar parsed = changelog({\n\tticketUrl: \"https://github.com/scottgonzalez/changelogplease/issues/{id}\",\n\tcommitUrl: \"https://github.com/scottgonzalez/changelogplease/commit/{id}\",\n\trepo: \"/path/to/repo\",\n\tcommittish: \"1.2.3..1.2.4\"\n});\n```\n\n## API\n\n### changelog( options, callback )\n\n* `options` (Object): Options for creating the changelog.\n * `ticketUrl` (String): Template for ticket/issue URLs; `{id}` will be replaced with the ticket id.\n * `commitUrl (String)`: Template for commit URLs; `{id}` will be replaced with the commit hash.\n * `repo` (String): Path to the repository.\n * `committish` (String): The range of commits for the changelog.\n* `callback` (Function; `function( error, log )`): Function to invoke after generating the changelog.\n * `log` (String): Generated changelog, written in markdown.\n\n### Changelog\n\n`changelog( options, callback )` is a shorthand for the following:\n\n```js\nvar Changelog = require( \"changelogplease\" ).Changelog;\nvar instance = new Changelog( options );\ninstance.parse( callback );\n```\n\nChangelog generation is tailored to a specific format based on the needs of the various jQuery\nprojects. However, the `Changelog` constructor and prototype are exposed to allow flexibility.\nBe aware that these methods are not currently documented because they may change. Feel free to\nsubmit [feature requests](https://github.com/scottgonzalez/changelogplease/issues/new) if you don't\nfeel comfortable hacking in your own changes (or even if you do).\n\n\n## License\n\nCopyright 2014 Scott González. Released under the terms of the MIT license.\n\n---\n\nSupport this project by [donating on Gittip](https://www.gittip.com/scottgonzalez/).\n", + "readme": "# Changelog, please\n\nGenerate changelogs from git commit messages using node.js. The generated changelogs are written in markdown.\n\nSupport this project by [donating on Gittip](https://www.gittip.com/scottgonzalez/).\n\n## Installation\n\n```\nnpm install changelogplease\n```\n\n## Usage\n\n```javascript\nvar changelog = require( \"changelogplease\" );\nchangelog({\n\tticketUrl: \"https://github.com/scottgonzalez/changelogplease/issues/{id}\",\n\tcommitUrl: \"https://github.com/scottgonzalez/changelogplease/commit/{id}\",\n\trepo: \"/path/to/repo\",\n\tcommittish: \"1.2.3..1.2.4\"\n}, function( error, log ) {\n\tif ( error ) {\n\t\tconsole.log( error );\n\t\treturn;\n\t}\n\n\tconsole.log( log );\n});\n```\n\n## API\n\n### changelog( options, callback )\n\n* `options` (Object): Options for creating the changelog.\n * `ticketUrl` (String): Template for ticket/issue URLs; `{id}` will be replaced with the ticket id.\n * `commitUrl (String)`: Template for commit URLs; `{id}` will be replaced with the commit hash.\n * `repo` (String): Path to the repository.\n * `committish` (String): The range of commits for the changelog.\n * `sort` (Boolean, Function): Function for sorting commits. By default commits are sorted alphabetically so they are grouped by component. A value of `false` disables sorting.\n* `callback` (Function; `function( error, log )`): Function to invoke after generating the changelog.\n * `log` (String): Generated changelog, written in markdown.\n\n### Changelog\n\n`changelog( options, callback )` is a shorthand for the following:\n\n```js\nvar Changelog = require( \"changelogplease\" ).Changelog;\nvar instance = new Changelog( options );\ninstance.parse( callback );\n```\n\nChangelog generation is tailored to a specific format based on the needs of the various jQuery\nprojects. However, the `Changelog` constructor and prototype are exposed to allow flexibility.\nBe aware that these methods are not currently documented because they may change. Feel free to\nsubmit [feature requests](https://github.com/scottgonzalez/changelogplease/issues/new) if you don't\nfeel comfortable hacking in your own changes (or even if you do).\n\n\n## License\n\nCopyright 2014 Scott González. Released under the terms of the MIT license.\n\n---\n\nSupport this project by [donating on Gittip](https://www.gittip.com/scottgonzalez/).\n", "readmeFilename": "README.md", - "_id": "changelogplease@1.0.1", + "_id": "changelogplease@1.1.0", "dist": { - "shasum": "2953e41245f475cd0a3d66b2861e3344166d6c30" + "shasum": "693070250b6ddc93fd87e1634db058e769e4b7d0" }, - "_from": "changelogplease@1.0.1", - "_resolved": "https://registry.npmjs.org/changelogplease/-/changelogplease-1.0.1.tgz" + "_from": "changelogplease@1.1.0", + "_resolved": "https://registry.npmjs.org/changelogplease/-/changelogplease-1.1.0.tgz" } diff --git a/package.json b/package.json index 000ec82..016c943 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "changelogplease": "1.0.1", + "changelogplease": "1.1.0", "colors": "0.6.2", "semver": "2.2.1", "shelljs": "0.2.6",