Skip to content

Commit 3f000ca

Browse files
committed
Hands-on(ignore-file): add sandbox for ignore file
1 parent b13523c commit 3f000ca

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

hands_on/ignore_file.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
from exercise_utils.file import create_or_update_file, append_to_file
3+
from exercise_utils.git import init, add, commit
4+
5+
__requires_git__ = True
6+
__requires_github__ = False
7+
8+
def download(verbose: bool):
9+
os.makedirs("sandbox", exist_ok=True)
10+
os.chdir("sandbox")
11+
init(verbose)
12+
13+
create_or_update_file("README.md", "# Ignore File Hands-on\n")
14+
add(["README.md"], verbose)
15+
commit("chore: init README", verbose)
16+
17+
create_or_update_file(".gitignore", "logs/\n*.tmp\n")
18+
add([".gitignore"], verbose)
19+
commit("chore: add .gitignore for logs/ and *.tmp", verbose)
20+
21+
create_or_update_file("notes.txt", "keep me tracked\n")
22+
add(["notes.txt"], verbose)
23+
commit("feat: add tracked notes.txt", verbose)
24+
25+
os.makedirs("logs", exist_ok=True)
26+
create_or_update_file("logs/run.log", "this should be ignored\n")
27+
create_or_update_file("temp.tmp", "also ignored by pattern\n")
28+
29+
append_to_file("notes.txt", "new line not committed yet\n")

0 commit comments

Comments
 (0)