Skip to content

Commit b46ec95

Browse files
Merge branch 'main' into release-0.9.0
2 parents 8eb5c58 + 1dfec6e commit b46ec95

File tree

10 files changed

+66
-36
lines changed

10 files changed

+66
-36
lines changed

binder/environment.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,4 @@ dependencies:
4343
- sqlite
4444
- pip:
4545
- grader-service==0.5.1
46-
- grader-labextension==0.8.0
47-
46+
- grader-labextension==0.8.2

grader_labextension/api/models/submission.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,27 @@ def user_display_name(self, user_display_name: str):
225225
"""Sets the user_display_name of this Submission.
226226
227227
228+
:param user_display_name: The user_display_name of this Submission.
229+
:type user_display_name: str
230+
"""
231+
232+
self._user_display_name = user_display_name
233+
234+
@property
235+
def user_display_name(self) -> str:
236+
"""Gets the user_display_name of this Submission.
237+
238+
239+
:return: The user_display_name of this Submission.
240+
:rtype: str
241+
"""
242+
return self._user_display_name
243+
244+
@user_display_name.setter
245+
def user_display_name(self, user_display_name: str):
246+
"""Sets the user_display_name of this Submission.
247+
248+
228249
:param user_display_name: The user_display_name of this Submission.
229250
:type user_display_name: str
230251
"""

grader_labextension/handlers/version_control.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ async def put(self, lecture_id: int, assignment_id: int, repo: str):
357357

358358
def _extract_request_params(
359359
self,
360-
) -> (Optional[str], Optional[str], List[str], bool, Optional[str]):
360+
) -> tuple[Optional[str], Optional[str], List[str], bool, Optional[str]]:
361361
sub_id_str = self.get_argument("subid", None)
362362
commit_message = self.get_argument("commit-message", None)
363363
selected_files = self.get_arguments("selected-files")

grader_labextension/services/git.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,23 @@ def undo_commit(self, n: int = 1) -> None:
212212
self._run_command("git gc", cwd=self.path)
213213

214214
def revert(self, commit_hash: str):
215+
"""Revert the repository to a previous commit.
216+
If the commit hash equal the HEAD commit, all local changes will be undone.
217+
Otherwise, the files will be reset to the specified commit.
218+
219+
Args:
220+
commit_hash (str): The hash of the commit to revert to.
221+
"""
215222
self.log.info(f"Reverting to {commit_hash}")
216-
self._run_command(f"git revert --no-commit {commit_hash}..HEAD", cwd=self.path)
217-
self._run_command(
218-
f'git commit -m "reverting to {commit_hash}" --allow-empty', cwd=self.path
219-
)
223+
if commit_hash == self._run_command("git rev-parse HEAD", cwd=self.path).strip():
224+
# If the commit hash is the HEAD commit, all local changes will be undone.
225+
self._run_command("git reset --hard", cwd=self.path)
226+
else:
227+
# If the commit hash is not the HEAD commit, revert to the specified commit and create a new revert commit.
228+
self._run_command(f"git revert --no-commit {commit_hash}..HEAD", cwd=self.path)
229+
self._run_command(
230+
f'git commit -m "reverting to {commit_hash}" --allow-empty', cwd=self.path
231+
)
220232

221233
def is_git(self) -> bool:
222234
"""Check if the directory is a git repository.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "grader-labextension",
3-
"version": "0.8.0",
3+
"version": "0.8.2",
44
"description": "Grader Labextension is a JupyterLab extension to enable automatic grading of assignment notebooks.",
55
"keywords": [
66
"jupyter",

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ classifiers = [
2323
"Programming Language :: Python :: 3.13",
2424
]
2525
dependencies = [
26-
27-
"grader-service>=0.8.1,<0.9",
28-
26+
"grader-service>=0.8.2,<0.9",
2927
"jupyter_server>=2.4.0,<3"
3028
]
3129
dynamic = ["version", "description", "authors", "urls", "keywords"]
@@ -40,7 +38,7 @@ test = [
4038
]
4139

4240
[tool.tbump.version]
43-
current = "0.8.0"
41+
current = "0.8.2"
4442

4543
regex = '''
4644
(?P<major>\d+)

src/model/assignment.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ export interface Assignment {
1818
settings?: AssignmentSettings;
1919
}
2020
export namespace Assignment {
21-
export type StatusEnum = 'created' | 'pushed' | 'released' | 'complete';
2221
export const StatusEnum = {
23-
Created: 'created' as StatusEnum,
24-
Pushed: 'pushed' as StatusEnum,
25-
Released: 'released' as StatusEnum,
26-
Complete: 'complete' as StatusEnum
27-
};
22+
Created: 'created',
23+
Pushed: 'pushed',
24+
Released: 'released',
25+
Complete: 'complete'
26+
} as const;
27+
export type StatusEnum = typeof StatusEnum[keyof typeof StatusEnum];
2828
}
2929

3030

src/model/assignmentDetail.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ export interface AssignmentDetail {
2020
submissions?: Array<Submission>;
2121
}
2222
export namespace AssignmentDetail {
23-
export type StatusEnum = 'created' | 'pushed' | 'released' | 'complete';
2423
export const StatusEnum = {
25-
Created: 'created' as StatusEnum,
26-
Pushed: 'pushed' as StatusEnum,
27-
Released: 'released' as StatusEnum,
28-
Complete: 'complete' as StatusEnum
29-
};
24+
Created: 'created',
25+
Pushed: 'pushed',
26+
Released: 'released',
27+
Complete: 'complete'
28+
} as const;
29+
export type StatusEnum = typeof StatusEnum[keyof typeof StatusEnum];
3030
}
3131

3232

src/model/assignmentSettings.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ export interface AssignmentSettings {
1818
autograde_type?: AssignmentSettings.AutogradeTypeEnum;
1919
}
2020
export namespace AssignmentSettings {
21-
export type AutogradeTypeEnum = 'auto' | 'full_auto' | 'unassisted';
2221
export const AutogradeTypeEnum = {
23-
Auto: 'auto' as AutogradeTypeEnum,
24-
FullAuto: 'full_auto' as AutogradeTypeEnum,
25-
Unassisted: 'unassisted' as AutogradeTypeEnum
26-
};
22+
Auto: 'auto',
23+
FullAuto: 'full_auto',
24+
Unassisted: 'unassisted'
25+
} as const;
26+
export type AutogradeTypeEnum = typeof AutogradeTypeEnum[keyof typeof AutogradeTypeEnum];
2727
}
2828

2929

src/model/remoteFileStatus.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ export interface RemoteFileStatus {
1313
status: RemoteFileStatus.StatusEnum;
1414
}
1515
export namespace RemoteFileStatus {
16-
export type StatusEnum = 'UP_TO_DATE' | 'DIVERGENT' | 'PULL_NEEDED' | 'PUSH_NEEDED' | 'NO_REMOTE_REPO';
1716
export const StatusEnum = {
18-
UpToDate: 'UP_TO_DATE' as StatusEnum,
19-
Divergent: 'DIVERGENT' as StatusEnum,
20-
PullNeeded: 'PULL_NEEDED' as StatusEnum,
21-
PushNeeded: 'PUSH_NEEDED' as StatusEnum,
22-
NoRemoteRepo: 'NO_REMOTE_REPO' as StatusEnum
23-
};
17+
UpToDate: 'UP_TO_DATE',
18+
Divergent: 'DIVERGENT',
19+
PullNeeded: 'PULL_NEEDED',
20+
PushNeeded: 'PUSH_NEEDED',
21+
NoRemoteRepo: 'NO_REMOTE_REPO'
22+
} as const;
23+
export type StatusEnum = typeof StatusEnum[keyof typeof StatusEnum];
2424
}
2525

2626

0 commit comments

Comments
 (0)