Skip to content

Commit

Permalink
Issue #286: Add "two dot" notation for "git log".
Browse files Browse the repository at this point in the history
Add unit test "with non-symmetric from and to" and modify the Readme.
  • Loading branch information
Guobacai committed May 7, 2019
1 parent ec7646d commit dc9251a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -61,7 +61,7 @@ when no error occurred) and secondly the data generated by that call.
| `.getRemotes([verbose], handlerFn)` | gets a list of the named remotes, when the verbose option is supplied as true, includes the URLs and purpose of each ref |
| `.init(bare, handlerFn)` | initialize a repository, optional `bare` parameter makes intialized repository bare |
| `.listRemote([args], handlerFn)` | lists remote repositories - there are so many optional arguments in the underlying `git ls-remote` call, just supply any you want to use as the optional `args` array of strings eg: `git.listRemote(['--heads', '--tags'], console.log.bind(console))` |
| `.log([options], handlerFn)` | list commits between `options.from` and `options.to` tags or branch (if not specified will show all history). Additionally you can provide `options.file`, which is the path to a file in your repository. Then only this file will be considered. For any other set of options, supply `options` as an array of strings to be appended to the `git log` command. To use a custom splitter in the log format, set `options.splitter` to be the string the log should be split on. Options can also be supplied as a standard [options](#how-to-specify-options) object for adding custom properties supported by the [git log](https://git-scm.com/docs/git-log) command. |
| `.log([options], handlerFn)` | list commits between `options.from` and `options.to` tags or branch (if not specified will show all history). Additionally you can provide `options.file`, which is the path to a file in your repository. Then only this file will be considered. `option.symmetrc` allows you to specify whether you want to use [symmetric revision range](https://git-scm.com/docs/gitrevisions#_dotted_range_notations) (To be compatible, by default, its value is true). For any other set of options, supply `options` as an array of strings to be appended to the `git log` command. To use a custom splitter in the log format, set `options.splitter` to be the string the log should be split on. Options can also be supplied as a standard [options](#how-to-specify-options) object for adding custom properties supported by the [git log](https://git-scm.com/docs/git-log) command. |
| `.mergeFromTo(from, to, [[options,] handlerFn])` | merge from one branch to another, when supplied the options should be an array of additional parameters to pass into the [git merge](https://git-scm.com/docs/git-merge) command |
| `.merge(options, handlerFn)` | runs a merge, `options` can be either an array of arguments supported by the [git merge](https://git-scm.com/docs/git-merge) command or an [options](#how-to-specify-options) object. Conflicts during the merge result in an error response, the response type whether it was an error or success will be a [MergeSummary](src/responses/MergeSummary.js) instance. When successful, the MergeSummary has all detail from a the [PullSummary](src/responses/PullSummary.js) |
| `.mirror(repoPath, localPath, handlerFn])` | clone and mirror the repo to local |
Expand Down
28 changes: 28 additions & 0 deletions test/unit/test-log.js
Expand Up @@ -74,6 +74,34 @@ exports.log = {
closeWith('');
},

'with explicit symmetric from and to' (test) {
git.log({
from: 'from',
to: 'to',
symmetric: true
}, function (err) {
test.equals(null, err, 'not an error');
test.same(["log", `--pretty=format:%H;%ai;%s;%D;%b;%aN;%ae${commitSplitter}`, "from...to"], theCommandRun());
test.done();
});

closeWith('');
},

'with non-symmetric from and to' (test) {
git.log({
from: 'from',
to: 'to',
symmetric: false
}, function (err) {
test.equals(null, err, 'not an error');
test.same(["log", `--pretty=format:%H;%ai;%s;%D;%b;%aN;%ae${commitSplitter}`, "from..to"], theCommandRun());
test.done();
});

closeWith('');
},

'with options array' (test) {
git.log(['--some=thing'], function (err, result) {
test.equals(null, err, 'not an error');
Expand Down

0 comments on commit dc9251a

Please sign in to comment.