File tree Expand file tree Collapse file tree 3 files changed +25
-12
lines changed Expand file tree Collapse file tree 3 files changed +25
-12
lines changed Original file line number Diff line number Diff line change @@ -445,7 +445,7 @@ def post(self):
445
445
446
446
class GitServerRootHandler (GitHandler ):
447
447
448
- def post (self ):
448
+ def get (self ):
449
449
# Similar to https://github.com/jupyter/nbdime/blob/master/nbdime/webapp/nb_server_extension.py#L90-L91
450
450
self .finish (json .dumps ({
451
451
"server_root" : getattr (self .contents_manager , 'root_dir' , None )
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ export async function openDiffView(
68
68
}
69
69
}
70
70
71
+ let serverRootResultCache = null ;
71
72
/**
72
73
* Gets the path of the file relative to the Jupyter server root. This resolves the server root path after calling
73
74
* the `/git/server_root` REST API, and uses the Git repo root and the file path relative to the repo root to resolve
@@ -79,10 +80,15 @@ export async function getRelativeFilePath(
79
80
path : string ,
80
81
topRepoPath : string
81
82
) : Promise < string > {
82
- const response = await httpGitRequest ( '/git/server_root' , 'POST' , { } ) ;
83
- const responseData = await response . json ( ) ;
84
- return PathExt . join (
85
- PathExt . relative ( responseData [ 'server_root' ] , topRepoPath ) ,
86
- path
87
- ) ;
83
+ if ( serverRootResultCache !== null ) {
84
+ return serverRootResultCache ;
85
+ } else {
86
+ const response = await httpGitRequest ( '/git/server_root' , 'GET' , null ) ;
87
+ const responseData = await response . json ( ) ;
88
+ serverRootResultCache = PathExt . join (
89
+ PathExt . relative ( responseData [ 'server_root' ] , topRepoPath ) ,
90
+ path
91
+ ) ;
92
+ return serverRootResultCache ;
93
+ }
88
94
}
Original file line number Diff line number Diff line change @@ -132,12 +132,19 @@ export interface IIdentity {
132
132
export function httpGitRequest (
133
133
url : string ,
134
134
method : string ,
135
- request : Object
135
+ request : Object | null
136
136
) : Promise < Response > {
137
- let fullRequest = {
138
- method : method ,
139
- body : JSON . stringify ( request )
140
- } ;
137
+ let fullRequest ;
138
+ if ( request === null ) {
139
+ fullRequest = {
140
+ method : method
141
+ } ;
142
+ } else {
143
+ fullRequest = {
144
+ method : method ,
145
+ body : JSON . stringify ( request )
146
+ } ;
147
+ }
141
148
142
149
let setting = ServerConnection . makeSettings ( ) ;
143
150
let fullUrl = URLExt . join ( setting . baseUrl , url ) ;
You can’t perform that action at this time.
0 commit comments