From 3f000ca9151a4c52b4bfb4712e0854d3fb83d5d7 Mon Sep 17 00:00:00 2001 From: MousseDm Date: Mon, 27 Oct 2025 15:59:43 +0800 Subject: [PATCH 1/2] Hands-on(ignore-file): add sandbox for ignore file --- hands_on/ignore_file.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 hands_on/ignore_file.py diff --git a/hands_on/ignore_file.py b/hands_on/ignore_file.py new file mode 100644 index 0000000..73879af --- /dev/null +++ b/hands_on/ignore_file.py @@ -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") From 80c3417f1b2cb60cb5deddf3938dd007311dae27 Mon Sep 17 00:00:00 2001 From: MousseDm Date: Mon, 10 Nov 2025 10:11:26 +0800 Subject: [PATCH 2/2] Modify script to fit issue description --- hands_on/ignore_file.py | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/hands_on/ignore_file.py b/hands_on/ignore_file.py index 73879af..c9e2c09 100644 --- a/hands_on/ignore_file.py +++ b/hands_on/ignore_file.py @@ -1,29 +1,16 @@ import os -from exercise_utils.file import create_or_update_file, append_to_file -from exercise_utils.git import init, add, commit +from exercise_utils.file import create_or_update_file +from exercise_utils.git import init __requires_git__ = True __requires_github__ = False def download(verbose: bool): - os.makedirs("sandbox", exist_ok=True) - os.chdir("sandbox") + os.makedirs("stuff", exist_ok=True) + os.chdir("stuff") 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") + create_or_update_file("keep.txt", "good stuff\n") + create_or_update_file("temp.txt", "temp stuff\n") + create_or_update_file("file1.tmp", "more temp stuff\n") + create_or_update_file("file2.tmp", "even more temp stuff\n") \ No newline at end of file