Handle not in git repository without error 500 to avoid confusion
See original GitHub issueDescription
Hi. git extension seems to output a rather ugly error message in the bash console when the current working directory is not a git repository, or when switching to such a directory:
With debug mode on, the error seems to be triggered by the following:
[D 20:39:53.173 LabApp.jupyterlab_git] Execute ['git', 'rev-parse', '--show-toplevel'] in /opt/files/jyusr.
[D 20:39:53.187 LabApp.jupyterlab_git] Code: 128
Output:
Error: fatal: not a git repository (or any of the parent directories): .git
which is followed by the following (showing in the console even without debug mode):
[E 20:39:53.187 LabApp] {
"Host": "127.0.0.1:8888",
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0",
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding": "gzip, deflate, br",
"Referer": "https://127.0.0.1:8888/lab?",
"Content-Type": "text/plain;charset=UTF-8",
"X-Xsrftoken": "2|0d88b5b9|xxx|1607891023",
"Origin": "https://127.0.0.1:8888",
"Content-Length": "24",
"Connection": "keep-alive",
"Cookie": "username-127-0-0-1-8888=\"2|1:0|10:1607891028|23:username-127-0-0-1-8888|44:xxx=|xxxx\"; _xsrf=2|0d88b5b9|xxx|1607891023",
"Pragma": "no-cache",
"Cache-Control": "no-cache"
}
[E 20:39:53.188 LabApp] 500 POST /git/show_top_level?1607891993159 (127.0.0.1) 23.65ms referer=https://127.0.0.1:8888/lab?
Am I doing anything wrong or is this expected behavior?
Reproduce
Launch Jupyter Lab. Working directory is not a git repository.
Expected behavior
Should not show anything even if I’m not in a git repo directory.
Context
jupyter 1.0.0 py_2 conda-forge
jupyter-lsp 0.9.3 pypi_0 pypi
jupyter_client 6.1.7 py_0 conda-forge
jupyter_console 6.2.0 py_0 conda-forge
jupyter_core 4.7.0 py38h578d9bd_0 conda-forge
jupyterlab 2.2.9 py_0 conda-forge
jupyterlab-git 0.23.2 pyhd8ed1ab_0 conda-forge
jupyterlab_pygments 0.1.2 pyh9f0ad1d_0 conda-forge
jupyterlab_server 1.2.0 py_0 conda-forge
gitpython 3.1.11 py_0 conda-forge
ipython 7.19.0 py38h81c977d_0 conda-forge
python 3.8.6 h852b56e_0_cpython conda-forge
jupyterlab-git 0.23.2 pyhd8ed1ab_0 conda-forge
- Operating System and its version: Ubuntu 20.04
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Git error - Fatal: Not a git repository and how to fix it | Datree.io
This error means you attempted to run a Git command, but weren't inside a Git repository. Make sure you've: Navigated to the right...
Read more >git: fatal: Could not read from remote repository - Stack Overflow
This error means that you have not specified your remote URL location upon which your code will push. You can set remote URL...
Read more >Solving “Fatal: Not A Git Repository” (Or Any Of The Parent ...
In this article, we will explore what causes, how to prevent, and how to solve the “fatal: not a git repository” error.
Read more >Troubleshooting Geo - GitLab Docs
Exception: fe_sendauth: no password supplied GitLab Geo is enabled . ... Primary site returns 500 error when accessing /admin/geo/replication/projects.
Read more >How to Handle Errors in an Express and Node.js App
The repository has a single JavaScript file, index.js with the following content: ... If no match is found, then Express displays an error....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Solved by #855
sorry was a bit late, but here goes PR proposal.