Don't assume remote name is origin #4775
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description
Remove hardcoded assumption that the remote is named
origin
Previously,
lazygit
assumed the remote was always named origin, causing errors when repositories used a different remote name—even if a valid remote was available. This PR removes that assumption by delegating remote resolution toRemoteCommands
, which now identifies the appropriate remote automatically (it one exists). As a result,HostingServiceMgr
can consistently be instantiated with a validrepoURL
, regardless of the remote’s name.Disable the option to copy the URL for local-only commits
While testing, I noticed that
lazygit
generates a URL for commits that exist only locally, which results in a 404 when opened. This portion of the PR disables the “Copy Commit URL” option for commits that are not present on any remote branch. I achieved this by adding acommitExistsOnRemote func(string) bool
field to theHostingServiceMgr
and populating it with a newRemoteCommands.CommitExistsOnRemote
helper method at instantiation.I’m not fully satisfied with my current implementation—it feels clunky—so I’d welcome any suggestions for improvement.
Resolves in commits, if
yu
(aka Copy URL of commit) it always assumes the remote is namedorigin
#4746.Please check if the PR fulfills these requirements
go generate ./...
)