Skip to content

Commit 6eb994e

Browse files
authored
Restore server_root endpoint (#733)
* Mention server settings in README * Restore server_root endpoint
1 parent d52688c commit 6eb994e

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jupyter lab build
3030

3131
## Settings
3232

33+
### UI Settings
34+
3335
Once installed, extension behavior can be modified via the following settings which can be set in JupyterLab's advanced settings editor:
3436

3537
- **blockWhileCommandExecutes**: suspend JupyterLab user interaction until Git commands (e.g., `commit`, `pull`, `reset`, `revert`) finish executing. Setting this to `true` helps mitigate potential race conditions leading to data loss, conflicts, and a broken Git history. Unless running a slow network, UI suspension should not interfere with standard workflows. Setting this to `false` allows for actions to trigger multiple concurrent Git actions.
@@ -41,7 +43,23 @@ Once installed, extension behavior can be modified via the following settings wh
4143
- **refreshInterval**: number of milliseconds between polling the file system for changes. In order to ensure that the UI correctly displays the current repository status, the extension must poll the file system for changes. Longer polling times increase the likelihood that the UI does not reflect the current status; however, longer polling times also incur less performance overhead.
4244
- **simpleStaging**: enable a simplified concept of staging. When this setting is `true`, all files with changes are automatically staged. When we develop in JupyterLab, we often only care about what files have changed (in the broadest sense) and don't need to distinguish between "tracked" and "untracked" files. Accordingly, this setting allows us to simplify the visual presentation of changes, which is especially useful for those less acquainted with Git.
4345

44-
### Troubleshooting
46+
### Server Settings
47+
48+
- Post *git init* actions: It is possible to provide a list of commands to be executed in a folder after it is initialized as Git repository.
49+
50+
```json
51+
{
52+
"JupyterLabGit": {
53+
"actions": {
54+
"post_init": [
55+
"touch dummy_init.dat"
56+
]
57+
}
58+
}
59+
}
60+
```
61+
62+
## Troubleshooting
4563

4664
Before consulting the following list, be sure the server extension and the frontend extension have the same version by executing the following commands:
4765

jupyterlab_git/handlers.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,18 @@ async def post(self):
621621
self.finish(json.dumps(result))
622622

623623

624+
# FIXME remove for 0.22 release - this avoid error when upgrading from 0.20 to 0.21 if the frontend
625+
# has not been rebuilt yet.
626+
class GitServerRootHandler(GitHandler):
627+
628+
@web.authenticated
629+
async def get(self):
630+
# Similar to https://github.com/jupyter/nbdime/blob/master/nbdime/webapp/nb_server_extension.py#L90-L91
631+
root_dir = getattr(self.contents_manager, "root_dir", None)
632+
server_root = None if root_dir is None else Path(root_dir).as_posix()
633+
self.finish(json.dumps({"server_root": server_root}))
634+
635+
624636
def setup_handlers(web_app):
625637
"""
626638
Setups all of the git command handlers.
@@ -649,6 +661,7 @@ def setup_handlers(web_app):
649661
("/git/remote/add", GitRemoteAddHandler),
650662
("/git/reset", GitResetHandler),
651663
("/git/reset_to_commit", GitResetToCommitHandler),
664+
("/git/server_root", GitServerRootHandler),
652665
("/git/settings", GitSettingsHandler),
653666
("/git/show_prefix", GitShowPrefixHandler),
654667
("/git/show_top_level", GitShowTopLevelHandler),

0 commit comments

Comments
 (0)