stagit

- static git page generator
git clone git://git.acid.vegas/stagit.git
Log | Files | Refs | Archive | README | LICENSE

commit f856d860713f05e5fd5c69133aabd935c48b4d96
parent 2a87b5b0ed1bd98ddc26b0bed89ac2f7b3010384
Author: acidvegas <acid.vegas@acid.vegas>
Date: Tue, 19 Mar 2024 11:53:49 -0400

Update clone <tr> to use the 'url' class for Software Heritage Foundation parsers (cheers pabs3)

Diffstat:
Massets/post-receive | 10+++++-----
Massets/repo | 56++++++++++++++++++++------------------------------------
Mstagit.c | 2+-

3 files changed, 26 insertions(+), 42 deletions(-)

diff --git a/assets/post-receive b/assets/post-receive
@@ -15,10 +15,10 @@ command -v stagit >/dev/null 2>&1 || { echo "stagit not found" >&2; exit 1; }
 mkdir -p "$HTML_DIR/$REPO" || { echo "Failed to create directory $HTML_DIR/$REPO" >&2; exit 1; }
 
 if cd "$HTML_DIR/$REPO"; then
-  stagit -l "$COMMIT_LIMIT" -u "$PROTO://$URL/$REPO" "$DIR" || { echo "stagit failed to generate static pages" >&2; exit 1; }
-  ln -sf log.html index.html
-  git --git-dir="$DIR" archive --format=tar.gz -o "$HTML_DIR/$REPO/archive.tar.gz" --prefix="$REPO/" HEAD || { echo "git archive failed" >&2; exit 1; }
+	stagit -l "$COMMIT_LIMIT" -u "$PROTO://$URL/$REPO" "$DIR" || { echo "stagit failed to generate static pages" >&2; exit 1; }
+	ln -sf log.html index.html
+	git --git-dir="$DIR" archive --format=tar.gz -o "$HTML_DIR/$REPO/archive.tar.gz" --prefix="$REPO/" HEAD || { echo "git archive failed" >&2; exit 1; }
 else
-  echo "Failed to change directory to $HTML_DIR/$REPO" >&2
-  exit 1
+	echo "Failed to change directory to $HTML_DIR/$REPO" >&2
+	exit 1
 fi
diff --git a/assets/repo b/assets/repo
@@ -1,21 +1,25 @@
 #!/bin/sh
 # git-shell-commands helper for stagit - developed by acidvegas (https://git.acid.vegas/stagit)
 
-check_description() {
-	if [ -f $1/description ]; then
-		if [ "$(cat $1/description)" = "Unnamed repository; edit this file 'description' to name the repository." ]; then
-			read -p "description for '$REPO':" desc
-			echo "$desc" > $1/description
-			echo "[+] updated default 'description' file for '$REPO'"
-		fi
-	else
-		read -p "description for '$REPO':" desc
-		echo "$desc" > $1/description
-		echo "[+] added missing 'description' file for '$REPO'"
+if [ "$#" -ne 2 ]; then
+	echo "invalid arguments (use -c or -d)"
+	exit 1
+elif [ "$1" = '-c' ]; then
+	if [ -d "$2.git" ]; then
+		echo "repository already exists"
+		exit 1
+	else if [ ! -f post-receive ]; then
+		echo "missing post-receive script"
+		exit 1
 	fi
-}
-
-remake_index() {
+	mkdir "$2.git"
+	git init --bare "$2.git"
+	touch "$2.git/git-daemon-export-ok"
+	ln /srv/git/git-shell-commands/post-receive "$2.git/hooks/post-receive" 
+	echo "https://git.acid.vegas/$2.git" > "$2.git/url"
+	echo "Description for '$2' repository:"
+	read desc
+	echo "$desc" > "$2.git/description"
 	echo "[~] recreating index..."
     args=""
     for category in $(cat /srv/git/*/owner | xargs -n1 | sort -u | xargs); do
@@ -24,33 +28,13 @@ remake_index() {
         args="$args -c \"$category\" $REPOS"
     done
     echo "$args" | xargs stagit-index > $HTML_DIR/index.html
-}
-
-if [ "$#" -ne 2 ]; then
-	echo "invalid arguments (use -c or -d)" >&2
-	exit 1
-fi
-
-if [ "$1" = '-c' ]; then
-	if [ -d "$2.git" ]; then
-		echo "repository already exists" >&2
-		exit 1
-	fi
-	if [ ! -f post-receive ]; then
-		echo "missing post-receive script" >&2
-		exit 1
-	fi
-	mkdir "$2.git" && git init --bare "$2.git" || exit 1
-	touch "$2.git/git-daemon-export-ok"
-	ln /srv/git/git-shell-commands/post-receive "$2.git/hooks/post-receive" || exit 1
-	echo "https://git.acid.vegas/$2.git" > "$2.git/url"
 elif [ "$1" = '-d' ]; then
 	if [ ! -d "$2.git" ]; then
-		echo "repository does not exist" >&2
+		echo "repository does not exist"
 		exit 1
 	fi
 	rm -rf "$2.git"
 else
-	echo "invalid arguments (use -c or -d)" >&2
+	echo "invalid arguments (use -c or -d)"
 	exit 1
 fi
 \ No newline at end of file
diff --git a/stagit.c b/stagit.c
@@ -484,7 +484,7 @@ void writeheader(FILE *fp, const char *title) {
 	xmlencode(fp, description, strlen(description));
 	fputs("</span></td></tr>\n", fp);
 	if (cloneurl[0]) {
-		fputs("\t\t<tr><td><i>git clone <a href=\"", fp);
+		fputs("\t\t<tr class=\"url\"><td><i>git clone <a href=\"", fp);
 		xmlencode(fp, cloneurl, strlen(cloneurl)); /* not percent-encoded */
 		fputs("\">", fp);
 		xmlencode(fp, cloneurl, strlen(cloneurl));