seed: curriculum content
This commit is contained in:
43
1.solar-system/1.welcome/16.the-pusher/index.md
Normal file
43
1.solar-system/1.welcome/16.the-pusher/index.md
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
type: challenge
|
||||
title: "The Pusher"
|
||||
xp: 100
|
||||
duration: 30
|
||||
difficulty: 3
|
||||
---
|
||||
|
||||
# The Pusher
|
||||
|
||||
> **[INCOMING — Mission Control, Earth]**
|
||||
>
|
||||
> Cadet, your commits live only on your machine until you *push* them
|
||||
> somewhere shared. That's how teams work.
|
||||
>
|
||||
> When your script runs, you'll find:
|
||||
>
|
||||
> - `local-repo/` — a working repo with two commits already, identity set
|
||||
> - `remote.git/` — an empty bare repo (your shared destination)
|
||||
>
|
||||
> Two commands:
|
||||
>
|
||||
> - `git remote add <name> <path>` — register a remote and give it a
|
||||
> short name (by convention, `origin`)
|
||||
> - `git push -u <remote> <branch>` — send your branch's commits to that
|
||||
> remote (`-u` sets it as default for next time)
|
||||
>
|
||||
> Wire `local-repo` to `remote.git` and push.
|
||||
>
|
||||
> [END TRANSMISSION]
|
||||
|
||||
## Your Task
|
||||
|
||||
In `starter/starter.sh`:
|
||||
|
||||
1. `cd local-repo`
|
||||
2. Add `../remote.git` as a remote named `origin`
|
||||
3. Push `main` to `origin` with `-u`
|
||||
|
||||
## Objectives
|
||||
|
||||
- `local-repo` has a remote `origin` configured
|
||||
- `remote.git` has the same commits on `main` as `local-repo`
|
||||
15
1.solar-system/1.welcome/16.the-pusher/starter/starter.sh
Normal file
15
1.solar-system/1.welcome/16.the-pusher/starter/starter.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
# The Pusher — send your commits to a remote.
|
||||
#
|
||||
# When this script runs:
|
||||
# - local-repo/ is a working repo with commits + identity already set
|
||||
# - remote.git/ is a bare empty repo waiting for your push
|
||||
#
|
||||
# Your script must:
|
||||
# 1. Inside local-repo, register remote.git as a remote named `origin`
|
||||
# pointing at ../remote.git
|
||||
# 2. Push the main branch to origin (use -u to set upstream)
|
||||
#
|
||||
# Tools: cd, git remote add, git push
|
||||
|
||||
# Your code here.
|
||||
27
1.solar-system/1.welcome/16.the-pusher/testing/test.sh
Normal file
27
1.solar-system/1.welcome/16.the-pusher/testing/test.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
mkdir -p local-repo
|
||||
(
|
||||
cd local-repo
|
||||
git init -q -b main
|
||||
git config user.name "Cadet Vega"
|
||||
git config user.email "cadet.vega@learnroom.local"
|
||||
echo "# Mission" > README.md
|
||||
git add README.md; git commit -q -m "initial commit"
|
||||
echo "Day 1 log" > log.txt
|
||||
git add log.txt; git commit -q -m "add log"
|
||||
)
|
||||
git init -q --bare remote.git
|
||||
|
||||
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; }
|
||||
|
||||
ORIGIN_URL=$(git -C local-repo remote get-url origin 2>/dev/null)
|
||||
[ -n "$ORIGIN_URL" ]; report $? "'origin' remote configured on local-repo"
|
||||
|
||||
LOCAL_COUNT=$(git -C local-repo log --oneline main 2>/dev/null | wc -l | tr -d ' ')
|
||||
REMOTE_COUNT=$(git -C remote.git log --oneline main 2>/dev/null | wc -l | tr -d ' ')
|
||||
|
||||
[ -n "$REMOTE_COUNT" ] && [ "$REMOTE_COUNT" != "0" ]; report $? "remote.git has commits on main"
|
||||
[ "$LOCAL_COUNT" = "$REMOTE_COUNT" ]; report $? "remote.git has same number of commits as local-repo"
|
||||
Reference in New Issue
Block a user