Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript Unit Tests #533

Merged
merged 16 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update changelog and readme, adds timeline for deprecations being rem…
…oved to warning messages (ie: v3)
  • Loading branch information
steveukx committed Dec 5, 2020
commit c7a5f65abac2bac05d86e08e4e3a8d2d1a53ef9b
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@

# Change History & Release Notes

## 2.25.0 TypeScript Types & Unit Tests, Commit Parsing

- To help keep the TypeScript definitions in line with functionality, unit tests are now written in TypeScript.
- When using `git.commit`, the first argument must be a string or array of strings. Passing another data type has long
been considered an error, but now a deprecation warning will be shown in the log and will be switched to an error
in version 3.
- Fixes an issue in `git.commit` whereby a commit that included only deleted lines would be parsed as though the
deletions were inclusions.

## 2.24.0 Types updated

- `pull`, `push` and `pushTags` parameter types updated to match new functionality and tests switched to TypeScript to ensure they are kept in sync
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ For type details of the response for each of the tasks, please see the [TypeScri
| `.diffSummary(options, handlerFn)` | includes options in the call to `diff --stat options` and returns a [DiffSummary](src/lib/responses/DiffSummary.js) |
| `.env(name, value)` | Set environment variables to be passed to the spawned child processes, [see usage in detail below](#environment-variables). |
| `.exec(handlerFn)` | calls a simple function in the current step |
| `.fetch([options, ] handlerFn)` | update the local working copy database with changes from the default remote repo and branch, when supplied the options argument can be a standard [options object](#how-to-specify-options) either an array of string commands as supported by the [git fetch](https://git-scm.com/docs/git-fetch). On success, the returned data will be an instance of the [FetchSummary](src/responses/FetchSummary.js) |
| `.fetch([options, ] handlerFn)` | update the local working copy database with changes from the default remote repo and branch, when supplied the options argument can be a standard [options object](#how-to-specify-options) either an array of string commands as supported by the [git fetch](https://git-scm.com/docs/git-fetch). |
| `.fetch(remote, branch, handlerFn)` | update the local working copy database with changes from a remote repo |
| `.fetch(handlerFn)` | update the local working copy database with changes from the default remote repo and branch |
| `.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. `options.symmetric` 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. Set `options.multiLine` to true to include a multi-line body in the output format. 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. |
Expand Down
13 changes: 7 additions & 6 deletions src/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,18 @@ Git.prototype.add = function (files) {
*/
Git.prototype.commit = function (message, files, options, then) {
const next = trailingFunctionArgument(arguments);
const messages = [];

if (!filterStringOrStringArray(message)) {
return this._runTask(
configurationErrorTask(`git.commit requires the commit message to be supplied as a string/string[]`),
next
);
if (filterStringOrStringArray(message)) {
messages.push(...asArray(message));
}
else {
console.warn('simple-git deprecation notice: git.commit: requires the commit message to be supplied as a string/string[], this will be an error in version 3');
}

return this._runTask(
commitTask(
asArray(message),
messages,
asArray(filterType(files, filterStringOrStringArray, [])),
[...filterType(options, filterArray, []), ...getTrailingOptions(arguments, 0, true)]
),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/task-callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function taskCallback<R>(task: SimpleGitTask<R>, response: Promise<R>, ca

function addDeprecationNoticeToError (err: GitResponseError) {
let log = (name: string) => {
console.warn(`simple-git deprecation notice: accessing GitResponseError.${name} should be GitResponseError.git.${name}`);
console.warn(`simple-git deprecation notice: accessing GitResponseError.${name} should be GitResponseError.git.${name}, this will no longer be available in version 3`);
log = NOOP;
};

Expand Down