unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: emacs-devel@gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>,
	Dmitry Gutov <dgutov@yandex.ru>
Subject: VC repository-url command (was: RFC: Automatic setup for bug-reference-mode)
Date: Mon, 15 Jun 2020 08:23:45 +0200	[thread overview]
Message-ID: <875zbssv7y.fsf_-_@gnu.org> (raw)
In-Reply-To: <877dw9qs1c.fsf@tcd.ie> (Basil L. Contovounesios's message of "Sun, 14 Jun 2020 22:03:11 +0100")

"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"...

Bye,
Tassilo



  reply	other threads:[~2020-06-15  6:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-14  9:37 RFC: Automatic setup for bug-reference-mode Tassilo Horn
2020-06-14 12:13 ` Basil L. Contovounesios
2020-06-14 12:56   ` Tassilo Horn
2020-06-14 14:56     ` Basil L. Contovounesios
2020-06-14 14:22 ` Stefan Monnier
2020-06-14 15:18   ` Tassilo Horn
2020-06-14 16:30     ` Tassilo Horn
2020-06-14 18:08       ` Basil L. Contovounesios
2020-06-14 18:40       ` Stefan Monnier
2020-06-14 18:57         ` Basil L. Contovounesios
2020-06-14 19:43           ` Tassilo Horn
2020-06-14 19:41       ` Dmitry Gutov
2020-06-14 20:39         ` Tassilo Horn
2020-06-14 20:51           ` Dmitry Gutov
2020-06-14 21:03             ` Basil L. Contovounesios
2020-06-15  6:23               ` Tassilo Horn [this message]
2020-06-15 11:33                 ` VC repository-url command Basil L. Contovounesios
2020-06-15  9:56           ` RFC: Automatic setup for bug-reference-mode Stephen Leake
2020-06-15 10:21             ` Tassilo Horn
2020-06-17 21:35               ` Juri Linkov
2020-06-17 22:10                 ` Dmitry Gutov
2020-06-18  6:06                 ` Tassilo Horn
2020-06-18  9:46                   ` Dmitry Gutov
2020-06-18 13:37                     ` Tassilo Horn
2020-06-18 14:28                       ` Dmitry Gutov
2020-06-15 10:57     ` Tassilo Horn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875zbssv7y.fsf_-_@gnu.org \
    --to=tsdh@gnu.org \
    --cc=contovob@tcd.ie \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).