Skip to content

Commit 2d186cd

Browse files
basokantfcollonval
andauthored
Fix files changed and reverting merge commits from the history panel bug (#1227)
* account for merge commit logs when retrieving the detailed log for a commit, as they have an extra line for the branch that was merged into the base branch * add --cc option for detailed logging * fix reverting merge commits, assuming the mainline branch is the first parent * change test to reflect changes to detailed log * correct detailed logger handler comment to include --cc -z * init merge commit integration test * add @jupyterlab/galata and @playwright/test * finish merge commit integration test 1 * finish merge commit integration test 2 * finish merge commit integration test 3 * finish merge commit integration test 4 (revert merge commit) * fix multiple installations of @playwright/test and upgrade @playwright/test dependency * complete final working ui-tests for merge commits * Bump nodejs * fix jest config * Fake crypto using node:crypto * Fix node crypto import * Use nodejs 16 on Binder * fix selecting mergeCommit in playwright tests --------- Co-authored-by: Frédéric Collonval <fcollonval@gmail.com> Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
1 parent 91c3073 commit 2d186cd

File tree

13 files changed

+2519
-2046
lines changed

13 files changed

+2519
-2046
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ jobs:
1515
python-version: ['3.7', '3.8', '3.9', '3.10']
1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v3
1919
- name: Install node
2020
uses: actions/setup-node@v1
2121
with:
22-
node-version: '14.x'
22+
node-version: '18.x'
2323
- name: Setup Python ${{ matrix.python-version }}
2424
uses: actions/setup-python@v2
2525
with:
@@ -101,11 +101,11 @@ jobs:
101101

102102
steps:
103103
- name: Checkout
104-
uses: actions/checkout@v2
104+
uses: actions/checkout@v3
105105
- name: Install node
106106
uses: actions/setup-node@v1
107107
with:
108-
node-version: '14.x'
108+
node-version: '18.x'
109109
- uses: actions/download-artifact@v2
110110
with:
111111
name: extension

binder/environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
- python >=3.8,<3.9.0a0
1515
- jupyterlab >=3,<4.0.0a0
1616
# labextension build dependencies
17-
- nodejs >=14,<15
17+
- nodejs >=16,<17
1818
- pip
1919
- wheel
2020
# additional packages for demos

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ tsOptions['inlineSourceMap'] = true;
77

88
const esModules = [
99
'.*@jupyterlab/',
10+
'@jupyter/ydoc',
1011
'lib0',
1112
'y\\-protocols',
1213
'y\\-websocket',

jupyterlab_git/git.py

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,16 @@ async def log(self, path, history_count=10, follow_path=None):
567567

568568
async def detailed_log(self, selected_hash, path):
569569
"""
570-
Execute git log -1 --numstat --oneline -z command (used to get
570+
Execute git log -m --cc -1 --numstat --oneline -z command (used to get
571571
insertions & deletions per file) & return the result.
572572
"""
573573
cmd = [
574574
"git",
575575
"log",
576+
"--cc",
577+
"-m",
576578
"-1",
579+
"--oneline",
577580
"--numstat",
578581
"--pretty=format:%b%x00",
579582
"-z",
@@ -596,35 +599,38 @@ async def detailed_log(self, selected_hash, path):
596599
for line in line_iterable:
597600
is_binary = line.startswith("-\t-\t")
598601
previous_file_path = ""
599-
insertions, deletions, file = line.split("\t")
600-
insertions = insertions.replace("-", "0")
601-
deletions = deletions.replace("-", "0")
602-
603-
if file == "":
604-
# file was renamed or moved, we need next two lines of output
605-
from_path = next(line_iterable)
606-
to_path = next(line_iterable)
607-
previous_file_path = from_path
608-
modified_file_name = from_path + " => " + to_path
609-
modified_file_path = to_path
610-
else:
611-
modified_file_name = file.split("/")[-1]
612-
modified_file_path = file
613-
614-
file_info = {
615-
"modified_file_path": modified_file_path,
616-
"modified_file_name": modified_file_name,
617-
"insertion": insertions,
618-
"deletion": deletions,
619-
"is_binary": is_binary,
620-
}
602+
tokens = line.split("\t")
603+
604+
if len(tokens) == 3:
605+
insertions, deletions, file = line.split("\t")
606+
insertions = insertions.replace("-", "0")
607+
deletions = deletions.replace("-", "0")
608+
609+
if file == "":
610+
# file was renamed or moved, we need next two lines of output
611+
from_path = next(line_iterable)
612+
to_path = next(line_iterable)
613+
previous_file_path = from_path
614+
modified_file_name = from_path + " => " + to_path
615+
modified_file_path = to_path
616+
else:
617+
modified_file_name = file.split("/")[-1]
618+
modified_file_path = file
619+
620+
file_info = {
621+
"modified_file_path": modified_file_path,
622+
"modified_file_name": modified_file_name,
623+
"insertion": insertions,
624+
"deletion": deletions,
625+
"is_binary": is_binary,
626+
}
621627

622-
if previous_file_path:
623-
file_info["previous_file_path"] = previous_file_path
628+
if previous_file_path:
629+
file_info["previous_file_path"] = previous_file_path
624630

625-
result.append(file_info)
626-
total_insertions += int(insertions)
627-
total_deletions += int(deletions)
631+
result.append(file_info)
632+
total_insertions += int(insertions)
633+
total_deletions += int(deletions)
628634

629635
modified_file_note = "{num_files} files changed, {insertions} insertions(+), {deletions} deletions(-)".format(
630636
num_files=len(result),
@@ -930,7 +936,7 @@ async def delete_commit(self, commit_id, path):
930936
"""
931937
Delete a specified commit from the repository.
932938
"""
933-
cmd = ["git", "revert", "--no-commit", commit_id]
939+
cmd = ["git", "revert", "-m", "1", "--no-commit", commit_id]
934940
code, _, error = await execute(cmd, cwd=path)
935941

936942
if code != 0:

jupyterlab_git/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ async def post(self, path: str = ""):
245245

246246
class GitDetailedLogHandler(GitHandler):
247247
"""
248-
Handler for 'git log -1 --stat --numstat --oneline' command.
248+
Handler for 'git log -m --cc -1 --stat --numstat --oneline -z' command.
249249
Fetches file names of committed files, Number of insertions &
250250
deletions in that commit.
251251
"""

jupyterlab_git/tests/test_detailed_log.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ async def test_detailed_log():
101101
[
102102
"git",
103103
"log",
104+
"--cc",
105+
"-m",
104106
"-1",
107+
"--oneline",
105108
"--numstat",
106109
"--pretty=format:%b%x00",
107110
"-z",

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"@jupyterlab/coreutils": "^5.0.0",
5656
"@jupyterlab/docregistry": "^3.0.0",
5757
"@jupyterlab/filebrowser": "^3.0.0",
58+
"@jupyterlab/galata": "^4.5.2",
5859
"@jupyterlab/mainmenu": "^3.0.0",
5960
"@jupyterlab/nbformat": "^3.0.0",
6061
"@jupyterlab/rendermime": "^3.0.0",
@@ -74,6 +75,7 @@
7475
"@material-ui/core": "^4.8.2",
7576
"@material-ui/icons": "^4.5.1",
7677
"@material-ui/lab": "^4.0.0-alpha.54",
78+
"@playwright/test": "^1.32.1",
7779
"diff-match-patch": "^1.0.4",
7880
"nbdime": "^6.1.1",
7981
"nbdime-jupyterlab": "^2.1.0",

testutils/jest-setup-files.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
global.fetch = require('jest-fetch-mock');
1+
globalThis.fetch = require('jest-fetch-mock');
2+
// Use node crypto for crypto
3+
globalThis.crypto = require('crypto');
4+
25
require("enzyme").configure({
36
adapter: new (require('@wojtekmaj/enzyme-adapter-react-17'))
4-
});
7+
});

ui-tests/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"test": "playwright test"
88
},
99
"devDependencies": {
10-
"@jupyterlab/galata": "^4.1.0",
11-
"@playwright/test": "^1.17.0"
10+
"@jupyterlab/galata": "^4.5.3"
1211
}
1312
}
Binary file not shown.

0 commit comments

Comments
 (0)