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

Don't rewrite config file unnecessarily when it contains commitPrefixes #4311

Conversation

ChrisMcD1
Copy link
Contributor

@ChrisMcD1 ChrisMcD1 commented Feb 23, 2025

Now, we initialize it to false, only set it to true inside our modification section of the for loop.
Tests updated to add one that would have failed prior to this change. The syntax change to use named struct fields instead of positional fields felt nice since I wanted to just define on a single one of them the assertAsString field.

The reason that field is required at all is the 2nd complaint on the linked issue about the formatting change, is I don't believe is something that is trivial to fix. I observed on existing migrations before I wrote this one. But if it is easy to wrap up into this, let me know!

Also, how do we normally backport things into previous releases? We'll probably want this to make it into a 0.47.2.

  • Please check if the PR fulfills these requirements
  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • [X]You've read through your own file changes for silly mistakes etc

Copy link
Collaborator

@stefanhaller stefanhaller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just two small things below.

I agree it would be good to release a 0.47.2 with this. There's no need for a backporting process, we usually just cut a new release from master and don't care that it also contains a few other changes.

foo:
- pattern: "^\\w+-\\w+.*"
replace: '[JIRA $0] '`,
expected: `
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is relying on the knowledge that our yaml rewriting will change the indentation to 4. If we change that as proposed in #4312, this test will no longer catch the error but succeed either way.

I think I would use some other indentation (e.g. 3 at top level, 1 at the second level) to make this more robust.

assert.Equal(t, s.expected, string(actualBytes))
} else {
assert.Equal(t, expectedConfig, actualConfig)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this change is necessary. If we do it, then we should also get rid of the indentation changes in many of the tests (and the comments "indentation is not preserved etc"). I got rid of many of those already in #4312 already though, so I feel we can just leave this as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this change is not necessary, are we fine without any tests in this PR? I'm fine with that, if so.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not what I meant, but I misread the code. I have mistaken this for the tests in yaml_utils_test.go, which always do string comparisons. I thought this one would do that too, before your change here; I didn't realize it always did yaml node comparisons.

So I guess what I would suggest is to change this test to work in a similar way as the ones in yaml_utils_test.go. I pushed a WIP commit that makes this change, but it would of course be nicer to have this before the other commit in the history. Happy to make this change if you agree, and if you don't enjoy history cleanup work (I do 😄).

@stefanhaller stefanhaller force-pushed the 4310-fix-commit-prefixes-deprecated branch from 1723b86 to d83208d Compare February 23, 2025 17:38
@ChrisMcD1 ChrisMcD1 force-pushed the 4310-fix-commit-prefixes-deprecated branch from d83208d to 35f8c32 Compare February 23, 2025 17:39
@ChrisMcD1
Copy link
Contributor Author

@stefanhaller Whoops! I was doing the rebase at the same time as you!

@ChrisMcD1 ChrisMcD1 force-pushed the 4310-fix-commit-prefixes-deprecated branch from 35f8c32 to d83208d Compare February 23, 2025 17:40
@stefanhaller
Copy link
Collaborator

No worries, feel free to force-push over my version, it wasn't much work.

If you want to pick up my changes, it would be easy to cherry-pick that commit.

@ChrisMcD1
Copy link
Contributor Author

I restored to your commit

@stefanhaller
Copy link
Collaborator

It's a bad habit of mine to rebase contributor's branches and force-push them, I should do that less often, or at least ask for an ok before I do that. I'm sometimes impatient and don't want to wait for the communication roundtrips...

@ChrisMcD1
Copy link
Contributor Author

I understand you there!

Just removed the assertAsString field since it is now useless. I'm happy with the tests like this if you want to squash and merge

stefanhaller and others added 3 commits February 23, 2025 18:59
@stefanhaller stefanhaller force-pushed the 4310-fix-commit-prefixes-deprecated branch from 7620855 to 72b9e83 Compare February 23, 2025 18:01
@stefanhaller
Copy link
Collaborator

Ok. I force-pushed again with a cleaned-up commit history, I also changed the indentation of the added test as suggested here to make it more robust.

Wanna have a last look before I merge?

@stefanhaller stefanhaller added the bug Something isn't working label Feb 23, 2025
Copy link
Contributor Author

@ChrisMcD1 ChrisMcD1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good To Me!

@stefanhaller stefanhaller changed the title Make commit prefixes migration only return true if it enters if statement Don't rewrite config file unnecessarily when it contains commitPrefixes Feb 23, 2025
@stefanhaller stefanhaller merged commit 62c6ba7 into jesseduffield:master Feb 23, 2025
15 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Feb 26, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) | patch | `v0.47.1` -> `v0.47.2` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jesseduffield/lazygit (jesseduffield/lazygit)</summary>

### [`v0.47.2`](https://github.com/jesseduffield/lazygit/releases/tag/v0.47.2)

[Compare Source](jesseduffield/lazygit@v0.47.1...v0.47.2)

<!-- Release notes generated using configuration in .github/release.yml at v0.47.2 -->

Small patch release for you all. This is mainly to fix an issue with v0.47.1 which erroneously re-indented users' lazygit config files on startup.

Shout-out to [@&#8203;karimkhaleel](https://github.com/karimkhaleel) for his MR with some gnarly yaml-handling code.

And a special shout-out to [@&#8203;ChrisMcD1](https://github.com/ChrisMcD1) who has been pumping out many great contributions lately. Great to have you aboard.

#### What's Changed

##### Enhancements 🔥

-   Skip post-checkout hook when discarding changes by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4313

##### Fixes 🔧

-   fix: Disable global keybinds when confirmation is active by [@&#8203;ChrisMcD1](https://github.com/ChrisMcD1) in jesseduffield/lazygit#4284
-   Don't rewrite config file unnecessarily when it contains commitPrefixes by [@&#8203;ChrisMcD1](https://github.com/ChrisMcD1) in jesseduffield/lazygit#4311
-   Change side panel width calculation to work for larger numbers by [@&#8203;ChrisMcD1](https://github.com/ChrisMcD1) in jesseduffield/lazygit#4287

##### Maintenance ⚙️

-   Fix auto-release schedule by [@&#8203;jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4308
-   Use indentation of 2 when rewriting auto-migrated config file by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4312
-   Use refs in jsonschema by [@&#8203;karimkhaleel](https://github.com/karimkhaleel) in jesseduffield/lazygit#4309
-   Improve release workflow by [@&#8203;jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4307
-   Filter out dev comments from schema by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4319
-   Fix release script by [@&#8203;jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4322
-   Fix release script once again by [@&#8203;jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4323

##### Docs 📖

-   Improve the error message when users have gpg signing turned on by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4296

**Full Changelog**: jesseduffield/lazygit@v0.47.1...v0.47.2

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xODAuMiIsInVwZGF0ZWRJblZlciI6IjM5LjE4MC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants