Skip to content

Commit d93f43d

Browse files
committed
Move solutions to GitHub Wiki
1 parent 9d5126e commit d93f43d

318 files changed

Lines changed: 115 additions & 82293 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
/solutions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ left on the board, ideally in the center location.
1212

1313
![Solitaire board](https://upload.wikimedia.org/wikipedia/commons/thumb/5/50/Spielzug_von_Solit%C3%A4r.gif/330px-Spielzug_von_Solit%C3%A4r.gif)
1414

15-
- [Solutions](https://github.com/Dampfwalze/solitaire_solver/blob/master/solutions/index.md)
15+
- [Solutions](https://github.com/Dampfwalze/solitaire_solver/wiki)
1616
- [Documentation](https://dampfwalze.github.io/solitaire_solver)
1717

1818
This project implements two board representations and two solving schemes,

scripts/push_wiki_solutions.sh

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
ROOT_DIR="$(git rev-parse --show-toplevel 2>/dev/null || true)"
6+
if [[ -z "$ROOT_DIR" ]]; then
7+
echo "Error: run this script inside a git repository."
8+
exit 1
9+
fi
10+
11+
SOURCE_DIR="$ROOT_DIR/solutions"
12+
if [[ ! -d "$SOURCE_DIR" ]]; then
13+
echo "Error: solutions directory not found at $SOURCE_DIR"
14+
exit 1
15+
fi
16+
17+
origin_url="$(git -C "$ROOT_DIR" remote get-url origin 2>/dev/null || true)"
18+
if [[ -z "$origin_url" ]]; then
19+
echo "Error: could not determine origin remote URL."
20+
exit 1
21+
fi
22+
23+
derive_wiki_url() {
24+
local remote_url="$1"
25+
26+
if [[ "$remote_url" =~ ^git@([^:]+):(.+)$ ]]; then
27+
local host="${BASH_REMATCH[1]}"
28+
local path="${BASH_REMATCH[2]}"
29+
path="${path%.git}"
30+
echo "git@${host}:${path}.wiki.git"
31+
return 0
32+
fi
33+
34+
if [[ "$remote_url" =~ ^ssh://git@([^/]+)/(.+)$ ]]; then
35+
local host="${BASH_REMATCH[1]}"
36+
local path="${BASH_REMATCH[2]}"
37+
path="${path%.git}"
38+
echo "ssh://git@${host}/${path}.wiki.git"
39+
return 0
40+
fi
41+
42+
if [[ "$remote_url" =~ ^https?://([^/]+)/(.+)$ ]]; then
43+
local proto host path
44+
proto="${remote_url%%://*}"
45+
host="${BASH_REMATCH[1]}"
46+
path="${BASH_REMATCH[2]}"
47+
path="${path%.git}"
48+
echo "${proto}://${host}/${path}.wiki.git"
49+
return 0
50+
fi
51+
52+
return 1
53+
}
54+
55+
wiki_url="$(derive_wiki_url "$origin_url" || true)"
56+
if [[ -z "$wiki_url" ]]; then
57+
echo "Error: unsupported origin URL format: $origin_url"
58+
exit 1
59+
fi
60+
61+
tmp_dir="$(mktemp -d)"
62+
wiki_dir="$tmp_dir/wiki"
63+
64+
cleanup() {
65+
rm -rf "$tmp_dir"
66+
}
67+
trap cleanup EXIT
68+
69+
echo "Cloning wiki repository: $wiki_url"
70+
git clone "$wiki_url" "$wiki_dir"
71+
72+
# Remove all existing wiki content while keeping the .git directory.
73+
find "$wiki_dir" -mindepth 1 -maxdepth 1 ! -name ".git" -exec rm -rf {} +
74+
75+
echo "Copying local solutions into wiki repository"
76+
cp -a "$SOURCE_DIR"/. "$wiki_dir"/
77+
cp "$wiki_dir"/Home.md "$wiki_dir"/_Sidebar.md
78+
79+
git -C "$wiki_dir" add -A
80+
81+
if git -C "$wiki_dir" diff --cached --quiet; then
82+
echo "No wiki changes detected. Nothing to push."
83+
exit 0
84+
fi
85+
86+
timestamp="$(date -u +"%Y-%m-%d %H:%M:%S UTC")"
87+
commit_message="Sync wiki from solutions (${timestamp})"
88+
89+
git -C "$wiki_dir" commit -m "$commit_message"
90+
git -C "$wiki_dir" push
91+
92+
echo "Wiki sync completed successfully."

solutions/index.md

Lines changed: 0 additions & 357 deletions
This file was deleted.

0 commit comments

Comments
 (0)