Add usaco sync; track saved test outputs
The website commits too, so `usaco sync` pulls its edits before pushing. tests/*.out were swallowed by the *.out rule; they are expected outputs the site shows, so re-include them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
*.out
|
*.out
|
||||||
|
# ...except saved expected outputs, which the website shows next to each test
|
||||||
|
!**/tests/*.out
|
||||||
*.bak
|
*.bak
|
||||||
solving/*/main
|
solving/*/main
|
||||||
solved/*/main
|
solved/*/main
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
# USACO Workspace
|
# USACO Workspace
|
||||||
|
|
||||||
Practice workspace for USACO problems, managed by the `./usaco` script.
|
Practice workspace for USACO problems, managed by the `./usaco` script.
|
||||||
|
The solved problems are also published at https://adam-french.co.uk/usaco/ by the
|
||||||
|
site in `site/` (see [site/README.md](site/README.md)).
|
||||||
|
|
||||||
## Layout
|
## Layout
|
||||||
|
|
||||||
```
|
```
|
||||||
template.cpp starting template for every problem
|
template.cpp starting template for every problem
|
||||||
|
site/ the website (Go server + Vue SPA), deployed as its own container
|
||||||
solving/<name>/ problems in progress
|
solving/<name>/ problems in progress
|
||||||
solved/<name>/ finished problems
|
solved/<name>/ finished problems
|
||||||
skipped/<name>/ problems set aside for later
|
skipped/<name>/ problems set aside for later
|
||||||
```
|
```
|
||||||
|
|
||||||
Each problem dir contains `main.cpp` plus `<io>.in` / `<io>.out` files (USACO file IO is wired up automatically via `STDIO("<io>")`).
|
Each problem dir contains `main.cpp` plus `<io>.in` / `<io>.out` files (USACO file IO is wired up automatically via `STDIO("<io>")`). Optional extras: `.url` (the problem link), `tests/N.in` + `N.out`, and `notes.md` (shown on the website, usually written from there).
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
@@ -35,10 +38,14 @@ Compiles with `g++ -O2 -std=c++17 -Wall -Wextra` and runs inside the problem dir
|
|||||||
### Finish (or give up on) a problem
|
### Finish (or give up on) a problem
|
||||||
```
|
```
|
||||||
./usaco done diamond-collector # move to solved/ and auto git commit "Solve <name>"
|
./usaco done diamond-collector # move to solved/ and auto git commit "Solve <name>"
|
||||||
|
./usaco sync # pull edits made on the website, push your commits
|
||||||
./usaco skip diamond-collector # move to skipped/
|
./usaco skip diamond-collector # move to skipped/
|
||||||
./usaco undo diamond-collector # bring back to solving/ from solved/ or skipped/
|
./usaco undo diamond-collector # bring back to solving/ from solved/ or skipped/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Website sync
|
||||||
|
The website commits too: marking a problem solved/skipped, or editing its link or notes there, pushes a commit to Gitea. So `git pull` before you push — `./usaco sync` (alias `sy`) does `git pull --rebase --autostash && git push`. Each push reaches the site within seconds through a Gitea webhook.
|
||||||
|
|
||||||
### Edit
|
### Edit
|
||||||
```
|
```
|
||||||
./usaco vim diamond-collector # open main.cpp in $EDITOR (defaults to vim)
|
./usaco vim diamond-collector # open main.cpp in $EDITOR (defaults to vim)
|
||||||
@@ -106,4 +113,5 @@ This gives you:
|
|||||||
# edit solving/the-lost-cow/main.cpp
|
# edit solving/the-lost-cow/main.cpp
|
||||||
./usaco run the-lost-cow # iterate until the output is right
|
./usaco run the-lost-cow # iterate until the output is right
|
||||||
./usaco done the-lost-cow # 🎉 (auto-commits)
|
./usaco done the-lost-cow # 🎉 (auto-commits)
|
||||||
|
./usaco sync # publish it on the website
|
||||||
```
|
```
|
||||||
|
|||||||
+1
-1
@@ -7,5 +7,5 @@ mv "$ROOT/solving/$name" "$ROOT/solved/$name"
|
|||||||
echo "Moved to solved/$name 🎉"
|
echo "Moved to solved/$name 🎉"
|
||||||
if git -C "$ROOT" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
if git -C "$ROOT" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||||
git -C "$ROOT" add -A "solved/$name" "solving/$name" 2>/dev/null || true
|
git -C "$ROOT" add -A "solved/$name" "solving/$name" 2>/dev/null || true
|
||||||
git -C "$ROOT" commit -m "Solve $name" >/dev/null && echo "Committed: Solve $name"
|
git -C "$ROOT" commit -m "Solve $name" >/dev/null && echo "Committed: Solve $name ${DIM}(usaco sync to publish it)${RST}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ HISTFILE="$ROOT/.usaco_history"
|
|||||||
# commands that take a problem name (the selection is injected when you omit it)
|
# commands that take a problem name (the selection is injected when you omit it)
|
||||||
WITH_PROBLEM="run build test done undo skip io cat copy edit open path template reset"
|
WITH_PROBLEM="run build test done undo skip io cat copy edit open path template reset"
|
||||||
# commands that take no problem
|
# commands that take no problem
|
||||||
NO_PROBLEM="list stats clean"
|
NO_PROBLEM="list stats clean sync"
|
||||||
# REPL-only words (used for completion and for 'help')
|
# REPL-only words (used for completion and for 'help')
|
||||||
REPL_WORDS="s use none push pop stack help quit exit"
|
REPL_WORDS="s use none push pop stack help quit exit"
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ while :; do
|
|||||||
case "$c" in
|
case "$c" in
|
||||||
r) c=run ;; b) c=build ;; t) c=test ;; d) c=done ;; u) c=undo ;; sk) c=skip ;;
|
r) c=run ;; b) c=build ;; t) c=test ;; d) c=done ;; u) c=undo ;; sk) c=skip ;;
|
||||||
e|vim) c=edit ;; o) c=open ;; l|ls) c=list ;; st) c=stats ;; p) c=path ;;
|
e|vim) c=edit ;; o) c=open ;; l|ls) c=list ;; st) c=stats ;; p) c=path ;;
|
||||||
tpl) c=template ;; rm|delete) c=reset ;; cp) c=copy ;;
|
tpl) c=template ;; rm|delete) c=reset ;; cp) c=copy ;; sy) c=sync ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ " $NO_PROBLEM " == *" $c "* ]]; then
|
if [[ " $NO_PROBLEM " == *" $c "* ]]; then
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# usaco sync
|
||||||
|
# Pull what the website committed (status changes, links, notes), then push local
|
||||||
|
# commits so the site shows them. --autostash keeps uncommitted work in solving/.
|
||||||
|
git -C "$ROOT" pull --rebase --autostash && git -C "$ROOT" push
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
YES
|
||||||
|
NO
|
||||||
|
YES
|
||||||
|
YES
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
4
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
10
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
3
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
3
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
3
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
10
|
||||||
|
15
|
||||||
|
45
|
||||||
|
55
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
10
|
||||||
|
20
|
||||||
|
30
|
||||||
|
30
|
||||||
|
40
|
||||||
|
50
|
||||||
|
60
|
||||||
|
60
|
||||||
|
120
|
||||||
|
760
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
7 0 0 0 0 0 1
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
11 0 0 0 0 0 0 0 0 0 0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
9 0 3 0 1 0 1 0 1
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
5 4 3 2 1
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ADOBECODEBA
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
a
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
BANC
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
H2O
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
H2MgO2
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
K4N2O14S4
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
# usaco stats Show solve counts and recent activity
|
# usaco stats Show solve counts and recent activity
|
||||||
# usaco path <name> Print the problem's directory (used by the ucd shell helper)
|
# usaco path <name> Print the problem's directory (used by the ucd shell helper)
|
||||||
# usaco clean Delete compiled binaries and backups from all problem dirs
|
# usaco clean Delete compiled binaries and backups from all problem dirs
|
||||||
|
# usaco sync git pull --rebase (picks up edits made on the website), then push
|
||||||
# usaco template <name> Re-copy template.cpp into the problem as main.cpp (backs up old one)
|
# usaco template <name> Re-copy template.cpp into the problem as main.cpp (backs up old one)
|
||||||
# usaco reset <name> Reset the solution: fresh main.cpp from template (STDIO wired up),
|
# usaco reset <name> Reset the solution: fresh main.cpp from template (STDIO wired up),
|
||||||
# delete binary + .out; keeps tests/ and .in (aliases: rm, delete)
|
# delete binary + .out; keeps tests/ and .in (aliases: rm, delete)
|
||||||
@@ -36,7 +37,7 @@
|
|||||||
# diff against expected output, show pass/fail
|
# diff against expected output, show pass/fail
|
||||||
#
|
#
|
||||||
# Short aliases: n=new r=run b=build t=test d=done u=undo sk=skip o=open
|
# Short aliases: n=new r=run b=build t=test d=done u=undo sk=skip o=open
|
||||||
# l/ls=list st=stats p=path tpl=template e=edit=vim
|
# l/ls=list st=stats p=path tpl=template e=edit=vim sy=sync
|
||||||
#
|
#
|
||||||
# Names may be unique prefixes: 'usaco e diam' finds diamond-collector.
|
# Names may be unique prefixes: 'usaco e diam' finds diamond-collector.
|
||||||
#
|
#
|
||||||
@@ -66,6 +67,7 @@ case "$cmd" in
|
|||||||
stats|st) cmd=stats ;;
|
stats|st) cmd=stats ;;
|
||||||
path|p) cmd=path ;;
|
path|p) cmd=path ;;
|
||||||
clean) cmd=clean ;;
|
clean) cmd=clean ;;
|
||||||
|
sync|sy) cmd=sync ;;
|
||||||
template|tpl) cmd=template ;;
|
template|tpl) cmd=template ;;
|
||||||
reset|rm|delete) cmd=reset ;;
|
reset|rm|delete) cmd=reset ;;
|
||||||
*) usage ;;
|
*) usage ;;
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ _usaco() {
|
|||||||
'path:print problem directory'
|
'path:print problem directory'
|
||||||
'p:print problem directory'
|
'p:print problem directory'
|
||||||
'clean:delete binaries and backups'
|
'clean:delete binaries and backups'
|
||||||
|
'sync:pull website edits, push local commits'
|
||||||
|
'sy:pull website edits, push local commits'
|
||||||
'template:re-copy template.cpp as main.cpp (backs up old)'
|
'template:re-copy template.cpp as main.cpp (backs up old)'
|
||||||
'tpl:re-copy template.cpp as main.cpp (backs up old)'
|
'tpl:re-copy template.cpp as main.cpp (backs up old)'
|
||||||
'reset:fresh main.cpp from template, delete binary/.out'
|
'reset:fresh main.cpp from template, delete binary/.out'
|
||||||
@@ -62,7 +64,7 @@ _usaco() {
|
|||||||
_describe 'command' cmds
|
_describe 'command' cmds
|
||||||
elif (( CURRENT == 3 )); then
|
elif (( CURRENT == 3 )); then
|
||||||
case "$words[2]" in
|
case "$words[2]" in
|
||||||
new|n|list|l|ls|stats|st|clean) ;; # no problem-name argument
|
new|n|list|l|ls|stats|st|clean|sync|sy) ;; # no problem-name argument
|
||||||
test|t)
|
test|t)
|
||||||
local -a subs
|
local -a subs
|
||||||
subs=('create:save a new test case' 'add:save a new test case' 'new:save a new test case')
|
subs=('create:save a new test case' 'add:save a new test case' 'new:save a new test case')
|
||||||
|
|||||||
Reference in New Issue
Block a user