shithub: shithub

ref: c5847bcde2ed8d1e5891e79b186a14e46cfa0bfa
dir: /files/

View raw version
#!/bin/rc

. /sys/lib/shithub/common.rc

cd $1
shift

rfork ne
nl='
'


gituser=$1
repo=$2
refname=$3
dir=$4

repons $gituser $repo
repodir=/mnt/$repo/.git
if(! ref=`{resolveref $refname}){
	echo '<b>invalid ref '$refname'</b>'
	exit
}

if(test -f $gitfs/$ref/hash)
	hash=`{cat $gitfs/$ref/hash}
if not
	hash=$ref

http_response
user_prelude $gituser $repo $hash

if(! test -d $gitfs/$ref/tree){
	echo '	<p>No code pushed</p>
		</body>
		</html>
	'
	exit
}

cd $gitfs/$ref/tree

echo '	<p>
	<b>ref:</b> <a href="'/git/$gituser/$repo/browse/$hash/'">'$hash'</a><br/>
	<b>tar:</b> <a href="'/git/$gituser/$repo/snap/$hash/'">download</a><br/></p>'

if (! ~ $#dir 0) cd .$dir

echo '<p>' 
if (! ~ $#dir 0) echo /$gituser/$repo/browse/$hash $repo $dir |breadcrumb
echo '<div id="code">'
for(f in `$nl{ls}){
echo '<!-- f: ' $f ' -->'
	url=`$nl{echo -n $f | urlencode}
	fname=`$nl{echo -n $f | htcat}
	action='view'
	if (test -d $f) action='browse'
	echo -n '<a href="'/$gituser/$repo/$action/$refname^$dir/$url'">'$fname
	if (test -d $f) echo '/'
	echo '</a><br/>'
}		
echo '	</div>
	</p>
	</body>
	</html>'