[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

VC repository-url command (was: RFC: Automatic setup for bug-reference-m

From: Tassilo Horn
Subject: VC repository-url command (was: RFC: Automatic setup for bug-reference-mode)
Date: Mon, 15 Jun 2020 08:23:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

>>> (defun vc-git-repository-url (file-or-dir)
>>>    (let ((default-directory (vc-git-root file-or-dir)))
>>>      (with-temp-buffer
>>>        (vc-git-command (current-buffer) 0 nil "remote" "get-url" "origin")
>>>        (buffer-substring-no-properties (point-min) (1- (point-max))))))
>>> where I explicitly name the remote "origin" (which, I know, doesn't need
>>> to exist but still works in 99% of all cases).
>> Sounds good!
>> If the new version can be used in vc-git-dir-extra-headers, could you
>> please make it so?

I'll have a look.

>> That aside, I was going to ask whether the new backend method should
>> take a "remote-name" argument, but I don't know how many backends
>> support different remotes. Or what other actual code is going to use
>> this method anyway.

I guess all distributed VCS do in some form or another.  With Hg, I
currently return the value of paths.default which could also be
paths.other-remote.  With Bzr, I think there's no such concept but each
branch is bound to some "parent branch" which is usually the URL from
where you cloned from.

> It would definitely be nice to somehow make this configurable.  For
> example in my local Emacs checkout I have Savannah as the "upstream"
> remote, and my mirror on GitLab as the "origin" remote, because that's
> where I push to most of the time.

I usually do the opposite: origin is the original project and tsdh is my
fork which I set as push-remote.

So I think I'll add an optional remote-name argument as suggested by
Dmitry that overrides "origin" for Git and "default" for Hg while being
ignored by the other supported backends SVN and Bzr.

Then I could also add "default remote" defvars (or defcustoms?) for Git
and Hg which are used if no remote-name was explicitly provided as
suggested by you.

As for the original task I want to implement, i.e., bug-reference
auto-setup, I'd actually want to get the remote's URL which actually
hosts the bug tracker (thinking of GitLab/GitHub repos and their forks).
So probably there I should try likely remote names such as "upstream"
before falling back to "origin"...


reply via email to

[Prev in Thread] Current Thread [Next in Thread]