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

Add codespell support (config, workflow to detect/not fix) and make it fix few typos #3751

Merged
merged 8 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[codespell]
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
skip = .git*,go.sum,*.lock,.codespellrc,vendor,translations,Keybindings_*.md
check-hidden = true
# camel-cased
ignore-regex = (\b[A-Za-z][a-z]*[A-Z]\S+\b|\.edn\b|\S+…|\\nd\b)
ignore-words-list = fomrat,inbetween
25 changes: 25 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Codespell configuration is within .codespellrc
---
name: Codespell

on:
push:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read

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

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Annotate locations with typos
uses: codespell-project/codespell-problem-matcher@v1
- name: Codespell
uses: codespell-project/actions-codespell@v2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# Hidden
.*
!.codespellrc

# Notes
*.notes
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/Codebase_Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Packages

* `pkg/app`: Contains startup code, inititalises a bunch of stuff like logging, the user config, etc, before starting the gui. Catches and handles some errors that the gui raises.
* `pkg/app`: Contains startup code, initialises a bunch of stuff like logging, the user config, etc, before starting the gui. Catches and handles some errors that the gui raises.
* `pkg/app/daemon`: Contains code relating to the lazygit daemon. This could be better named: it's is not a daemon in the sense that it's a long-running background process; rather it's a short-lived background process that we pass to git for certain tasks, like GIT_EDITOR for when we want to set the TODO file for an interactive rebase.
* `pkg/cheatsheet`: Generates the keybinding cheatsheets in `docs/keybindings`.
* `pkg/commands/git_commands`: All communication to the git binary happens here. So for example there's a `Checkout` method which calls `git checkout`.
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/Find_Base_Commit_For_Fixup_Design.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ is this:
"github.com/jesseduffield/lazygit/pkg/utils"
+ "github.com/samber/lo"
"golang.org/x/sync/errgroup"
@@ -308,9 +309,5 @@ func (self *FixupHelper) blameAddedLines(addedLineHunks []*hunk) ([]string, erro
@@ -308,9 +309,5 @@ func (self *FixupHelper) blameAddedLines(addedLineHunks []*hunk) ([]string, error
func findCommit(hash string) (*models.Commit, int, bool) {
- for i, commit := range self.c.Model().Commits {
- if commit.Hash == hash {
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/oscommands/cmd_obj_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (self *cmdObjRunner) getCredentialPromptFn(cmdObj ICmdObj) (func(Credential
}

// runAndDetectCredentialRequest detect a username / password / passphrase question in a command
// promptUserForCredential is a function that gets executed when this function detect you need to fillin a password or passphrase
// promptUserForCredential is a function that gets executed when this function detect you need to fill in a password or passphrase
// The promptUserForCredential argument will be "username", "password" or "passphrase" and expects the user's password/passphrase or username back
func (self *cmdObjRunner) runAndDetectCredentialRequest(
cmdObj ICmdObj,
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/context/sub_commits_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewSubCommitsContext(

getDisplayStrings := func(startIdx int, endIdx int) [][]string {
// This can happen if a sub-commits view is asked to be rerendered while
// it is invisble; for example when switching screen modes, which
// it is invisible; for example when switching screen modes, which
// rerenders all views.
if viewModel.GetRef() == nil {
return [][]string{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/controllers/helpers/confirmation_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (self *ConfirmationHelper) resizeMenu(parentPopupContext types.Context) {
}

// Wraps the lines of the menu prompt to the available width and rerenders the
// menu if neeeded. Returns the number of lines the prompt takes up.
// menu if needed. Returns the number of lines the prompt takes up.
func (self *ConfirmationHelper) layoutMenuPrompt(contentWidth int) int {
oldPromptLines := self.c.Contexts().Menu.GetPromptLines()
var promptLines []string
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/controllers/helpers/confirmation_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func Test_underlineLinks(t *testing.T) {
expectedResult: "\x1b]8;;https://example.com\x1b\\https://example.com\x1b]8;;\x1b\\",
},
{
name: "link preceeded and followed by text",
name: "link preceded and followed by text",
text: "bla https://example.com xyz",
expectedResult: "bla \x1b]8;;https://example.com\x1b\\https://example.com\x1b]8;;\x1b\\ xyz",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/controllers/helpers/refresh_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ func (self *RefreshHelper) refreshStateFiles() error {
// FilteredReflogCommits are rendered in the reflogs panel, and ReflogCommits
// are used by the branches panel to obtain recency values for sorting.
func (self *RefreshHelper) refreshReflogCommits() error {
// pulling state into its own variable incase it gets swapped out for another state
// pulling state into its own variable in case it gets swapped out for another state
// and we get an out of bounds exception
model := self.c.Model()
var lastReflogCommit *models.Commit
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
// When you open a popup over it, we'll let you return to it upon pressing escape
PERSISTENT_POPUP
// A temporary popup is one that could be used for various things (e.g. a generic menu or confirmation popup).
// Because we re-use these contexts, they're temporary in that you can't return to them after you've switched from them
// Because we reuse these contexts, they're temporary in that you can't return to them after you've switched from them
// to some other context, because the context you switched to might actually be the same context but rendering different content.
// We should really be able to spawn new contexts for menus/prompts so that we can actually return to old ones.
TEMPORARY_POPUP
Expand Down
2 changes: 1 addition & 1 deletion pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@ func EnglishTranslationSet() *TranslationSet {
MovePatchIntoNewCommit: "Move patch into new commit",
MovePatchIntoNewCommitTooltip: "Move the patch out of its commit and into a new commit sitting on top of the original commit. This is achieved by starting an interactive rebase at the original commit, applying the patch in reverse, then applying the patch to the index and committing it as a new commit, before continuing the rebase to completion. If later commits depend on the patch, you may need to resolve conflicts.",
MovePatchToSelectedCommit: "Move patch to selected commit (%s)",
MovePatchToSelectedCommitTooltip: "Move the patch out of its original commit and into the selected commit. This is achieved by starting an interactive rebase at the original commit, applying the patch in reverse, then continuing the rebase up to the selected commit, before applying the patch forward and amending the seleced commit. The rebase is then continued to completion. If commits between the source and destination commit depend on the patch, you may need to resolve conflicts.",
MovePatchToSelectedCommitTooltip: "Move the patch out of its original commit and into the selected commit. This is achieved by starting an interactive rebase at the original commit, applying the patch in reverse, then continuing the rebase up to the selected commit, before applying the patch forward and amending the selected commit. The rebase is then continued to completion. If commits between the source and destination commit depend on the patch, you may need to resolve conflicts.",
CopyPatchToClipboard: "Copy patch to clipboard",
NoMatchesFor: "No matches for '%s' %s",
ExitSearchMode: "%s: Exit search mode",
Expand Down
2 changes: 1 addition & 1 deletion pkg/integration/components/text_matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (self *TextMatcher) IsSelected() *TextMatcher {

// if the matcher has an `IsSelected` rule, it returns true, along with the matcher after that rule has been removed
func (self *TextMatcher) checkIsSelected() (bool, *TextMatcher) {
// copying into a new matcher in case we want to re-use the original later
// copying into a new matcher in case we want to reuse the original later
newMatcher := &TextMatcher{Matcher: &Matcher[string]{}}
*newMatcher.Matcher = *self.Matcher

Expand Down
2 changes: 1 addition & 1 deletion pkg/integration/components/view_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (self *ViewDriver) VisibleLines(matchers ...*TextMatcher) *ViewDriver {
return self.assertLines(originY, matchers...)
}

// asserts that somewhere in the view there are consequetive lines matching the given matchers.
// asserts that somewhere in the view there are consecutive lines matching the given matchers.
func (self *ViewDriver) ContainsLines(matchers ...*TextMatcher) *ViewDriver {
self.validateMatchersPassed(matchers)
self.validateEnoughLines(matchers)
Expand Down
2 changes: 1 addition & 1 deletion pkg/integration/tests/branch/rebase_and_drop.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shared.MergeConflictsSetup(shell)
// addin a couple additional commits so that we can drop one
// adding a couple additional commits so that we can drop one
shell.EmptyCommit("to remove")
shell.EmptyCommit("to keep")
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/integration/tests/demo/custom_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var usersFileContent = `package main
import "fmt"

func main() {
// TODO: verify that this actuall works
// TODO: verify that this actually works
fmt.Println("hello world")
}
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// can be relocated elsewhere if you need them somewhere else. So for example if
// I hit enter on a branch I'll see the sub-commits view, but if I then navigate
// to the reflog context and hit enter on a reflog, the sub-commits view is moved
// to the reflog window. This is because we re-use the same view (it's a limitation
// to the reflog window. This is because we reuse the same view (it's a limitation
// that would be nice to remove in the future).
// Nonetheless, we need to ensure that upon moving the view, the filter is cancelled.

Expand Down
2 changes: 1 addition & 1 deletion pkg/integration/tests/misc/recent_repos_on_launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

// Couldn't find an easy way to actually reproduce the situation of opening outside a repo,
// so I'm introducing a hacky env var to force lazygit to show the recent repos meu upon opening.
// so I'm introducing a hacky env var to force lazygit to show the recent repos menu upon opening.

var RecentReposOnLaunch = NewIntegrationTest(NewIntegrationTestArgs{
Description: "When opening to a menu, focus is correctly given to the menu",
Expand Down
2 changes: 1 addition & 1 deletion scripts/bisect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# It's assumed that the current commit (i.e. HEAD) is broken.

if [[ $# -ne 3 ]] ; then
echo 'Usage: scripts/bisect.sh <ref thats broken> <ref thats working> <integration test name>'
echo 'Usage: scripts/bisect.sh <ref that's broken> <ref that's working> <integration test name>'
exit 1
fi

Expand Down
Loading