shithub: shithub

Download patch

ref: ea71c33594b15937ba22faab3cf2905d3a138594
parent: 95d87ae1d14c74b85c1247d03ad3fc71e61c0d8b
author: phil9 <telephil9@gmail.com>
date: Sun Jan 31 23:48:07 EST 2021

pass parameters instead of relyin on variables being set

	a couple of functions were expecting some variables to be set.
	This is plain wrong so we explicitely pass parameters instead

--- a/shithub
+++ b/shithub
@@ -46,7 +46,9 @@
 }
 
 fn formatcommit {
-	phash=$1
+	puser=$1
+	prepo=$2
+	phash=$3
 
 	message=`{htcat /mnt/git/object/$phash/msg | sed 1q}
 	date=`{date -t `{mtime /mnt/git/object/$phash/msg | awk '{print $1}'}}
@@ -53,7 +55,7 @@
 	author=`"{htcat /mnt/git/object/$phash/author | awk '{print $1}'}
 	shorthash=`{echo $phash | awk '{print substr($0, 0, 8)}'}
 	echo '	<div id="commit">
-		<a href=/git/'$gituser/$repo/$phash'/commit.html>'$shorthash'</a>
+		<a href=/git/'$puser/$prepo/$phash'/commit.html>'$shorthash'</a>
 		 – '$author' – '$"date'
 		<pre>'$"message'</pre>
 		</div>'
@@ -60,18 +62,22 @@
 }
 
 fn shortlog {
-	ref=$1
-	commitcount=$2
+	puser=$1
+	prepo=$2
+	pref=$3
+	pcount=$4
 
 	d=`{pwd}
-	commithash=`{cat /mnt/git/$ref/hash | sed 1q}
+	commithash=`{cat /mnt/git/$pref/hash | sed 1q}
 	count=()
-	while (! ~ $#commithash 0 && ! ~ $#count $commitcount) {
+	while (! ~ $#commithash 0 && ! ~ $#count $pcount) {
 		count=($count 1)
-		formatcommit $commithash
+		formatcommit $puser $prepo $commithash
 		echo '<br/>'
 		commithash=`{cat /mnt/git/object/$commithash/parent | sed 1q}
 	}
+	if(! ~ $"commithash '')
+		echo '<a href="/git/'$puser/$prepo/$commithash'/log.html">Next</a>'
 	cd $d
 }
 
@@ -257,7 +263,7 @@
 
 	if(test -f /mnt/git/object/$hash/msg){
 		echo '	<h3>Last commit</h3>'
-		formatcommit $hash
+		formatcommit $gituser $repo $hash
 	}
 
 	echo '	<h3>About</h3>
@@ -416,10 +422,8 @@
 	}
 	cd /mnt/git/$ref/tree
 	echo '	<p>'
-	shortlog $ref 100
+	shortlog $gituser $repo $ref 100
 	echo '	</p>'
-	if(! ~ $"commithash '')
-		echo '<a href="/git/'$gituser/$repo/$commithash'/log.html">Next</a>'
 	echo '	</body>
 		</html>'