sshaw / git-link

Emacs package to get the GitHub/Bitbucket/GitLab/... URL for a buffer location
399 stars 74 forks source link

Configuring remote per repository #17

Closed prathamesh-sonpatki closed 9 years ago

prathamesh-sonpatki commented 9 years ago

Can we configure default remote (origin/upstream) (& branch also) at repository level. For certain upstream repositories, I want to see commit links in upstream though I am in origin. Usecase for forked codebases. Upstream is pointing to source while origin is pointing to my fork which may be outdated.

sshaw commented 9 years ago

Sounds like a good idea. Currently you may be able to do this for remote by advising git-link (untested):

(defadvice git-link (aroud git-link-remote-lookup first nil activate)
  (let ((git-link-default-remote (your-lookup-funtion (git-link-repo-root))))
    ad-do-it))

But that doesn't handle branch, which currently can't be set.

How would you expect to map repo to branch/remote? Per buffer via buffer local variables, a callback, prompted by prefix call to git-link? What would be the key used to lookup mapped brach/remote?

sshaw commented 9 years ago

Can we configure default remote (origin/upstream) (& branch also) at repository level

Ah, I think you're saying that you'd like to be able so do something like this:

git config --local --add git-link.remote  some-remote
git config --local --add git-link.branch  some-branch

Good idea. Please confirm.

prathamesh-sonpatki commented 9 years ago

@sshaw Sorry for replying late. But this is exactly I want :smile:

sshaw commented 9 years ago

@prathamesh-sonpatki checkout the git-based-config branch. It gives priority to the the branch and remote given by git config git-link.remote and git config git-link.branch. Let me know what you think.

One question: If git-link.remote does not exist how should C-u M-x git-link behave? I think current functionality is okay, but I can also see it being a tad confusing.

sshaw commented 9 years ago

This has been merged into master and can be found in the v0.3.0 release.

prathamesh-sonpatki commented 9 years ago

Looks good. I will try it out.

If git-link.remote does not exist how should C-u M-x git-link behave?

I think current behavior is good in that case.