4953: Submitting reviews in some directories fails due to none error


What version are you running?

RBTools 2.0.1 (Python 3.9.2)

What steps will reproduce the problem?

This is happening randomly in a repository I'm using so not something someone can reproduce on command, however for my repo to reproduce it I simply add a file, commit it, and use rbt post

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

For it to post to our RB server, instead I get:
CRITICAL: expected str, bytes or os.PathLike object, not NoneType
This seems to be from the
['git', 'rev-parse', '--git-dir']
function, it returns .git, there is a bit of code checking that the folder exists and, if it doesn't, returns none, which the script cannot then handle. However, this check is invalid because the repo is at path ~/REPO/modules/new and the folder I am in is ~/REPO/modules/new/tests/test/build so there would not be a .git folder in this path, it should be looking for a .git folder up 3 directories.
Note that I have many branches, I am currently in a non-main branch with a remote that points to upstram main (I have many branches that do this in this repository)

What operating system are you using?

Linux, debian 11

Attach the debug out from the command.

>>> RBTools 2.0.1
>>> Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110]
>>> Running on Linux-5.15.0-11.1-liquorix-amd64-x86_64-with-glibc2.32
>>> Home = /home/user
>>> Current directory = /home/user/REPO/modules/new/tests/test/_AA
>>> Command line: rbt post --branch=devfix --target-groups=CP_Modules --bugs-closed=20667 -d
>>> Running: tf vc help
>>> Checking for a Bazaar repository...
>>> Unable to execute "brz help" or "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...
['git', 'rev-parse', '--git-dir']
>>> Running: git rev-parse --git-dir
>>> Running: git config core.bare
>>> Running: git rev-parse --show-toplevel
['git', 'symbolic-ref', '-q', 'HEAD']
>>> Running: git symbolic-ref -q HEAD
['git', 'config', '--get', 'branch.devfix.merge']
>>> Running: git config --get branch.devfix.merge
>>> Command exited with rc 1: ['git', 'config', '--get', 'branch.devfix.merge']
['git', 'config', '--get', 'branch.devfix.remote']
>>> Running: git config --get branch.devfix.remote
>>> Command exited with rc 1: ['git', 'config', '--get', 'branch.devfix.remote']
['git', 'config', '--global', '--get', 'init.defaultBranch']
>>> Running: git config --global --get init.defaultBranch
['git', 'rev-parse', '--git-dir']
>>> Running: git rev-parse --git-dir
['git', 'rev-parse', '--git-dir']
>>> Running: git rev-parse --git-dir
Traceback (most recent call last):
  File "/home/user/.local/bin/rbt", line 39, in <module>
  File "/home/user/.local/lib/python3.9/site-packages/rbtools/commands/main.py", line 124, in main
    command.run_from_argv([RB_MAIN, command_name] + args)
  File "/home/user/.local/lib/python3.9/site-packages/rbtools/commands/__init__.py", line 770, in run_from_argv
    exit_code = self.main(*args) or 0
  File "/home/user/.local/lib/python3.9/site-packages/rbtools/commands/post.py", line 956, in main
    repository_info, self.tool = self.initialize_scm_tool(
  File "/home/user/.local/lib/python3.9/site-packages/rbtools/commands/__init__.py", line 816, in initialize_scm_tool
    repository_info, tool = scan_usable_client(
  File "/home/user/.local/lib/python3.9/site-packages/rbtools/clients/__init__.py", line 861, in scan_usable_client
    repository_info = tool.get_repository_info()
  File "/home/user/.local/lib/python3.9/site-packages/rbtools/clients/git.py", line 378, in get_repository_info
    upstream_branch = self._get_parent_branch()
  File "/home/user/.local/lib/python3.9/site-packages/rbtools/clients/git.py", line 568, in _get_parent_branch
    os.path.exists(os.path.join(self._get_git_dir(), 'refs',
  File "/usr/lib/python3.9/posixpath.py", line 76, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

I added some print output to narrow down the issue, which is included in the above debug output