Skip to content

Conversation

@oadultradeepfield
Copy link

Exercise Discussion

This PR will close #56. Below is a more detailed description of the changes along with implementation notes:

  1. Added an add_origin function in exercise_utils/git.py. This might be helpful in the future. I noticed that there is already a remove_remote implementation, and add_origin is intended to be used in a similar way.
  2. To help ensure that the remote repository gitmastery-things is created successfully across multiple attempts, I added a check to delete any existing remote repository with the same name. Please note that this requires setting up delete access for the GitHub CLI via gh auth refresh -h github.com -s delete_repo. I also realised that the GitHub CLI needs to be configured beforehand for this part of the hands-on to work.

Note: The download script tested via test-download.sh works fine. Here is the remote repo I managed to create.

Checklist

  • If you require a new remote repository on the Git-Mastery organization, have you created a request for it?
  • Have you written unit tests using repo-smith to validate the exercise grading scheme?
  • Have you tested the download script using test-download.sh?
  • Have you verified that this exercise does not already exist or is not currently in review?
  • Did you introduce a new grading mechanism that should belong to git-autograder?
  • Did you introduce a new dependency that should belong to app?

Copy link
Member

@woojiahao woojiahao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't an easy hands-on to implement because we have remote integration. Left a couple of comments on structuring the hands-on!

Please note that this requires setting up delete access for the GitHub CLI via gh auth refresh -h github.com -s delete_repo.

@damithc are we able to include this in our setup guide if it's not yet included?

I also realised that the GitHub CLI needs to be configured beforehand for this part of the hands-on to work.

This is already supported when you do __require_github__ = True: https://git-mastery.github.io/developers/docs/architecture/hands-on-structure/#file-structure

Comment on lines 23 to 25
_create_and_commit_fruits_file(verbose)
_update_fruits_file(verbose)
_add_additional_files(verbose)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am inclined to oppose to overly abstracting these functions. They do not really need to belong to individual functions at the moment, and the term add_additional_files is not particularly informative for our use case.

We can consider flattening out these functions first, and if we notice a use case for having modularized functions, we can do so in a follow-up PR! What do you think? @oadultradeepfield

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the structure I'm thinking is:

download: setup_local_repository -> create_things_repository -> link_things_repository

And then

setup_local_repository: all behavior in the same function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree! This hands-on .py file does feel a bit too abstracted for its own good. Keeping the structure you suggested makes the most sense, as it meets a nice balance and keeps the abstraction layer meaningful.

We can consider flattening out these functions first, and if we notice a use case for having modularized functions, we can do so in a follow-up PR! What do you think? @oadultradeepfield

I also took a look at some other hands-on issues, and it seems this setup pattern is quite common across them. This one’s pretty similar to #55 as well. So I still believe that the abstractions are useful, just maybe something to refine in a future PR, once modularisation brings clearer benefits (and less head-scratching 😅).



def _link_repositories(verbose: bool):
full_repo_name = _get_full_repo_name(verbose)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can likely move this inline with this function. The function to get the full repo name is not used anywhere else

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@woojiahao, it is actually used here as well. Is it okay to keep as is?

@oadultradeepfield
Copy link
Author

Thanks for the super-detailed comments! I’ll make the corresponding changes later today.

This is already supported when you do require_github = True: https://git-mastery.github.io/developers/docs/architecture/hands-on-structure/#file-structure

Sorry for the confusion, what I meant was that students need to have the GitHub CLI installed for the gh commands to work. I think it’s just an issue on my device since I haven’t used it before 😅.

@damithc
Copy link
Contributor

damithc commented Oct 26, 2025

Please note that this requires setting up delete access for the GitHub CLI via gh auth refresh -h github.com -s delete_repo.

@damithc are we able to include this in our setup guide if it's not yet included?

Given having to delete a remote repo is rare, instead of deleting the repo automatically, a safer alternative is to abort with a message asking the student to delete the repo and run the download operation again after doing so.
WDYT?

@oadultradeepfield
Copy link
Author

Given having to delete a remote repo is rare, instead of deleting the repo automatically, a safer alternative is to abort with a message asking the student to delete the repo and run the download operation again after doing so. WDYT?

I agree with this approach! If I understand correctly, this would mean the Python script in this repo should raise exceptions that the app’s download.py can then catch and print user-friendly messages, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Hands-On Discussion] T2L5/hp-populate-remote (Pushing a local repo to an empty emote repo)

3 participants