Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions hands_on/ignore_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os
from exercise_utils.file import create_or_update_file, append_to_file
from exercise_utils.git import init, add, commit

__requires_git__ = True
__requires_github__ = False

def download(verbose: bool):
os.makedirs("sandbox", exist_ok=True)
os.chdir("sandbox")
init(verbose)

create_or_update_file("README.md", "# Ignore File Hands-on\n")
add(["README.md"], verbose)
commit("chore: init README", verbose)

create_or_update_file(".gitignore", "logs/\n*.tmp\n")
add([".gitignore"], verbose)
commit("chore: add .gitignore for logs/ and *.tmp", verbose)

create_or_update_file("notes.txt", "keep me tracked\n")
add(["notes.txt"], verbose)
commit("feat: add tracked notes.txt", verbose)

os.makedirs("logs", exist_ok=True)
create_or_update_file("logs/run.log", "this should be ignored\n")
create_or_update_file("temp.tmp", "also ignored by pattern\n")

append_to_file("notes.txt", "new line not committed yet\n")