Skip to content

Commit

Permalink
fix: Add codespell: workflow, config and fix typos it finds (#1843)
Browse files Browse the repository at this point in the history
* Add github action to codespell main on push and PRs
* Add rudimentary codespell config
* Ignore some common short words
* [DATALAD RUNCMD] Do interactive fixing of some ambigous typos
* Manually committing selected fixed by codespell to those files in the tests
* Skip __tests__
* [DATALAD RUNCMD] run codespell throughout fixing typo automagically
* docs: add @yarikoptic as a contributor
  • Loading branch information
yarikoptic committed Feb 16, 2024
1 parent 45bc531 commit 6170171
Show file tree
Hide file tree
Showing 28 changed files with 77 additions and 40 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Expand Up @@ -660,6 +660,15 @@
"contributions": [
"code"
]
},
{
"login": "yarikoptic",
"name": "Yaroslav Halchenko",
"avatar_url": "https://avatars.githubusercontent.com/u/39889?v=4",
"profile": "https://github.com/yarikoptic",
"contributions": [
"doc"
]
}
],
"commitConvention": "angular"
Expand Down
5 changes: 5 additions & 0 deletions .codespellrc
@@ -0,0 +1,5 @@
[codespell]
skip = .git,*.pdf,*.svg,package-lock.json,*.css,*.min.*,.codespellrc,__fixtures__,__tests__
check-hidden = true
# ignore-regex =
ignore-words-list = ot,fo
22 changes: 22 additions & 0 deletions .github/workflows/codespell.yml
@@ -0,0 +1,22 @@
---
name: Codespell

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Codespell
uses: codespell-project/actions-codespell@v2
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -83,7 +83,7 @@ parse[*]Request: (input: stream) -> Object
write[*]Response: (input: Object) -> stream

### How git works
If you want to contribute it may be usefull if you understand how git works under the hood.
If you want to contribute it may be useful if you understand how git works under the hood.
This is great article that shows the details:<br/>
[A Hacker's Guide to Git](https://wildlyinaccurate.com/a-hackers-guide-to-git/).<br/>
But as first the introduction you can watch this video:<br/>
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -367,6 +367,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
<td align="center"><a href="https://github.com/DanilKazanov"><img src="https://avatars.githubusercontent.com/u/139755256?v=4?s=60" width="60px;" alt=""/><br /><sub><b>DanilKazanov</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=DanilKazanov" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=DanilKazanov" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=DanilKazanov" title="Tests">⚠️</a></td>
<td align="center"><a href="https://api.github.com/users/hisco"><img src="https://avatars.githubusercontent.com/u/39222286?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Eyal Hisco</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Ahisco" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/scolladon"><img src="https://avatars.githubusercontent.com/u/522422?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Sebastien</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=scolladon" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/yarikoptic"><img src="https://avatars.githubusercontent.com/u/39889?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Yaroslav Halchenko</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=yarikoptic" title="Documentation">📖</a></td>
</tr>
</table>

Expand Down
2 changes: 1 addition & 1 deletion __tests__/test-abortMerge.js
Expand Up @@ -154,7 +154,7 @@ describe('abortMerge', () => {

expect(await modified(index, head)).toBe(false)

// only since we didnt touch anything
// only since we didn't touch anything
expect(await modified(workdir, head)).toBe(false)

expect(await modified(index, workdir)).toBe(false)
Expand Down
8 changes: 4 additions & 4 deletions __tests__/test-hosting-providers.js
Expand Up @@ -20,7 +20,7 @@ describe('Hosting Providers', () => {
// These HTTPS Git credentials for AWS CodeCommit are for IAM user arn:aws:iam::260687965765:user/tester
// which only has git access to the test repo:
// https://git-codecommit.us-west-2.amazonaws.com/v1/repos/test.empty
// It is stored reversed because the GitHub one is stored reversed and I like being consistant.
// It is stored reversed because the GitHub one is stored reversed and I like being consistent.
const password = reverse('=cYfZKeyeW3ig0yZrkzkd9ElDKYctLgV2WNOZ1Ctntnt')
const username = 'tester-at-260687965765'
it('fetch', async () => {
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('Hosting Providers', () => {

describe('Azure DevOps', () => {
// These git credentials are specific to https://isomorphic-git@dev.azure.com/isomorphic-git/isomorphic-git/_git/test.empty
// It is stored reversed because the GitHub one is stored reversed and I like being consistant.
// It is stored reversed because the GitHub one is stored reversed and I like being consistent.
const password = reverse('ez8dMKyRfWpzMkhg3QJb5m')
const username = 'isomorphicgittestpush'
it('fetch', async () => {
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('Hosting Providers', () => {
// This App Password is for the test account 'isomorphic-git' user on Bitbucket,
// with "repositories.read" and "repositories.write" access. However the only repo the account has access to is
// https://bitbucket.org/isomorphic-git/test.empty
// It is stored reversed because the GitHub one is stored reversed and I like being consistant.
// It is stored reversed because the GitHub one is stored reversed and I like being consistent.
const password = reverse('TqSWhF3xLxEEXKQtZTwn')
const username = 'isomorphic-git'
it('push', async () => {
Expand Down Expand Up @@ -194,7 +194,7 @@ describe('Hosting Providers', () => {
// This Personal Access Token is for a test account (https://gitlab.com/isomorphic-git-test-push)
// with "read_repository" and "write_repository" access. However the only repo it has write access to is
// https://gitlab.com/isomorphic-git/test.empty
// It is stored reversed because the GitHub one is stored reversed and I like being consistant.
// It is stored reversed because the GitHub one is stored reversed and I like being consistent.
const password = reverse('vjNzgKP7acS6e6vb2Q6g')
const username = 'isomorphic-git-test-push'
it('fetch', async () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/test-listServerRefs.js
Expand Up @@ -10,7 +10,7 @@ const localhost =
// NOTE:
// Protocol Version 1 is incapable of reporting all the symrefs in a repo
// It reports HEAD but does not report refs/heads/symbol.
// So that descrepancy between the results for version 1 and version 2 is correct.
// So that discrepancy between the results for version 1 and version 2 is correct.
describe('listServerRefs', () => {
it('protocol 1', async () => {
const refs = await listServerRefs({
Expand Down
4 changes: 2 additions & 2 deletions docs/cache.md
Expand Up @@ -29,7 +29,7 @@ test().catch(err => console.log(err))

Running this code on the `isomorphic-git` repo on my 2018 Macbook Pro takes over 2 minutes!

It is slow because every time you call `git.status` it has to re-read and re-parse one or more packfiles in `.git/objecs/pack`.
It is slow because every time you call `git.status` it has to re-read and re-parse one or more packfiles in `.git/objects/pack`.
Each individual status may take relatively little time (10ms to 100ms) but if you have thousands of files that quickly adds up.

Naively doing it in parallel will not help!
Expand Down Expand Up @@ -76,7 +76,7 @@ This runs in 843ms on my machine.
As you can see, you can easily write yourself into a performance trap using `isomorphic-git` commands in isolation.

Unlike canonical `git` commands however, there is a way for `isomorphic-git` commands to cache intermediate results
and re-use them between commands.
and reuse them between commands.
It used to do this by default, but that results in a memory leak if you never clear the cache.

There is no single best caching strategy:
Expand Down
2 changes: 1 addition & 1 deletion docs/onAuthFailure.md
Expand Up @@ -8,7 +8,7 @@ This is helpful to know if you were using a saved password in the `onAuth` callb
It also gives you an opportunity to retry the request with new credentials.

As long as your `onAuthFailure` function returns credentials, it will keep trying.
This is the main reason we don't re-use the `onAuth` callback for this purpose. If we did, then a naive `onAuth` callback that simply returned saved credentials might loop indefinitely.
This is the main reason we don't reuse the `onAuth` callback for this purpose. If we did, then a naive `onAuth` callback that simply returned saved credentials might loop indefinitely.

An `onAuthFailure` function is called with a `url` and an `auth` object and can return a GitAuth object:

Expand Down
2 changes: 1 addition & 1 deletion src/api/annotatedTag.js
Expand Up @@ -24,7 +24,7 @@ import { normalizeAuthorObject } from '../utils/normalizeAuthorObject.js'
* @param {string} [args.tagger.email] - Default is `user.email` config.
* @param {number} [args.tagger.timestamp=Math.floor(Date.now()/1000)] - Set the tagger timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
* @param {number} [args.tagger.timezoneOffset] - Set the tagger timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
* @param {string} [args.gpgsig] - The gpgsig attatched to the tag object. (Mutually exclusive with the `signingKey` option.)
* @param {string} [args.gpgsig] - The gpgsig attached to the tag object. (Mutually exclusive with the `signingKey` option.)
* @param {string} [args.signingKey] - Sign the tag object using this private PGP key. (Mutually exclusive with the `gpgsig` option.)
* @param {boolean} [args.force = false] - Instead of throwing an error if a tag named `ref` already exists, overwrite the existing tag. Note that this option does not modify the original tag object itself.
* @param {object} [args.cache] - a [cache](cache.md) object
Expand Down
8 changes: 4 additions & 4 deletions src/api/listServerRefs.js
Expand Up @@ -25,12 +25,12 @@ import { writeListRefsRequest } from '../wire/writeListRefsRequest.js'
* Hard numbers vary by situation, but here's some numbers from my machine:
*
* Using isomorphic-git in a browser, with a CORS proxy, listing only the branches (refs/heads) of https://github.com/isomorphic-git/isomorphic-git
* - Protocol Version 1 took ~300ms and transfered 84 KB.
* - Protocol Version 2 took ~500ms and transfered 4.1 KB.
* - Protocol Version 1 took ~300ms and transferred 84 KB.
* - Protocol Version 2 took ~500ms and transferred 4.1 KB.
*
* Using isomorphic-git in a browser, with a CORS proxy, listing only the branches (refs/heads) of https://gitlab.com/gitlab-org/gitlab
* - Protocol Version 1 took ~4900ms and transfered 9.41 MB.
* - Protocol Version 2 took ~1280ms and transfered 433 KB.
* - Protocol Version 1 took ~4900ms and transferred 9.41 MB.
* - Protocol Version 2 took ~1280ms and transferred 433 KB.
*
* Finally, there is a fun quirk regarding the `symrefs` parameter.
* Protocol Version 1 will generally only return the `HEAD` symref and not others.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/checkout.js
Expand Up @@ -318,7 +318,7 @@ async function analyze({

// This is a kind of silly pattern but it worked so well for me in the past
// and it makes intuitively demonstrating exhaustiveness so *easy*.
// This checks for the presense and/or absence of each of the 3 entries,
// This checks for the presence and/or absence of each of the 3 entries,
// converts that to a 3-bit binary representation, and then handles
// every possible combination (2^3 or 8 cases) with a lookup table.
const key = [!!stage, !!commit, !!workdir].map(Number).join('')
Expand Down
2 changes: 1 addition & 1 deletion src/errors/IndexResetError.js
Expand Up @@ -6,7 +6,7 @@ export class IndexResetError extends BaseError {
*/
constructor(filepath) {
super(
`Could not merge index: Entry for '${filepath}' is not up to date. Either reset the index entry to HEAD, or stage your unstaged chages.`
`Could not merge index: Entry for '${filepath}' is not up to date. Either reset the index entry to HEAD, or stage your unstaged changes.`
)
this.code = this.name = IndexResetError.code
this.data = { filepath }
Expand Down
2 changes: 1 addition & 1 deletion src/managers/GitIgnoreManager.js
Expand Up @@ -5,7 +5,7 @@ import { dirname } from '../utils/dirname.js'
import { join } from '../utils/join.js'

// I'm putting this in a Manager because I reckon it could benefit
// from a LOT of cacheing.
// from a LOT of caching.
export class GitIgnoreManager {
static async isIgnored({ fs, dir, gitdir = join(dir, '.git'), filepath }) {
// ALWAYS ignore ".git" folders.
Expand Down
2 changes: 1 addition & 1 deletion src/managers/GitRemoteHTTP.js
Expand Up @@ -8,7 +8,7 @@ import { collect } from '../utils/collect.js'
import { extractAuthFromUrl } from '../utils/extractAuthFromUrl.js'
import { parseRefsAdResponse } from '../wire/parseRefsAdResponse.js'

// Try to accomodate known CORS proxy implementations:
// Try to accommodate known CORS proxy implementations:
// - https://jcubic.pl/proxy.php? <-- uses query string
// - https://cors.isomorphic-git.org <-- uses path
const corsProxify = (corsProxy, url) =>
Expand Down
6 changes: 3 additions & 3 deletions src/models/FileSystem.js
Expand Up @@ -74,7 +74,7 @@ export class FileSystem {

/**
* Return true if a file exists, false if it doesn't exist.
* Rethrows errors that aren't related to file existance.
* Rethrows errors that aren't related to file existence.
*/
async exists(filepath, options = {}) {
try {
Expand Down Expand Up @@ -218,7 +218,7 @@ export class FileSystem {

/**
* Return the Stats of a file/symlink if it exists, otherwise returns null.
* Rethrows errors that aren't related to file existance.
* Rethrows errors that aren't related to file existence.
*/
async lstat(filename) {
try {
Expand All @@ -234,7 +234,7 @@ export class FileSystem {

/**
* Reads the contents of a symlink if it exists, otherwise returns null.
* Rethrows errors that aren't related to file existance.
* Rethrows errors that aren't related to file existence.
*/
async readlink(filename, opts = { encoding: 'buffer' }) {
// Note: FileSystem.readlink returns a buffer by default
Expand Down
2 changes: 1 addition & 1 deletion src/models/GitConfig.js
Expand Up @@ -34,7 +34,7 @@ const schema = {
// section starts with [ and ends with ]
// section is alphanumeric (ASCII) with - and .
// section is case insensitive
// subsection is optionnal
// subsection is optional
// subsection is specified after section and one or more spaces
// subsection is specified between double quotes
const SECTION_LINE_REGEX = /^\[([A-Za-z0-9-.]+)(?: "(.*)")?\]$/
Expand Down
2 changes: 1 addition & 1 deletion src/models/GitPktLine.js
Expand Up @@ -9,7 +9,7 @@ of the line, the pkt-len, indicates the total length of the line,
in hexadecimal. The pkt-len includes the 4 bytes used to contain
the length's hexadecimal representation.
A pkt-line MAY contain binary data, so implementors MUST ensure
A pkt-line MAY contain binary data, so implementers MUST ensure
pkt-line parsing/formatting routines are 8-bit clean.
A non-binary line SHOULD BE terminated by an LF, which if present
Expand Down
4 changes: 2 additions & 2 deletions website/blog/2018-04-02-contributing-workflow.md
Expand Up @@ -268,7 +268,7 @@ Branch issue-107 set up to track remote branch issue-107 from origin.
```
(If the linter had found any style problems, it would have fixed them using prettier.
I have not automated ammending the commit though, so I would have to fix the commit with
I have not automated amending the commit though, so I would have to fix the commit with
`git add -u && git commit --amend --no-edit` and try pushing again.)
Since it succeeded, it will show up on the [Github page](https://github.com/isomorphic-git/isomorphic-git)
Expand All @@ -279,7 +279,7 @@ However, now I will tack on "(fixes #107)" to the end of the title just so Githu
the issue and the PR.
... I lied. Github is not smart enough to use the PR title. :eyeroll:
I edit the PR description to be "fixes #107" and _then_ Github adds the "wmhilton referened this issue a minute ago" link to the PR to the issue.
I edit the PR description to be "fixes #107" and _then_ Github adds the "wmhilton referenced this issue a minute ago" link to the PR to the issue.
Now we wait for the Continuous Integration (CI) system to do its thing.
I didn't actually check if it would work in the browser -
Expand Down
4 changes: 2 additions & 2 deletions website/blog/2020-02-25-version-1-0-0.md
Expand Up @@ -38,7 +38,7 @@ And here's what it looks like in version 1.0:


The functions themselves have been tweaked so that the [core object interfaces](https://github.com/isomorphic-git/isomorphic-git/blob/master/src/typedefs.js) (`CommitObject`, `TreeEntry`, `TagObject`, etc) are reused wherever possible,
so that all the functions feel consistant and there are no surprises.
so that all the functions feel consistent and there are no surprises.
The result is a cleaner API where the documentation comes to you, right where you are.

## Better TypeScript Integration
Expand Down Expand Up @@ -159,7 +159,7 @@ Everyone has benefitted from the bugfixes, perf, and usability enhancements that
- The `autoTranslateSSH` feature was removed, since it is trivial to implement your own version using just the `UnknownTransportError.data.suggestion`
- The `writeObject` function when used to write a tree now expects a plain array rather than an object with a property called `entries` which is the array. (This is so that argument to `writeObject` has the same shape as the arguments to `writeBlob`/`writeCommit`/`writeTag`/`writeTree`.)
- The `noOverwrite` parameter was removed from `init` and is the new behavior.
- The `author.date`, `committer.date`, `tagger.date` parameters were removed in favor of `author.timestamp`, `comitter.timestamp`, `tagger.timestamp` in order to be clear about what is actually written and share the same shape as the return types in `readCommit`, `log`, and `readTag`.
- The `author.date`, `committer.date`, `tagger.date` parameters were removed in favor of `author.timestamp`, `committer.timestamp`, `tagger.timestamp` in order to be clear about what is actually written and share the same shape as the return types in `readCommit`, `log`, and `readTag`.

### The return types of some functions have changed:
- Functions that used to return `Buffer` objects now return `Uint8Array` objects. (This is so we can eventually remove all internal dependencies on the Buffer browser polyfill, which is quite heavy!)
Expand Down
2 changes: 1 addition & 1 deletion website/pages/en/index.js
Expand Up @@ -268,7 +268,7 @@ const TryGitRemoteInfo = props => (
<Container padding={["bottom", "top"]} id={props.id} background="light">
<div className="try-it-out">
<h2>Try it out!</h2>
<label htmlFor="giturl">Enter in the URL of a git repository, and we'll retrive the list of branches and tags using the git HTTP protocol.</label>
<label htmlFor="giturl">Enter in the URL of a git repository, and we'll retrieve the list of branches and tags using the git HTTP protocol.</label>
<div>
<input
id="giturl_input"
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.70.7/annotatedTag.md
Expand Up @@ -22,7 +22,7 @@ Create an annotated tag.
| tagger.date | string | Set the tagger timestamp field. Default is the current date. |
| tagger.timestamp | string | Set the tagger timestamp field. This is an alternative to using `date` using an integer number of seconds since the Unix epoch instead of a JavaScript date object. |
| tagger.timezoneOffset | string | Set the tagger timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`. |
| signature | string | The signature attatched to the tag object. (Mutually exclusive with the `signingKey` option.) |
| signature | string | The signature attached to the tag object. (Mutually exclusive with the `signingKey` option.) |
| signingKey | string | Sign the tag object using this private PGP key. (Mutually exclusive with the `signature` option.) |
| force | boolean = false | Instead of throwing an error if a tag named `ref` already exists, overwrite the existing tag. Note that this option does not modify the original tag object itself. |
| return | Promise\<void\> | Resolves successfully when filesystem operations are complete |
Expand Down

0 comments on commit 6170171

Please sign in to comment.