4530: rbt post incorrectly uses the fetch URL with a Git repository with different fetch/push URLs

kbuck

What version are you running?

RBTools 0.7.5

What steps will reproduce the problem?

  1. Clone a git repository from a mirror: $ git clone https://github.com/torvalds/linux
  2. Configure the repository with a different push URL: $ git remote set-url --push origin git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
  3. (Compose something to post for review.)
  4. $ rbt post

What is the expected output? What do you see instead?

Expected: rbt would detect the push URL and use that as the repository URL.
Actual: rbt returns: "The repository path specified is not in the list of known repositories. (HTTP 400, API Error 206)"
This is because rbt queries the fetch URL and not the push URL (strace output):
[pid 14741] execve("/usr/bin/git", ["git", "config", "--get", "remote.origin.url"], [/ 28 vars /]) = 0

What operating system are you using?

Ubuntu 16.04.1

Attach the debug out from the command.

Extraneous content removed:

$ rbt post --debug HEAD
>>> RBTools 0.7.5
>>> Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609]
>>> Running on Linux-4.4.0-47-generic-x86_64-with-Ubuntu-16.04-xenial
(...)
>>> Running: git config --get remote.origin.url
>>> repository info: Path: ssh://git-mirror.(...), Base path: , Supports changesets: False
(...)
>>> Got API Error 206 (HTTP code 400): The repository path specified is not in the list of known repositories.
>>> Error data: {u'stat': u'fail', u'repository': u'ssh://git-mirror.(...)', u'err': {u'msg': u'The repository path specified is not in the list of known repositories.', u'code': 206}}
Traceback (most recent call last):
  File "/usr/bin/rbt", line 9, in <module>
    load_entry_point('RBTools==0.7.5', 'console_scripts', 'rbt')()
  File "/usr/lib/python2.7/dist-packages/rbtools/commands/main.py", line 133, in main
    command.run_from_argv([RB_MAIN, command_name] + args)
  File "/usr/lib/python2.7/dist-packages/rbtools/commands/__init__.py", line 622, in run_from_argv
    exit_code = self.main(*args) or 0
  File "/usr/lib/python2.7/dist-packages/rbtools/commands/post.py", line 754, in main
    (msg_prefix, e))
rbtools.commands.CommandError: Error validating diff

The repository path specified is not in the list of known repositories. (HTTP 400, API Error 206)

Please provide any additional information below.

This bug also reproduces with RBTools 0.7.9.

Unfortunately, it looks like querying for the push URL will only return a value if this has been set separately from the fetch URL, so rbt will need to query for a pushurl, then if that doesn't exist, use the default URL.

#1 kbuck

The command to read the push URL from a repo configured with a separate one is:
$ git config --get remote.<remotename>.pushurl