harbor run -t openthoughts/tasktrove-exp-rpt-stack-bash-withtests-gpt5mini-v2-stack-bash-withtests-gpt4o-9518harbor download openthoughts/tasktrove-exp-rpt-stack-bash-withtests-gpt5mini-v2-stack-bash-withtests-gpt4o-9518Implement two small command-line programs and place them in /app/:
They should be executable (chmod +x).
Goal
Requirements — stagit
Usage (called by the build script): stagit -c CACHE -u CLONE_URL REPO_PATH (You do not need to validate all flags strictly; accept these parameters in any reasonable order.)
Behavior:
Data sources: Read repository metadata files from the REPO_PATH argument (these are plain text files placed in the repository directory by the user):
Minimal valid HTML is sufficient. The verifier only checks that expected files are created and contain recognizable data (owner/description/URL/name).
Requirements — stagit-index
Notes and constraints
Deliverable
The following test script will be used to verify your solution:
#!/bin/sh
# - Makes index for repositories in a single directory.
# - Makes static pages for each repository directory.
#
# NOTE, things to do manually (once) before running this script:
# - copy style.css, logo.svg and favicon.ico manually, a style.css example
# is included.
# - modify the categories in the for loop with your own.
#
# - write clone url, for example "git://git.codemadness.org/dir" to the "url"
# file for each repo.
# - write owner of repo to the "owner" file.
# - write description in "description" file.
#
# Usage:
# - mkdir -p htmldir && cd htmldir
# - sh example_create.sh
# path must be absolute
reposdir="/var/www/git"
webdir="/var/www/stagit"
defaultdir="/usr/local/share/doc/stagit"
mkdir -p "$webdir" || exit 1
# set assets if not already there
ln -s "$defaultdir/style.css" "$webdir/style.css" 2> /dev/null
ln -s "$defaultdir/logo.png" "$webdir/logo.png" 2> /dev/null
ln -s "$defaultdir/favicon.ico" "$webdir/favicon.ico" 2> /dev/null
ln -s "$defaultdir/IBMPlexSans-Regular.woff" "$webdir/IBMPlexSans-Regular.woff" 2> /dev/null
ln -s "$defaultdir/IBMPlexSans-Regular.woff2" "$webdir/IBMPlexSans-Regular.woff2" 2> /dev/null
ln -s "$defaultdir/IBMPlexMono-Regular.woff" "$webdir/IBMPlexMono-Regular.woff" 2> /dev/null
ln -s "$defaultdir/IBMPlexMono-Regular.woff2" "$webdir/IBMPlexMono-Regular.woff2" 2> /dev/null
# clean
for dir in "$webdir/"*/; do
rm -rf "$dir"
done
# make files per repo
for dir in "$reposdir/"*.git/; do
dir="${dir%/}"
[ ! -f "$dir/git-daemon-export-ok" ] && continue
[ ! -f "$dir/category" ] && [ -z "$stagit_uncat" ] && stagit_uncat="1"
# strip .git suffix
r="$(basename "$dir")"
d="$(basename "$dir" ".git")"
printf "%s... " "$d"
mkdir -p "$webdir/$d"
cd "$webdir/$d" || continue
stagit -c ".stagit-build-cache" -u "git://git.alexnorman.xyz/$d/" "$reposdir/$r"
# symlinks
[ -f "about.html" ] \
&& ln -sf "about.html" "index.html" \
|| ln -sf "log.html" "index.html"
ln -sfT "$reposdir/$r" ".git"
echo "done"
done
# generate index arguments
args=""
for cat in "Projects" "Personal setup" "Miscellanea"; do
args="$args -c \"$cat\""
for dir in "$reposdir/"*.git/; do
dir="${dir%/}"
[ -f "$dir/git-daemon-export-ok" ] && [ -f "$dir/category" ] && \
[ "$(cat "$dir/category")" = "$cat" ] && \
args="$args $dir"
done
done
if [ -n "$stagit_uncat" ]; then
args="$args -c Uncategorized"
for dir in "$reposdir/"*.git/; do
dir="${dir%/}"
[ -f "$dir/git-daemon-export-ok" ] && [ ! -f "$dir/category" ] && \
args="$args $dir"
done
fi
# make index
echo "$args" | xargs stagit-index > "$webdir/index.html"