------------------------------------------------------------------------------
To reply, visit https://hellosplat.com/s/beanbag/tickets/4829/
------------------------------------------------------------------------------

New ticket #4829 by luisp
For Beanbag, Inc. > RBTools

Status: New
Tags: Priority:Medium, Type:Defect


------------------------------------------------------------------------------
rbtools with git client gets remote name containing a newline and fails to post 
review
==============================================================================

# What version are you running?
`RBTools-1.0.2`

# What steps will reproduce the problem?
1. branch off of any repo's master branch
2. make any commit
3. `rbt post --tracking-branch=origin/master --parent=CURRENT_SHA_ON_MASTER 
--branch=BRANCH_FROM_STEP_ONE`
4. the `rbt post` should error out trying to `git rev-parse 
FIRST_COMMIT_SHA_ON_MASTER^`


# What is the expected output? What do you see instead?
I expect a review to be posted. Instead I see 
```
WARNING: Could not determine specific upstream remote to use for diffs. We 
recommend setting TRACKING_BRANCH in reviewboardrc to your nearest upstream 
remote branch.
CRITICAL: Failed to execute command: ['git', 'rev-parse', 
'e181f11730060fb3682016c233533d90602a0c2c^']
``` where `e181f11730060fb3682016c233533d90602a0c2c` is the first commit ever 
made to the repo I ran this on.

# What operating system are you using?
OS: `macOS Mojave (10.14.3)`

# Attach the debug out from the command.
```
rbt post --debug --server=https://INTERNALREVIEWBOARD --repository=REPO 
--tracking-branch=origin/master 
--parent=4ccc43cb299d7498f19de6178408f2a078e51859 --branch=luisp/test           
                                       

>>> RBTools 1.0.2
>>> Python 3.7.3 (default, Mar 27 2019, 09:23:15)
[Clang 10.0.1 (clang-1001.0.46.3)]
>>> Running on Darwin-18.2.0-x86_64-i386-64bit
>>> Home = /Users/luisp
>>> Current directory = /Users/luisp/REPO
>>> Command line: rbt post --debug --server=https://INTERNALREVIEWBOARD 
>>> --repository=REPO --tracking-branch=origin/master 
>>> --parent=4ccc43cb299d7498f19de6178408f2a078e51859 --branch=luisp/test
>>> Running: tf vc help
>>> Checking for a Bazaar repository...
>>> Unable to execute "bzr help": skipping Bazaar
>>> Checking for a ClearCase repository...
>>> Unable to execute "cleartool help": skipping ClearCase
>>> Checking for a CVS repository...
>>> Unable to execute "cvs": skipping CVS
>>> Checking for a Git repository...
>>> Running: git rev-parse --git-dir
>>> Running: git config core.bare
>>> Running: git rev-parse --show-toplevel
>>> Running: git symbolic-ref -q HEAD
>>> Running: git config --get 
>>> remote.4ccc43cb299d7498f19de6178408f2a078e51859.url
>>> Command exited with rc 1: ['git', 'config', '--get', 
>>> 'remote.4ccc43cb299d7498f19de6178408f2a078e51859.url']
---
>>> Repository info: Path: /Users/luisp/REPO/.git, Base path: , Supports 
>>> changesets: False
>>> Checking for a Mercurial repository...
>>> Unable to execute "hg --help": skipping Mercurial
>>> Checking for a Perforce repository...
>>> Unable to execute "p4 help": skipping Perforce
>>> Checking for a Plastic repository...
>>> Unable to execute "cm version": skipping Plastic
>>> Checking for a Subversion repository...
>>> Running: svn --non-interactive info
>>> Command exited with rc 1: ['svn', '--non-interactive', 'info']
>>> Checking for a Team Foundation Server repository...
>>> Unable to execute "tf help": skipping TFS
>>> Making HTTP GET request to https://INTERNALREVIEWBOARD/api/
>>> Running: git rev-parse refs/heads/luisp/test
>>> Running: git branch --remotes
>>> Running: git config --get 
>>> branch.4ccc43cb299d7498f19de6178408f2a078e51859.remote
>>> Command exited with rc 1: ['git', 'config', '--get', 
>>> 'branch.4ccc43cb299d7498f19de6178408f2a078e51859.remote']
---
>>> Running: git remote
WARNING: Could not determine specific upstream remote to use for diffs. We 
recommend setting TRACKING_BRANCH in reviewboardrc to your nearest upstream 
remote branch.
>>> Running: git rev-parse 4ccc43cb299d7498f19de6178408f2a078e51859
>>> Running: git rev-list 4ccc43cb299d7498f19de6178408f2a078e51859 --not 
>>> --remotes=origin

>>> Running: git rev-parse e181f11730060fb3682016c233533d90602a0c2c^
>>> Command exited with rc 128: ['git', 'rev-parse', 
>>> 'e181f11730060fb3682016c233533d90602a0c2c^']
fatal: ambiguous argument 'e181f11730060fb3682016c233533d90602a0c2c^': unknown 
revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
e181f11730060fb3682016c233533d90602a0c2c^
---
Traceback (most recent call last):
  File "/Users/luisp/.dotfiles/venv/bin/rbt", line 10, in <module>
    sys.exit(main())
  File 
"/Users/luisp/.dotfiles/venv/lib/python3.7/site-packages/rbtools/commands/main.py",
 line 120, in main
    command.run_from_argv([RB_MAIN, command_name] + args)
  File 
"/Users/luisp/.dotfiles/venv/lib/python3.7/site-packages/rbtools/commands/__init__.py",
 line 725, in run_from_argv
    exit_code = self.main(*args) or 0
  File 
"/Users/luisp/.dotfiles/venv/lib/python3.7/site-packages/rbtools/commands/post.py",
 line 793, in main
    self.revisions = get_revisions(self.tool, self.cmd_args)
  File 
"/Users/luisp/.dotfiles/venv/lib/python3.7/site-packages/rbtools/utils/review_request.py",
 line 67, in get_revisions
    revisions = tool.parse_revision_spec(cmd_args)
  File 
"/Users/luisp/.dotfiles/venv/lib/python3.7/site-packages/rbtools/clients/git.py",
 line 147, in parse_revision_spec
    parent_ref, remote)
  File 
"/Users/luisp/.dotfiles/venv/lib/python3.7/site-packages/rbtools/clients/git.py",
 line 569, in _rev_list_youngest_remote_ancestor
    youngest_remote_commit = self._rev_parse('%s^' % local_commit)[0]
  File 
"/Users/luisp/.dotfiles/venv/lib/python3.7/site-packages/rbtools/clients/git.py",
 line 537, in _rev_parse
    revisions = self._execute([self.git, 'rev-parse'] + revisions)
  File 
"/Users/luisp/.dotfiles/venv/lib/python3.7/site-packages/rbtools/clients/git.py",
 line 1225, in _execute
    return execute(cmdline, cwd=self._git_toplevel, *args, **kwargs)
  File 
"/Users/luisp/.dotfiles/venv/lib/python3.7/site-packages/rbtools/utils/process.py",
 line 189, in execute
    raise Exception('Failed to execute command: %s' % command)
Exception: Failed to execute command: ['git', 'rev-parse', 
'e181f11730060fb3682016c233533d90602a0c2c^']
```


# Please provide any additional information below.
Git: `git version 2.20.1 (Apple Git-117)`
Python: `3.7.3`
reviewboardrc: None

>From some debugging, it seems like 
>https://github.com/reviewboard/rbtools/blob/5a58d03c7b9eb709330436ee415a268aebee15bb/rbtools/clients/git.py#L143
> is returning `origin\n` which is then passed into 
>https://github.com/reviewboard/rbtools/blob/5a58d03c7b9eb709330436ee415a268aebee15bb/rbtools/clients/git.py#L146.
> I added a breakpoint and ran 
>`self._rev_list_youngest_remote_ancestor(parent_ref, 'origin\n')` to verify 
>and saw the same stracktrace about `Exception: Failed to execute command: 
>['git', 'rev-parse', 'e181f11730060fb3682016c233533d90602a0c2c^']`. I then ran 
>`self._rev_list_youngest_remote_ancestor(parent_ref, 'origin')` didn't get a 
>traceback. 

Seems like a quick fix would be to to call strip() before returning in 
https://github.com/reviewboard/rbtools/blob/5a58d03c7b9eb709330436ee415a268aebee15bb/rbtools/clients/git.py#L143,
 but I'm not sure if this should be done at a lower level (or if it should be 
done in a more targetted fashion inside `parse_revision_spec`.

------------------------------------------------------------------------------

-- 
You received this message because you are subscribed to the Google Groups 
"reviewboard-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/reviewboard-issues.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/reviewboard-issues/20190627000756.25890.37268%40ip-10-1-54-209.ec2.internal.
For more options, visit https://groups.google.com/d/optout.

Reply via email to