Skip to content

Conversation

@hrzlgnm
Copy link
Contributor

@hrzlgnm hrzlgnm commented Nov 6, 2025

PR Description

This allows for having extra slashes in git URLs. Especially in submodules. Those may be used to avoid warnings with older bitbake fetcher implementations in yocto. Which warns about relative urls when not having a slash in git urls.

But when trying to open a PR from lazygit with an url like [email protected]:/project/repo.git leads to https://bitbucket.org//project/repo being opened and one has to stare at a blank page unless one removes the extra / manualy.

This PR updates the regex used for matching git url fragments in a way, that the extra / is ignored.

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
  • You've read through your own file changes for silly mistakes etc

@hrzlgnm hrzlgnm changed the title feat: Open pull requests in browser with extra leading slashes removed Open pull requests in browser with extra leading slashes removed Nov 6, 2025
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.

I am a little bit reluctant about this change; those don't look like valid URLs to me (I find this hard to tell though, it's difficult to find official documentation about this). Wouldn't it be better to submit bug fixes to whatever software has trouble parsing them? (I don't know what "bitbake fetcher" is...)

On the other hand, there's the "be liberal in what you accept" thing, and stripping the slashes doesn't seem harmful, so why not. I guess I could be persuaded.

var defaultUrlRegexStrings = []string{
`^(?:https?|ssh)://[^/]+/(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
`^.*?@.*:(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
`^.*?@.*:/*(?P<owner>[^/].*)/(?P<repo>.*?)(?:\.git)?$`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the added [^/] needed? The /* before the owner is a greedy match, so it will consume all the leading slashes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, i'll check again whether it is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You were right, those were not needed.

Copy link
Contributor Author

@hrzlgnm hrzlgnm Nov 6, 2025

Choose a reason for hiding this comment

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

@stefanhaller I tried the mentioned: regoio.herokuapp.com from line 4 to debug the regex, but that link seems to be dead, do you mind if I also update the url to something working like https://regex101.com/, which also has support for Golang regex?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You were right, those were not needed.

Good. Please squash the second commit into the first; see https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#commit-history.

do you mind if I also update the url to something working like https://regex101.com/,

Yes please, that's a good change (separate commit of course). I use regex101 myself most of the time, it's great.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stefanhaller Done as requested, Thanks you for your review.

@hrzlgnm
Copy link
Contributor Author

hrzlgnm commented Nov 6, 2025

I am a little bit reluctant about this change; those don't look like valid URLs to me (I find this hard to tell though, it's difficult to find official documentation about this). Wouldn't it be better to submit bug fixes to whatever software has trouble parsing them?
(I don't know what "bitbake fetcher" is...)

I totally agree on that, but the release one sometimes has to work with may not be maintained anymore so a bug report is pointless, the issue is most likely already fixed in newer versions.

@hrzlgnm
Copy link
Contributor Author

hrzlgnm commented Nov 6, 2025

Just for the reference, bitbake from yocto-3.0.0 produces the mentioned warning here:
https://github.com/openembedded/bitbake/blob/5d83d828cacb58ccb7c464e799c85fd2d2a50ccc/lib/bb/fetch2/gitsm.py#L111
Which can be worked around with adding an extra /

The issue is probably still presetn as the warning is still present on the master branch:
https://github.com/openembedded/bitbake/blob/90da82bd2bfcfd5590c9ae06015737b616074b56/lib/bb/fetch2/gitsm.py#L111

@hrzlgnm hrzlgnm requested a review from stefanhaller November 7, 2025 08:10
@hrzlgnm hrzlgnm force-pushed the feat/strip-extra-slashes-from-projects branch from e33099f to 8063f50 Compare November 7, 2025 14:58
This allows for having extra slashes in git urls, for example to avoid
warnings with older bitbake fetcher implementations in yocto. Which
warns about a missing / in git urls
@hrzlgnm hrzlgnm force-pushed the feat/strip-extra-slashes-from-projects branch from 8063f50 to f729e2c Compare November 7, 2025 15:00
@stefanhaller stefanhaller added the enhancement New feature or request label Nov 7, 2025
@stefanhaller
Copy link
Collaborator

Excellent, thanks!

@stefanhaller stefanhaller disabled auto-merge November 7, 2025 15:22
@stefanhaller stefanhaller merged commit 9c0cbd8 into jesseduffield:master Nov 7, 2025
12 of 13 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Dec 12, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) | minor | `v0.56.0` -> `v0.57.0` |

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.57.0`](https://github.com/jesseduffield/lazygit/releases/tag/v0.57.0)

[Compare Source](jesseduffield/lazygit@v0.56.0...v0.57.0)

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

#### What's Changed

##### Enhancements 🔥

- Open pull requests in browser with extra leading slashes removed by [@&#8203;hrzlgnm](https://github.com/hrzlgnm) in [#&#8203;5018](jesseduffield/lazygit#5018)
- Allow using SelectedSubmodule in CustomCommands by [@&#8203;rlkandela](https://github.com/rlkandela) in [#&#8203;5015](jesseduffield/lazygit#5015)
- Don't allow empty input in most prompts by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5043](jesseduffield/lazygit#5043)
- Suppress output from background fetch (unless there were errors) by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5044](jesseduffield/lazygit#5044)
- feat: add fork remote command by [@&#8203;karolzwolak](https://github.com/karolzwolak) in [#&#8203;4831](jesseduffield/lazygit#4831)
- Trigger immediate background fetch when switching repos by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5047](jesseduffield/lazygit#5047)

##### Fixes 🔧

- Keep cursor at top/bottom when navigating by page by [@&#8203;RaphaeleL](https://github.com/RaphaeleL) in [#&#8203;5019](jesseduffield/lazygit#5019)
- Switch to branches view when checking out a commit by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5048](jesseduffield/lazygit#5048)
- Fix deleting a remote tag when a remote branch with the same name exists, or vice versa by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5075](jesseduffield/lazygit#5075)
- Show fixup base commits in correct order in ctrl-f error message by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5073](jesseduffield/lazygit#5073)
- Band-aid fix for rare crashes when refreshing files by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5074](jesseduffield/lazygit#5074)
- Fix to support creating MRs for repositories cloned with SSH alias by [@&#8203;roveo](https://github.com/roveo) in [#&#8203;5082](jesseduffield/lazygit#5082)

##### Maintenance ⚙️

- Keep config and schema unchanged during a release by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5010](jesseduffield/lazygit#5010)
- Modernize all codes by [@&#8203;phanen](https://github.com/phanen) in [#&#8203;5036](jesseduffield/lazygit#5036)
- Bump golang.org/x/crypto from 0.37.0 to 0.45.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5054](jesseduffield/lazygit#5054)
- Don't use "HEADLESS" environment variable for running tests by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5064](jesseduffield/lazygit#5064)
- refactor: use strings.Builder and strings.Repeat to simplify code by [@&#8203;boqishan](https://github.com/boqishan) in [#&#8203;5068](jesseduffield/lazygit#5068)
- chore: fix function name in comment by [@&#8203;riyueguang](https://github.com/riyueguang) in [#&#8203;4481](jesseduffield/lazygit#4481)

##### Docs 📖

- Add a "Commit history" section to CONTRIBUTING.md by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5022](jesseduffield/lazygit#5022)
- Update table of contents in README.md by [@&#8203;madscientist16](https://github.com/madscientist16) in [#&#8203;5045](jesseduffield/lazygit#5045)
- Update docs and schema for release by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5091](jesseduffield/lazygit#5091)

##### I18n 🌎

- Update translations from Crowdin by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5090](jesseduffield/lazygit#5090)

##### Performance Improvements 📊

- Fix and speed up the file list for the "Enter path to filter by" feature by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5056](jesseduffield/lazygit#5056)

#### New Contributors

- [@&#8203;hrzlgnm](https://github.com/hrzlgnm) made their first contribution in [#&#8203;5018](jesseduffield/lazygit#5018)
- [@&#8203;RaphaeleL](https://github.com/RaphaeleL) made their first contribution in [#&#8203;5019](jesseduffield/lazygit#5019)
- [@&#8203;rlkandela](https://github.com/rlkandela) made their first contribution in [#&#8203;5015](jesseduffield/lazygit#5015)
- [@&#8203;phanen](https://github.com/phanen) made their first contribution in [#&#8203;5036](jesseduffield/lazygit#5036)
- [@&#8203;madscientist16](https://github.com/madscientist16) made their first contribution in [#&#8203;5045](jesseduffield/lazygit#5045)
- [@&#8203;karolzwolak](https://github.com/karolzwolak) made their first contribution in [#&#8203;4831](jesseduffield/lazygit#4831)
- [@&#8203;boqishan](https://github.com/boqishan) made their first contribution in [#&#8203;5068](jesseduffield/lazygit#5068)
- [@&#8203;riyueguang](https://github.com/riyueguang) made their first contribution in [#&#8203;4481](jesseduffield/lazygit#4481)
- [@&#8203;roveo](https://github.com/roveo) made their first contribution in [#&#8203;5082](jesseduffield/lazygit#5082)

**Full Changelog**: <jesseduffield/lazygit@v0.56.0...v0.57.0>

</details>

---

### Configuration

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

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, 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:eyJjcmVhdGVkSW5WZXIiOiI0Mi40Ny4wIiwidXBkYXRlZEluVmVyIjoiNDIuNDcuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants