Joke Generator Pull Request Exercise
Joke Generator Pull Request Exercise
Team Setup (2 people)
- Person A: Repository Owner & Developer
- Person B: Contributor & Developer
Phase 1: Initial Setup (Person A - 5 minutes)
Create a new GitHub repository:
- Name:
joke-generator-[your-names]
- Make it public, initialize with README
Create the base joke_generator.py
:
import random
# Initial joke collection
jokes = [
"Pourquoi les développeurs préfèrent le mode sombre ? Parce que la lumière attire les bugs !",
"Combien de développeurs faut-il pour changer une ampoule ? Aucun, c'est un problème hardware.",
"Pourquoi les développeurs Java portent des lunettes ? Parce qu'ils ne peuvent pas C# !"
]
def print_random_joke():
"""Print a random joke from the collection."""
joke = random.choice(jokes)
print(f"😂 {joke}")
if __name__ == "__main__":
print("Bienvenue au Générateur de Blagues !")
print_random_joke()
Commit and push to GitHub
Share repo URL with Person B
Phase 2: Parallel Development - Merge Conflict Time! (10 minutes)
Person A: Add Dad Jokes Feature
- Create branch:
git switch -c add-dad-jokes
- Your mission:
- Add a new list of dad jokes (blagues de papa) in French (go online to find some, or AI whatever)
- Modify
print_random_joke()
to randomly pick from both programming and dad jokes - Test that it works
- Commit and push the branch
- Merge the branch back to main
Person B: Add Joke Categories Feature
- Fork the original repository
- Clone your fork locally
- Create branch:
git switch -c add-joke-categories
- Your mission:
- Modify
print_random_joke()
to accept a category parameter - Add category labels to the output (like
[PROGRAMMATION]
) - Update the main section to specify which category you’re showing
- Test that it works
- Modify
- Commit and push the branch
- Create Pull Request
Phase 3: Merge Conflict Resolution (10 minutes)
Person A:
- First merge your own branch directly:
git switch main git merge add-dad-jokes git push origin main
- Now try to merge Person B’s PR - CONFLICT! 💥
Both people work together to:
- Understand what each version does
- Decide how to combine both features
- Resolve the conflict to support both dad jokes AND categories
- Test the final solution
Target result: A function that can handle both joke collections AND category filtering.
Phase 4: Next Development Cycle (10 minutes)
Now, that you have made the first merge conflicts, you can try both add more features to the code and merge them again together. or work together on another project.