From 9b305a15639cb48f562142e71551803b288f8170 Mon Sep 17 00:00:00 2001
From: Markus M <mmi.github@gmail.com>
Date: Tue, 16 Apr 2024 16:51:32 +0200
Subject: [PATCH] feat(fugit):  added fugit and fugitclean scripts for working
 with student repos

---
 fugit.sh      | 25 +++++++++++++++++++++++++
 fugitclean.sh |  8 ++++++++
 install.sh    |  3 +--
 3 files changed, 34 insertions(+), 2 deletions(-)
 create mode 100755 fugit.sh
 create mode 100755 fugitclean.sh

diff --git a/fugit.sh b/fugit.sh
new file mode 100755
index 0000000..aabbd05
--- /dev/null
+++ b/fugit.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+if [ $# -gt 2 ]; then
+    printf "Usage: %s [branch] [reponame]" $(basename $0) >&2
+    printf "Default branch name will be read from comments.txt" >&2
+    printf "Default reponame will be npvp-exercises" >&2
+    exit 1
+fi
+
+if [ -z $2 ]; then
+    repo_name=`echo $PWD | sed 's/.*(\([a-z0-9]*\))$/\1/'`
+    repo_name="$repo_name/npvp-exercises"
+else
+    repo_name=$2
+fi
+
+if [ -z $1 ]; then 
+    # read branch name from comments.txt
+    branch_name=`cat comments.txt`
+     
+else
+    branch_name=$1
+fi
+
+`git clone -b $branch_name git@git.imp.fu-berlin.de:$repo_name git-solution`
diff --git a/fugitclean.sh b/fugitclean.sh
new file mode 100755
index 0000000..b567d5e
--- /dev/null
+++ b/fugitclean.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+# this script cleans all checked out repositories when called from the same folder that contains the grades.csv
+# or a singular checked out repo when called from within a student folder
+
+find -type d \
+    -wholename "*/git-solution" -prune \
+    -execdir sh -c "rm -rf ./git-solution/" {} \;
+    
diff --git a/install.sh b/install.sh
index 8642ca1..5773717 100755
--- a/install.sh
+++ b/install.sh
@@ -1,7 +1,6 @@
 #! /bin/sh
 
-scripts="fixpdf.sh fucopy.sh fufixpdf.sh fuzip.sh fuxournalexport.sh"
-
+scripts="fixpdf.sh fucopy.sh fufixpdf.sh fuzip.sh fuxournalexport.sh fugit.sh fugitclean.sh"
 destdir="${DESTDIR:=$HOME/.local/bin}"
 mkdir -p "$destdir"
 
-- 
GitLab