seed: curriculum content
This commit is contained in:
38
1.solar-system/1.welcome/11.the-identity/index.md
Normal file
38
1.solar-system/1.welcome/11.the-identity/index.md
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
type: challenge
|
||||
title: "The Identity"
|
||||
xp: 50
|
||||
duration: 15
|
||||
difficulty: 2
|
||||
---
|
||||
|
||||
# The Identity
|
||||
|
||||
> **[INCOMING — Mission Control, Earth]**
|
||||
>
|
||||
> Cadet, before Git records any of your work, it needs to know who's
|
||||
> making the changes. Every commit you'll ever make will carry your
|
||||
> name and email.
|
||||
>
|
||||
> When your script runs, a fresh Git repository already exists in the
|
||||
> current directory. Set the local identity:
|
||||
>
|
||||
> ```bash
|
||||
> git config user.name "Your Name"
|
||||
> git config user.email "you@example.com"
|
||||
> ```
|
||||
>
|
||||
> Without `--global`, these settings only apply to this one repo —
|
||||
> exactly what we want for a contained challenge.
|
||||
>
|
||||
> [END TRANSMISSION]
|
||||
|
||||
## Your Task
|
||||
|
||||
In `starter/starter.sh`, set `user.name` and `user.email` on the
|
||||
current Git repo.
|
||||
|
||||
## Objectives
|
||||
|
||||
- `user.name` is set on the repo (non-empty)
|
||||
- `user.email` is set on the repo and looks like an email
|
||||
12
1.solar-system/1.welcome/11.the-identity/starter/starter.sh
Normal file
12
1.solar-system/1.welcome/11.the-identity/starter/starter.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
# The Identity — tell Git who you are.
|
||||
#
|
||||
# When this script runs, a fresh Git repo is already initialized in
|
||||
# the current directory. Your script must set both:
|
||||
#
|
||||
# - user.name (any non-empty string)
|
||||
# - user.email (must contain @ and a dot)
|
||||
#
|
||||
# Tools: git config <key> "<value>"
|
||||
|
||||
# Your code here.
|
||||
13
1.solar-system/1.welcome/11.the-identity/testing/test.sh
Normal file
13
1.solar-system/1.welcome/11.the-identity/testing/test.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
git init -q -b main
|
||||
|
||||
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; }
|
||||
|
||||
NAME=$(git config --local --get user.name 2>/dev/null)
|
||||
EMAIL=$(git config --local --get user.email 2>/dev/null)
|
||||
|
||||
[ -n "$NAME" ]; report $? "user.name is set on the repo"
|
||||
[[ "$EMAIL" == *@*.* ]]; report $? "user.email is set and looks like an email"
|
||||
Reference in New Issue
Block a user