Skip to content

Add bonsai-tree #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2025
Merged
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions bonsai_tree/.gitmastery-exercise.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"exercise_name": "bonsai-tree",
"tags": [
"git-branch",
"git-checkout"
],
"requires_git": true,
"requires_github": false,
"base_files": {},
"exercise_repo": {
"repo_type": "local",
"repo_name": "care-notes",
"repo_title": null,
"create_fork": null,
"init": true
}
}
28 changes: 28 additions & 0 deletions bonsai_tree/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# bonsai-tree

You are an aspiring botanist and you are starting to take notes of the various botany facts related to [bonsai trees]()

## Task

Create a new file titled `dangers-to-bonsais.txt` on the `main` branch with the following text:

```text
Bonsai trees are delicate and vulnerable to threats like overwatering, pests, fungal infections, and extreme temperatures. Poor pruning or wiring can cause lasting damage, while dehydration and root rot are common killers. Without careful maintenance, these miniature trees can quickly decline.
```

Create a new branch `history` and add another file `history-of-bonsais.txt` with the following text:

```text
Bonsai originated in China over a thousand years ago as "penjing," the art of miniature landscape cultivation. The practice later spread to Japan, where it evolved into the refined bonsai we know today, emphasizing simplicity, balance, and harmony with nature. Traditionally associated with Zen Buddhism, bonsai became a symbol of patience and artistic expression. Over time, it gained global popularity, with enthusiasts worldwide cultivating these miniature trees as a blend of horticulture and art.
```

Finally, create a final branch that goes off of `history` called `care` and edit the empty `bonsai-care.txt` file with the following text:

```text
Proper bonsai care involves balancing water, light, and nutrients to maintain a healthy tree. Bonsais require well-draining soil and regular watering, but overwatering can lead to root rot. They need adequate sunlight, with indoor varieties thriving near bright windows and outdoor species requiring seasonal adjustments. Pruning and wiring help shape the tree, while repotting every few years ensures root health. Protecting bonsais from pests, extreme temperatures, and diseases is essential for their longevity, making their care both an art and a discipline.
```

Ultimately, your Git tree should look like this:

![Expected tree](./res/expected-tree.png)

Empty file added bonsai_tree/__init__.py
Empty file.
32 changes: 32 additions & 0 deletions bonsai_tree/download.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import subprocess
from sys import exit
from typing import List, Optional

__resources__ = {"bonsai-care.txt": "bonsai-care.txt"}


def run_command(command: List[str], verbose: bool) -> Optional[str]:
try:
result = subprocess.run(
command,
capture_output=True,
text=True,
check=True,
)
if verbose:
print(result.stdout)
return result.stdout
except subprocess.CalledProcessError as e:
if verbose:
print(e.stderr)
exit(1)


def setup(verbose: bool = False):
commits_str = run_command(
["git", "log", "--reverse", "--pretty=format:%h"], verbose
)
assert commits_str is not None
first_commit = commits_str.split("\n")[0]
tag_name = f"git-mastery-start-{first_commit}"
run_command(["git", "tag", tag_name], verbose)
Empty file added bonsai_tree/res/bonsai-care.txt
Empty file.
Binary file added bonsai_tree/res/expected-tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added bonsai_tree/tests/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions bonsai_tree/tests/specs/base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
initialization:
steps:
- type: commit
empty: true
message: Empty commit
id: start
44 changes: 44 additions & 0 deletions bonsai_tree/tests/specs/bonsai-tree.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
initialization:
steps:
- type: new-file
filename: bonsai-care.txt
contents:
- type: add
files:
- bonsai-care.txt
- type: commit
message: Start
id: start
- type: new-file
filename: dangers-to-bonsais.txt
contents: |
Bonsai trees are delicate and vulnerable to threats like overwatering, pests, fungal infections, and extreme temperatures. Poor pruning or wiring can cause lasting damage, while dehydration and root rot are common killers. Without careful maintenance, these miniature trees can quickly decline.
- type: add
files:
- dangers-to-bonsais.txt
- type: commit
message: Add dangers
- type: branch
branch-name: history
- type: new-file
filename: history-of-bonsais.txt
contents: |
Bonsai originated in China over a thousand years ago as "penjing," the art of miniature landscape cultivation. The practice later spread to Japan, where it evolved into the refined bonsai we know today, emphasizing simplicity, balance, and harmony with nature. Traditionally associated with Zen Buddhism, bonsai became a symbol of patience and artistic expression. Over time, it gained global popularity, with enthusiasts worldwide cultivating these miniature trees as a blend of horticulture and art.
- type: add
files:
- history-of-bonsais.txt
- type: commit
message: Add history
- type: branch
branch-name: care
- type: edit-file
filename: bonsai-care.txt
contents: |
Proper bonsai care involves balancing water, light, and nutrients to maintain a healthy tree. Bonsais require well-draining soil and regular watering, but overwatering can lead to root rot. They need adequate sunlight, with indoor varieties thriving near bright windows and outdoor species requiring seasonal adjustments. Pruning and wiring help shape the tree, while repotting every few years ensures root health. Protecting bonsais from pests, extreme temperatures, and diseases is essential for their longevity, making their care both an art and a discipline.
- type: add
files:
- bonsai-care.txt
- type: commit
message: Add bonsai care
- type: checkout
branch-name: main
44 changes: 44 additions & 0 deletions bonsai_tree/tests/specs/invalid-care.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
initialization:
steps:
- type: new-file
filename: bonsai-care.txt
contents:
- type: add
files:
- bonsai-care.txt
- type: commit
message: Start
id: start
- type: new-file
filename: dangers-to-bonsais.txt
contents: |
Bonsai trees are delicate and vulnerable to threats like overwatering, pests, fungal infections, and extreme temperatures. Poor pruning or wiring can cause lasting damage, while dehydration and root rot are common killers. Without careful maintenance, these miniature trees can quickly decline.
- type: add
files:
- dangers-to-bonsais.txt
- type: commit
message: Add dangers
- type: branch
branch-name: history
- type: new-file
filename: history-of-bonsais.txt
contents: |
Bonsai originated in China over a thousand years ago as "penjing," the art of miniature landscape cultivation. The practice later spread to Japan, where it evolved into the refined bonsai we know today, emphasizing simplicity, balance, and harmony with nature. Traditionally associated with Zen Buddhism, bonsai became a symbol of patience and artistic expression. Over time, it gained global popularity, with enthusiasts worldwide cultivating these miniature trees as a blend of horticulture and art.
- type: add
files:
- history-of-bonsais.txt
- type: commit
message: Add history
- type: branch
branch-name: care
- type: edit-file
filename: bonsai-care.txt
contents: |
bonsai care involves balancing water, light, and nutrients to maintain a healthy tree. Bonsais require well-draining soil and regular watering, but overwatering can lead to root rot. They need adequate sunlight, with indoor varieties thriving near bright windows and outdoor species requiring seasonal adjustments. Pruning and wiring help shape the tree, while repotting every few years ensures root health. Protecting bonsais from pests, extreme temperatures, and diseases is essential for their longevity, making their care both an art and a discipline.
- type: add
files:
- bonsai-care.txt
- type: commit
message: Add bonsai care
- type: checkout
branch-name: main
44 changes: 44 additions & 0 deletions bonsai_tree/tests/specs/invalid-history.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
initialization:
steps:
- type: new-file
filename: bonsai-care.txt
contents:
- type: add
files:
- bonsai-care.txt
- type: commit
message: Start
id: start
- type: new-file
filename: dangers-to-bonsais.txt
contents: |
Bonsai trees are delicate and vulnerable to threats like overwatering, pests, fungal infections, and extreme temperatures. Poor pruning or wiring can cause lasting damage, while dehydration and root rot are common killers. Without careful maintenance, these miniature trees can quickly decline.
- type: add
files:
- dangers-to-bonsais.txt
- type: commit
message: Add dangers
- type: branch
branch-name: history
- type: new-file
filename: history-of-bonsais.txt
contents: |
originated in China over a thousand years ago as "penjing," the art of miniature landscape cultivation. The practice later spread to Japan, where it evolved into the refined bonsai we know today, emphasizing simplicity, balance, and harmony with nature. Traditionally associated with Zen Buddhism, bonsai became a symbol of patience and artistic expression. Over time, it gained global popularity, with enthusiasts worldwide cultivating these miniature trees as a blend of horticulture and art.
- type: add
files:
- history-of-bonsais.txt
- type: commit
message: Add history
- type: branch
branch-name: care
- type: edit-file
filename: bonsai-care.txt
contents: |
Proper bonsai care involves balancing water, light, and nutrients to maintain a healthy tree. Bonsais require well-draining soil and regular watering, but overwatering can lead to root rot. They need adequate sunlight, with indoor varieties thriving near bright windows and outdoor species requiring seasonal adjustments. Pruning and wiring help shape the tree, while repotting every few years ensures root health. Protecting bonsais from pests, extreme temperatures, and diseases is essential for their longevity, making their care both an art and a discipline.
- type: add
files:
- bonsai-care.txt
- type: commit
message: Add bonsai care
- type: checkout
branch-name: main
39 changes: 39 additions & 0 deletions bonsai_tree/tests/specs/invalid_dangers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
initialization:
steps:
- type: commit
empty: true
message: Start commit
id: start
- type: new-file
filename: dangers-to-bonsais.txt
content: |
trees are delicate and vulnerable to threats like overwatering, pests, fungal infections, and extreme temperatures. Poor pruning or wiring can cause lasting damage, while dehydration and root rot are common killers. Without careful maintenance, these miniature trees can quickly decline.
- type: add
files:
- dangers-to-bonsais.txt
- type: commit
message: Add dangers
- type: branch
branch-name: history
- type: new-file
filename: history-of-bonsais.txt
contents: |
Bonsai originated in China over a thousand years ago as "penjing," the art of miniature landscape cultivation. The practice later spread to Japan, where it evolved into the refined bonsai we know today, emphasizing simplicity, balance, and harmony with nature. Traditionally associated with Zen Buddhism, bonsai became a symbol of patience and artistic expression. Over time, it gained global popularity, with enthusiasts worldwide cultivating these miniature trees as a blend of horticulture and art.
- type: add
files:
- history-of-bonsais.txt
- type: commit
message: Add history
- type: branch
branch-name: care
- type: new-file
filename: bonsai-care.txt
contents: |
Proper bonsai care involves balancing water, light, and nutrients to maintain a healthy tree. Bonsais require well-draining soil and regular watering, but overwatering can lead to root rot. They need adequate sunlight, with indoor varieties thriving near bright windows and outdoor species requiring seasonal adjustments. Pruning and wiring help shape the tree, while repotting every few years ensures root health. Protecting bonsais from pests, extreme temperatures, and diseases is essential for their longevity, making their care both an art and a discipline.
- type: add
files:
- bonsai-care.txt
- type: commit
message: Add bonsai care
- type: checkout
branch-name: main
38 changes: 38 additions & 0 deletions bonsai_tree/tests/specs/missing-care.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
initialization:
steps:
- type: new-file
filename: bonsai-care.txt
contents:
- type: add
files:
- bonsai-care.txt
- type: commit
message: Start
id: start
- type: new-file
filename: dangers-to-bonsais.txt
contents: |
Bonsai trees are delicate and vulnerable to threats like overwatering, pests, fungal infections, and extreme temperatures. Poor pruning or wiring can cause lasting damage, while dehydration and root rot are common killers. Without careful maintenance, these miniature trees can quickly decline.
- type: add
files:
- dangers-to-bonsais.txt
- type: commit
message: Add dangers
- type: branch
branch-name: history
- type: new-file
filename: history-of-bonsais.txt
contents: |
Bonsai originated in China over a thousand years ago as "penjing," the art of miniature landscape cultivation. The practice later spread to Japan, where it evolved into the refined bonsai we know today, emphasizing simplicity, balance, and harmony with nature. Traditionally associated with Zen Buddhism, bonsai became a symbol of patience and artistic expression. Over time, it gained global popularity, with enthusiasts worldwide cultivating these miniature trees as a blend of horticulture and art.
- type: add
files:
- history-of-bonsais.txt
- type: commit
message: Add history
- type: branch
branch-name: care
- type: commit
empty: true
message: Not adding bonsai care
- type: checkout
branch-name: main
26 changes: 26 additions & 0 deletions bonsai_tree/tests/specs/missing_care_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
initialization:
steps:
- type: commit
empty: true
message: Start commit
id: start
- type: new-file
filename: dangers-to-bonsais.txt
contents: |
Bonsai trees are delicate and vulnerable to threats like overwatering, pests, fungal infections, and extreme temperatures. Poor pruning or wiring can cause lasting damage, while dehydration and root rot are common killers. Without careful maintenance, these miniature trees can quickly decline.
- type: add
files:
- dangers-to-bonsais.txt
- type: commit
message: Add dangers
- type: branch
branch-name: history
- type: new-file
filename: history-of-bonsais.txt
contents: |
Bonsai originated in China over a thousand years ago as "penjing," the art of miniature landscape cultivation. The practice later spread to Japan, where it evolved into the refined bonsai we know today, emphasizing simplicity, balance, and harmony with nature. Traditionally associated with Zen Buddhism, bonsai became a symbol of patience and artistic expression. Over time, it gained global popularity, with enthusiasts worldwide cultivating these miniature trees as a blend of horticulture and art.
- type: add
files:
- history-of-bonsais.txt
- type: commit
message: Add history
33 changes: 33 additions & 0 deletions bonsai_tree/tests/specs/missing_dangers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
initialization:
steps:
- type: commit
empty: true
message: Start commit
id: start
- type: commit
empty: true
message: Dummy commit
- type: branch
branch-name: history
- type: new-file
filename: history-of-bonsais.txt
contents: |
Bonsai originated in China over a thousand years ago as "penjing," the art of miniature landscape cultivation. The practice later spread to Japan, where it evolved into the refined bonsai we know today, emphasizing simplicity, balance, and harmony with nature. Traditionally associated with Zen Buddhism, bonsai became a symbol of patience and artistic expression. Over time, it gained global popularity, with enthusiasts worldwide cultivating these miniature trees as a blend of horticulture and art.
- type: add
files:
- history-of-bonsais.txt
- type: commit
message: Add history
- type: branch
branch-name: care
- type: new-file
filename: bonsai-care.txt
contents: |
Proper bonsai care involves balancing water, light, and nutrients to maintain a healthy tree. Bonsais require well-draining soil and regular watering, but overwatering can lead to root rot. They need adequate sunlight, with indoor varieties thriving near bright windows and outdoor species requiring seasonal adjustments. Pruning and wiring help shape the tree, while repotting every few years ensures root health. Protecting bonsais from pests, extreme temperatures, and diseases is essential for their longevity, making their care both an art and a discipline.
- type: add
files:
- bonsai-care.txt
- type: commit
message: Add bonsai care
- type: checkout
branch-name: main
33 changes: 33 additions & 0 deletions bonsai_tree/tests/specs/missing_history.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
initialization:
steps:
- type: commit
empty: true
message: Empty
id: start
- type: new-file
filename: dangers-to-bonsais.txt
contents: |
Bonsai trees are delicate and vulnerable to threats like overwatering, pests, fungal infections, and extreme temperatures. Poor pruning or wiring can cause lasting damage, while dehydration and root rot are common killers. Without careful maintenance, these miniature trees can quickly decline.
- type: add
files:
- dangers-to-bonsais.txt
- type: commit
message: Add dangers
- type: branch
branch-name: history
- type: commit
empty: true
message: Not adding history
- type: branch
branch-name: care
- type: new-file
filename: bonsai-care.txt
contents: |
Proper bonsai care involves balancing water, light, and nutrients to maintain a healthy tree. Bonsais require well-draining soil and regular watering, but overwatering can lead to root rot. They need adequate sunlight, with indoor varieties thriving near bright windows and outdoor species requiring seasonal adjustments. Pruning and wiring help shape the tree, while repotting every few years ensures root health. Protecting bonsais from pests, extreme temperatures, and diseases is essential for their longevity, making their care both an art and a discipline.
- type: add
files:
- bonsai-care.txt
- type: commit
message: Add bonsai care
- type: checkout
branch-name: main
Loading