Pull Request Workflow with Git and Copilot
Learn how to add pull request with Git and Copilot.
You’ve joined a development team working on a web service. Your next task is to create a slugify(text)
helper that converts titles like "Hello, World!"
into clean, SEO-friendly URLs like hello-world
. In this lesson, you’ll simulate the complete pull request workflow developers use to ship features in real projects.
You will:
Write the
slugify
function locally.Use GitHub Copilot to draft your commit message and pull request (PR) description.
Push your work and open a PR.
Once the PR is open, you’ll switch roles to the reviewer. You’ll pull the latest code, ask Copilot to generate tests using pytest
, and push those tests back to the same PR.
Finally, you’ll request a Copilot review. Copilot will suggest improvements, which you’ll review, apply at least one, and complete the merge.
Throughout this process, you’ll use six essential Git commands:
git statusgit addgit commitgit pushgit pullgit branch
This exercise is designed to give you practical experience with GitHub Copilot, Git workflows, and team collaboration—exactly how modern software teams work. Let’s dive in.
The author adds slugify
locally
Now that you understand the scenario, it’s time to start coding as the junior developer.
Write the code
Open your app.py
file and write the slugify
function. This helper will turn a string like "Hello, World!"
into hello-world
, a format that works well for SEO-friendly URLs.
Here’s the code you’ll write:
import redef slugify(text: str) -> str:"""Convert *text* into a lowercase dash-separated slug.Keeps alphanumerics, converts spaces & punctuation to '-',collapses consecutive dashes."""text = text.lower()text = re.sub(r"[^a-z0-9]+", "-", text)return re.sub(r"-{2,}", "-", text).strip("-")
This function does three things:
Converts the text to lowercase.
Replaces all non-alphanumeric characters with dashes.
Collapses consecutive dashes into one and trims extra dashes at the ends.
Stage and commit the changes with Copilot
Once your code is ready, you’ll move to your terminal to prepare the commit.
Use these Git commands:
git initgit statusgit add app.pygit commit -m "$(gh copilot suggest -m)"
git status
: ...