-
Notifications
You must be signed in to change notification settings - Fork 26
[Exercise: glossary-branch-pull] T8L2. Pulling Branches from a Remote #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Exercise: glossary-branch-pull] T8L2. Pulling Branches from a Remote #242
Conversation
|
Hi @desmondwong1215, thank you for your contribution! 🎉 This PR comes from your fork Before you request for a review, please ensure that you have tested your changes locally! Important The previously recommended way of using Please read the following instructions for the latest instructions. PrerequisitesEnsure that you have the Testing stepsIf you already have a local Git-Mastery root to test, you can skip the following step. Create a Git-Mastery root locally: gitmastery setupNavigate into the Git-Mastery root (defaults to cd gitmastery-exercises/Edit the {
# other fields...
"exercises_source": {
"username": "desmondwong1215",
"repository": "exercises",
"branch": "e-glossary-branch-pull"
}
}Then, you can use the gitmastery download <your new change>
gitmastery verifyChecklist
Important To any reviewers of this pull request, please use the same instructions above to test the changes. |
|
@desmondwong1215 Can you indicate by mentioning us when this PR is ready for our review, as it seems you're still working on it? Another method you could use is to mark this PR as a draft until it's ready to be reviewed. |
|
Hi @VikramGoyal23, this PR is ready for review. Thanks |
VikramGoyal23
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM. Just a nit and some minor changes to logic for now, while we wait on the update to repo-smith to support unit tests.
|
|
||
| checkout("DEF", False, verbose) | ||
| run_command(["git", "reset", "--hard", "HEAD~1"], verbose) | ||
| create_or_update_file("e.txt", "documentation: Evidence that someone once cared.\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more idiomatic to use a multiline string here.
| create_or_update_file("e.txt", "documentation: Evidence that someone once cared.\n") | |
| create_or_update_file( | |
| "e.txt", | |
| """ | |
| documentation: Evidence that someone once cared. | |
| """ | |
| ) |
| else: | ||
| def_branch = repo.branches.branch("DEF").branch | ||
| remote_def = def_branch.tracking_branch() | ||
| if remote_def: | ||
| local_commits = set(commit.hexsha for commit in repo.branches.branch("DEF").commits) | ||
| remote_commit_hexsha = remote_def.commit.hexsha | ||
| if remote_commit_hexsha not in local_commits: | ||
| comments.append(COMMIT_MISSING.format(branch="DEF")) | ||
| else: | ||
| comments.append(BRANCH_NOT_TRACKING.format(branch="DEF")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better if we also checked that the student did not, perchance, delete the local commit (since they might take a wrong approach to resolve the merge conflict). You can check the existence of the commit using this function by jovnc:
def get_commit_from_message(
commits: List[GitAutograderCommit], message: str
) -> Optional[GitAutograderCommit]:
"""Find a commit with the given message from a list of commits."""
for commit in commits:
if message.strip() == commit.commit.message.strip():
return commit
return None
Exercise Review
Exercise Discussion
Fixes #237
Checklist
Git-Masteryorganization, have you created a request for it?repo-smithto validate the exercise grading scheme?git-autograder?app?