commit 71ebfbce02f07b026a00d3ab8f6620b359ab5abc
parent 98deb9605ffe190673a1d0d7ca8f653c74c7be80
Author: Michael Neuper <michael@michaelneuper.com>
Date: Sun, 25 Oct 2026 22:16:10 +0200
stagit-index: add a Language column before Owner
The language is read from a "language" file in the repository, like
owner. build.sh writes it from GitHub's primary language, and its repo
list now uses the ASCII unit separator instead of tabs, because read
merges the empty fields between two tabs.
Diffstat:
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/build.sh b/build.sh
@@ -31,17 +31,19 @@ rm -rf "$out"
mkdir -p "$out"
copyassets "$out"
-# One line per non-empty, public, non-fork repo:
-# name<TAB>default branch<TAB>description
+# One line per non-empty, public, non-fork repo: name, default branch,
+# primary language and description, separated by the ASCII unit separator
+# (read would merge the empty fields between two tabs).
gh repo list "$user" --visibility public --source --limit 1000 \
- --json name,defaultBranchRef,description,isEmpty \
+ --json name,defaultBranchRef,primaryLanguage,description,isEmpty \
--jq '.[] | select(.isEmpty | not)
- | [.name, .defaultBranchRef.name, (.description // "" | gsub("\\s+"; " "))]
- | join("\t")' > "$work/repos.tsv"
+ | [.name, .defaultBranchRef.name, (.primaryLanguage.name // ""),
+ (.description // "" | gsub("\\s+"; " "))]
+ | join("\u001f")' > "$work/repos.lst"
-tab=$(printf '\t')
+us=$(printf '\037')
: > "$work/index.lst"
-while IFS=$tab read -r name branch desc <&3; do
+while IFS=$us read -r name branch lang desc <&3; do
if grep -qxF "$name" "$root/exclude" 2>/dev/null; then
continue
fi
@@ -63,6 +65,7 @@ while IFS=$tab read -r name branch desc <&3; do
# ends up inside <title>.
printf '%s' "$desc" > "$repo/description"
printf '%s' "$user" > "$repo/owner"
+ printf '%s' "$lang" > "$repo/language"
if [ "$serve_git" = 1 ]; then
printf '%s' "$site_url$name.git" > "$repo/url"
else
@@ -88,7 +91,7 @@ while IFS=$tab read -r name branch desc <&3; do
fi
echo "$(git -C "$repo" log -1 --format=%ct) $repo" >> "$work/index.lst"
-done 3< "$work/repos.tsv"
+done 3< "$work/repos.lst"
# Index page, most recently committed to first.
sort -rn -o "$work/index.lst" "$work/index.lst"
diff --git a/stagit-index.c b/stagit-index.c
@@ -15,6 +15,7 @@ static const char *relpath = "";
static char description[255] = "Repositories";
static char *name = "";
static char owner[255];
+static char language[255];
/* Handle read or write errors for a FILE * stream */
void
@@ -110,7 +111,7 @@ writeheader(FILE *fp)
fputs("</span></td></tr><tr><td></td><td>\n"
"</td></tr>\n</table>\n<hr/>\n<div id=\"content\">\n"
"<table id=\"index\"><thead>\n"
- "<tr><td><b>Name</b></td><td><b>Description</b></td><td><b>Owner</b></td>"
+ "<tr><td><b>Name</b></td><td><b>Description</b></td><td><b>Language</b></td><td><b>Owner</b></td>"
"<td><b>Last commit</b></td></tr>"
"</thead><tbody>\n", fp);
}
@@ -156,6 +157,8 @@ writelog(FILE *fp)
fputs("</a></td><td>", fp);
xmlencode(fp, description, strlen(description));
fputs("</td><td>", fp);
+ xmlencode(fp, language, strlen(language));
+ fputs("</td><td>", fp);
xmlencode(fp, owner, strlen(owner));
fputs("</td><td>", fp);
if (author)
@@ -244,6 +247,21 @@ main(int argc, char *argv[])
fclose(fp);
owner[strcspn(owner, "\n")] = '\0';
}
+
+ /* read language or .git/language */
+ joinpath(path, sizeof(path), repodir, "language");
+ if (!(fp = fopen(path, "r"))) {
+ joinpath(path, sizeof(path), repodir, ".git/language");
+ fp = fopen(path, "r");
+ }
+ language[0] = '\0';
+ if (fp) {
+ if (!fgets(language, sizeof(language), fp))
+ language[0] = '\0';
+ checkfileerror(fp, "language", 'r');
+ fclose(fp);
+ language[strcspn(language, "\n")] = '\0';
+ }
writelog(stdout);
}
writefooter(stdout);