seed: curriculum content
This commit is contained in:
45
1.solar-system/1.welcome/15.the-cloner/index.md
Normal file
45
1.solar-system/1.welcome/15.the-cloner/index.md
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
type: challenge
|
||||
title: "The Cloner"
|
||||
xp: 75
|
||||
duration: 25
|
||||
difficulty: 3
|
||||
---
|
||||
|
||||
# The Cloner
|
||||
|
||||
> **[INCOMING — Mission Control, Earth]**
|
||||
>
|
||||
> Cadet, real work doesn't start from scratch. You join an existing
|
||||
> project — clone it, make changes, commit.
|
||||
>
|
||||
> When your script runs, `remote.git` is a *bare repository* (think
|
||||
> of it as a project living on a server) sitting in your working
|
||||
> directory. Clone it into a folder called `project`:
|
||||
>
|
||||
> ```bash
|
||||
> git clone remote.git project
|
||||
> ```
|
||||
>
|
||||
> Then inside it, set your identity (Git won't let you commit
|
||||
> without one), create `log-entry.txt` containing exactly
|
||||
> `Cadet log entry — checked in.`, and commit with message
|
||||
> `add cadet log entry`.
|
||||
>
|
||||
> [END TRANSMISSION]
|
||||
|
||||
## Your Task
|
||||
|
||||
In `starter/starter.sh`:
|
||||
|
||||
1. Clone `remote.git` into `project`
|
||||
2. `cd project`
|
||||
3. Set `user.name` and `user.email`
|
||||
4. Create `log-entry.txt` with the exact line above
|
||||
5. Add and commit with the exact message
|
||||
|
||||
## Objectives
|
||||
|
||||
- `project/.git` exists
|
||||
- `project/log-entry.txt` matches the exact content
|
||||
- `project/` has at least 2 commits in its log
|
||||
15
1.solar-system/1.welcome/15.the-cloner/starter/starter.sh
Normal file
15
1.solar-system/1.welcome/15.the-cloner/starter/starter.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
# The Cloner — clone a remote and add a commit.
|
||||
#
|
||||
# When this script runs, a bare repository `remote.git` is in your
|
||||
# working directory. Your script must:
|
||||
#
|
||||
# 1. Clone remote.git into a folder called `project`
|
||||
# 2. Inside project/, set user.name and user.email
|
||||
# 3. Create log-entry.txt containing exactly:
|
||||
# Cadet log entry — checked in.
|
||||
# 4. Stage and commit it with message: "add cadet log entry"
|
||||
#
|
||||
# Tools: git clone, cd, git config, echo, git add, git commit -m
|
||||
|
||||
# Your code here.
|
||||
29
1.solar-system/1.welcome/15.the-cloner/testing/test.sh
Normal file
29
1.solar-system/1.welcome/15.the-cloner/testing/test.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
TMP=$(mktemp -d)
|
||||
(
|
||||
cd "$TMP"
|
||||
git init -q -b main
|
||||
git config user.name "Setup"
|
||||
git config user.email "setup@learnroom.local"
|
||||
echo "# Mission Project" > README.md
|
||||
echo "Initial mission setup." > mission.txt
|
||||
git add .
|
||||
git commit -q -m "initial mission setup"
|
||||
)
|
||||
git clone -q --bare "$TMP" remote.git
|
||||
rm -rf "$TMP"
|
||||
|
||||
bash solution.sh > /dev/null 2>&1
|
||||
|
||||
N=0
|
||||
report() { N=$((N+1)); if [ "$1" = "0" ]; then echo "ok $N - $2"; else echo "not ok $N - $2"; fi; }
|
||||
|
||||
[ -d project/.git ]; report $? "project/.git exists (clone happened)"
|
||||
[ -f project/log-entry.txt ]; report $? "project/log-entry.txt exists"
|
||||
ACTUAL=$(cat project/log-entry.txt 2>/dev/null)
|
||||
ACTUAL="${ACTUAL%$'\n'}"
|
||||
[ "$ACTUAL" = "Cadet log entry — checked in." ]; report $? "log-entry.txt contains the exact line"
|
||||
|
||||
COUNT=$(git -C project log --oneline 2>/dev/null | wc -l | tr -d ' ')
|
||||
[ "$COUNT" -ge 2 ] 2>/dev/null
|
||||
report $? "project has at least 2 commits"
|
||||
Reference in New Issue
Block a user