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

allow to type a branch name #30

Open
parkouss opened this issue Apr 3, 2016 · 5 comments
Open

allow to type a branch name #30

parkouss opened this issue Apr 3, 2016 · 5 comments
Milestone

Comments

@parkouss
Copy link

parkouss commented Apr 3, 2016

Hi, first, thanks for this package!

I have a request - I am sometimes working on a local branch (not pushed to a remote location) and in this case using git-link generate a wrong url. Would it be possible to allow to chose the branch in some cases? I am thinking of something simple, e.g:

M-x git-link => do not prompt, generate link
C-u M-x git-link => ask for the remote name first
C-u C-u M-x git-link => ask for the remote and the branch name

Note that the first two options are already working this way, so it should not break the workflow for other users.

What do you think? I could work on a simple PR to implement this if you like the idea.

@sshaw
Copy link
Owner

sshaw commented Apr 14, 2016

Hi!

I am sometimes working on a local branch (not pushed to a remote location) and in this case using git-link generate a wrong url

Do you know about these options?

Would it be possible to allow to chose the branch in some cases?

Certainly seems reasonable.

I am thinking of something simple, e.g:
M-x git-link => do not prompt, generate link
C-u M-x git-link => ask for the remote name first
C-u C-u M-x git-link => ask for the remote and the branch n

Also seems reasonable, though could this be done another way? Just curious.

What do you think? I could work on a simple PR to implement this if you like the idea.

Pull request it up! :neckbeard:

@sshaw
Copy link
Owner

sshaw commented Apr 14, 2016

C-u M-x git-link => ask for the remote name first
C-u C-u M-x git-link => ask for the remote and the branch name

But... what if someone only wants to specify the branch name? May get complicated.

At some point I wanted to remove git-link-commit and incorporate it into git-link. That's a lot of prefix options. So I guess my question of "could this be done another way" may be somewhat more relevant.

Maybe it's sign that adding git-link-commit to git-link is a bad idea. Or, that prompting for branch is 😈.

@sshaw sshaw added this to the v1.0 milestone Sep 26, 2017
@ibizaman
Copy link

What about functions like these?

(defun git-link-master-branch ()
  (interactive)
  (let ((git-link-default-branch "master"))
    (call-interactively 'git-link)))
(defun git-link-at-commit ()
  (interactive)
  (let ((git-link-use-commit t))
    (call-interactively 'git-link)))

@dotemacs
Copy link

Hello o/

I really like git-link & have been using it for ages. Thank you for the work put in.

Oftentimes I have the same requirement that this thread is describing, where I'd like to link to a branch on GitHub (or some forge), that isn't the branch that I'm currently working on. I had some hacks in place to handle it. But revisited this repo to see if there's been some work on it.

Since git-link, the function, already handles a few current-prefix-arg options, I'm not sure what is the most elegant way to add the option for linking to a remote branch on a forge, while passing the prefix arg to git-link.

So I extended the function @ibizaman came up with, above:

(defun git-link-diffrent-branch (branch)
  "Invoke `git-link', but with the `branch' name set to a different
branch than the one you're currently working on."
  (interactive "P")
  (let* ((default-remote-branch-name "main")
         (git-link-current-branch-setting git-link-default-branch)
         (git-link-default-branch (if branch
                                      (completing-read
                                       (format "Instead of '%s' branch replace with branch: " (git-link--branch))
                                       (magit-list-branch-names))
                                    default-remote-branch-name)))
    (setq current-prefix-arg nil)
    (call-interactively 'git-link)
    (setq git-link-default-branch git-link-current-branch-setting)))

Ideally, I'd like git-link to just accept a prefix arg and then prompt you to provide:

  • a remote (like it currently does)
  • a branch
  • a remote & a branch

Yes, this is all a PR away, but is it worth pursuing?

Thanks

@sshaw
Copy link
Owner

sshaw commented Aug 19, 2024

Yes, this is all a PR away, but is it worth pursuing?

@dotemacs yes I think so, the demand is there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants