lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Copy branch url to clipboard

Open skolj opened this issue 1 year ago • 4 comments

  • PR Description This change allows copying branch URL to clipboard in the branches view. The existing copy X items are moved to a Copy to Clipboard menu with the following copy options:
  • Branch name
  • Branch URL (key: u)
  • Pull request URL (key: p)

Fixes #1959

  • Please check if the PR fulfills these requirements
  • [x] Cheatsheets are up-to-date (run go generate ./...)
  • [x] Code has been formatted (see here)
  • [ ] Tests have been added/updated (see here for the integration test guide)
  • [ ] Text is internationalised (see here)
  • [ ] Docs (specifically docs/Config.md) have been updated if necessary
  • [x] You've read through your own file changes for silly mistakes etc

skolj avatar Feb 26 '24 00:02 skolj

Getting some weird behaviors when in a repo with multiple remotes. But I think it's not due to the changes in this PR, but rather with the way getHostingServiceMgr is implemented.

Copy branch url seems to only use the base url of the upstream named origin. This results in a 404 if the upstream named origin does not have a branch with that name.

Maybe we can find a way to pass in the name of the upstream of the branch we want to get the url / open a pull request for? We can always default to origin.

Especially since this is already what we are doing in CheckRemoteBranchExists.

karimkhaleel avatar Mar 10 '24 13:03 karimkhaleel

Valid point @karimkhaleel. I'm not sure how we'd deal with upstreams (for from and to branches) when creating pull requests given that lazygit has a pull request options menu where the target branch can be selected. The branch URL part is clear to me.

skolj avatar Mar 10 '24 19:03 skolj

I'm not sure how we'd deal with upstreams (for from and to branches) when creating pull requests given that lazygit has a pull request options menu where the target branch can be selected.

Maybe we just leave the to branch as default, like the first option in the View pull request options... menu? This is already what the lowercase o keybind does in the branches menu anyway.

karimkhaleel avatar Mar 16 '24 09:03 karimkhaleel