Skip to content

Commit adb91e6

Browse files
authored
Merge pull request #438 from fcollonval/408-model-vue
Rework frontend
2 parents 53ee473 + 8192bc8 commit adb91e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3706
-2897
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,4 @@ node_modules/
107107
package-lock.json
108108
MANIFEST
109109
jupyterlab_git/labextension/*.tgz
110+
*.tsbuildinfo

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ cache:
77
- /home/travis/.yarn-cache/
88
before_install:
99
- nvm install 10
10-
install: pip install pytest "jupyterlab~=1.0"
10+
install: pip install pytest "jupyterlab~=1.1"
1111
script:
1212
- python setup.py sdist
13+
# Install the extension ensuring the cache is unused
1314
- pip install jupyterlab_git[test] --pre --no-index --find-links=dist --no-deps --no-cache-dir -v
15+
# Install the extension dependencies
1416
- pip install jupyterlab_git[test]
1517
- jupyter labextension list
1618
- jupyter lab build

jest.config.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
var tsConfig = require ('./tsconfig.json');
2+
3+
var tsOptions = tsConfig["compilerOptions"];
4+
// Need as the test folder is not visible from the src folder
5+
tsOptions["rootDir"] = null;
6+
17
module.exports = {
28
automock: false,
39
moduleNameMapper: {
@@ -7,12 +13,12 @@ module.exports = {
713
preset: 'ts-jest/presets/js-with-babel',
814
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
915
setupFiles: ['<rootDir>/testutils/jest-setup-files.js'],
10-
testPathIgnorePatterns: ['/dev_mode/', '/lib/', '/node_modules/'],
11-
testRegex: '/tests/test-.*/.*.spec.ts[x]?$',
16+
testPathIgnorePatterns: ['/lib/', '/node_modules/'],
17+
testRegex: '/tests/.*.spec.ts[x]?$',
1218
transformIgnorePatterns: ['/node_modules/(?!(@jupyterlab/.*)/)'],
1319
globals: {
1420
'ts-jest': {
15-
tsConfig: 'tsconfig.json'
21+
tsConfig: tsOptions
1622
}
1723
}
1824
};

jupyterlab_git/handlers.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ def post(self):
142142
POST request handler,
143143
fetches Commit SHA, Author Name, Commit Date & Commit Message.
144144
"""
145-
current_path = self.get_json_body()["current_path"]
146-
result = self.git.log(current_path)
145+
body = self.get_json_body()
146+
current_path = body["current_path"]
147+
history_count = body.get("history_count", 25)
148+
result = self.git.log(current_path, history_count)
147149
self.finish(json.dumps(result))
148150

149151

@@ -179,9 +181,6 @@ def post(self):
179181
top_repo_path = self.get_json_body()["top_repo_path"]
180182
my_output = self.git.diff(top_repo_path)
181183
self.finish(my_output)
182-
print("GIT DIFF")
183-
print(my_output)
184-
185184

186185
class GitBranchHandler(GitHandler):
187186
"""
@@ -289,12 +288,10 @@ def post(self):
289288
top_repo_path = data["top_repo_path"]
290289
if data["checkout_branch"]:
291290
if data["new_check"]:
292-
print("to create a new branch")
293291
my_output = self.git.checkout_new_branch(
294292
data["branchname"], top_repo_path
295293
)
296294
else:
297-
print("switch to an old branch")
298295
my_output = self.git.checkout_branch(data["branchname"], top_repo_path)
299296
elif data["checkout_all"]:
300297
my_output = self.git.checkout_all(top_repo_path)
@@ -418,7 +415,6 @@ def post(self):
418415
"""
419416
top_repo_path = self.get_json_body()["top_repo_path"]
420417
my_output = self.git.add_all_untracked(top_repo_path)
421-
print(my_output)
422418
self.finish(my_output)
423419

424420
class GitChangedFilesHandler(GitHandler):

jupyterlab_git/tests/test_handlers.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from jupyterlab_git.handlers import (
55
GitAllHistoryHandler,
66
GitBranchHandler,
7+
GitLogHandler,
78
GitPushHandler,
89
GitUpstreamHandler,
910
setup_handlers
@@ -120,6 +121,38 @@ def test_branch_handler_localbranch(mock_finish, mock_git):
120121
'branches': branch['branches']
121122
}))
122123

124+
@patch('jupyterlab_git.handlers.GitLogHandler.__init__', Mock(return_value=None))
125+
@patch('jupyterlab_git.handlers.GitLogHandler.get_json_body', Mock(return_value={'current_path': 'test_path', 'history_count': 20}))
126+
@patch('jupyterlab_git.handlers.GitLogHandler.git')
127+
@patch('jupyterlab_git.handlers.GitLogHandler.finish')
128+
def test_log_handler(mock_finish, mock_git):
129+
# Given
130+
log = {'code': 0, 'commits': []}
131+
mock_git.log.return_value = log
132+
133+
# When
134+
GitLogHandler().post()
135+
136+
# Then
137+
mock_git.log.assert_called_with('test_path', 20)
138+
mock_finish.assert_called_with(json.dumps(log))
139+
140+
141+
@patch('jupyterlab_git.handlers.GitLogHandler.__init__', Mock(return_value=None))
142+
@patch('jupyterlab_git.handlers.GitLogHandler.get_json_body', Mock(return_value={'current_path': 'test_path'}))
143+
@patch('jupyterlab_git.handlers.GitLogHandler.git')
144+
@patch('jupyterlab_git.handlers.GitLogHandler.finish')
145+
def test_log_handler_no_history_count(mock_finish, mock_git):
146+
# Given
147+
log = {'code': 0, 'commits': []}
148+
mock_git.log.return_value = log
149+
150+
# When
151+
GitLogHandler().post()
152+
153+
# Then
154+
mock_git.log.assert_called_with('test_path', 25)
155+
mock_finish.assert_called_with(json.dumps(log))
123156

124157

125158
@patch('jupyterlab_git.handlers.GitPushHandler.__init__', Mock(return_value=None))

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"build:lib": "tsc",
1818
"build:all": "jlpm run build:labextension",
1919
"clean": "jlpm run clean:lib",
20-
"clean:lib": "rimraf lib",
20+
"clean:lib": "rimraf lib && rimraf tsconfig.tsbuildinfo",
2121
"clean:labextension": "rimraf jupyterlab_git/labextension",
2222
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
2323
"prepare": "jlpm run clean && jlpm run build",
@@ -68,6 +68,8 @@
6868
"devDependencies": {
6969
"@babel/core": "^7.5.0",
7070
"@babel/preset-env": "^7.5.0",
71+
"@jupyterlab/testutils": "^1.1.0",
72+
"@types/codemirror": "^0.0.79",
7173
"@types/enzyme": "3.1.15",
7274
"@types/jest": "^24",
7375
"@types/react": "~16.8.13",

0 commit comments

Comments
 (0)