From 160a740cc74094b6b083475557b05820f387d146 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonah=20Br=C3=BCchert?= <jbb@kaidan.im>
Date: Wed, 15 May 2024 22:44:59 +0200
Subject: [PATCH] Add script to clone everyones git repository

This is a simplified and generalized version of the script by mielimom02
---
 fugit.sh   | 28 ++++++++++++++++++++++++++++
 install.sh |  2 +-
 2 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100755 fugit.sh

diff --git a/fugit.sh b/fugit.sh
new file mode 100755
index 0000000..9305e7c
--- /dev/null
+++ b/fugit.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+if [ $# -lt 2 ] || ([ ! -f 'grades.csv' ] && [ ! -f 'grades.xls' ]); then
+    printf "Usage: %s <repository name> <branch>\n" $(basename $0) >&2
+    printf "Supply a repository name and branch name\n" >&2
+    printf "Execute within the directory containing 'grades.csv'\n" >&2
+    exit 1
+fi
+
+repo_name="$1"
+branch="$2"
+
+for user in *; do
+    if [ -d "$user" ]; then
+        cd "$user"
+
+        current_dir=$(basename "$PWD")
+
+        zedat_username=`echo $current_dir | sed 's/.*(\([a-z0-9]*\))$/\1/'`
+
+        if [ ! -d npvp-exercises ]; then
+            git clone "git@git.imp.fu-berlin.de:$zedat_username/$repo_name"
+        fi
+
+        git -C "$repo_name" checkout "$branch"
+        cd ..
+    fi
+done
diff --git a/install.sh b/install.sh
index 4df6257..9939e73 100755
--- a/install.sh
+++ b/install.sh
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-scripts="fixpdf.sh fucopy.sh fufixpdf.sh fuzip.sh fuxournalexport.sh fixtimes.sh fuclean.sh"
+scripts="fixpdf.sh fucopy.sh fufixpdf.sh fuzip.sh fuxournalexport.sh fufixtimes.sh fuclean.sh fugit.sh"
 
 destdir="${DESTDIR:=$HOME/.local/bin}"
 mkdir -p "$destdir"
-- 
GitLab