shell

Git shell for sbi.re
Log | Files | Refs | README

commit 62c61dca0a7efc7cbd76d4c7d6cb9109cd4ff2ce
parent 928854bcb5538241fc1e18f3a446ace4af5cd8e5
Author: flupe <flupe@sbi.re>
Date:   Fri, 19 Nov 2021 14:36:24 +0100

removed users, using global hook now

Diffstat:
A.gitconfig | 2++
Ahooks/post-receive | 43+++++++++++++++++++++++++++++++++++++++++++
Mshell.py | 2+-
Dtemplate/hooks/post-receive | 42------------------------------------------
Dusers/calvin/MBP.pub | 1-
Dusers/ismael/MBP.pub | 1-
Dusers/lucas/poule.pub | 2--
Dusers/peio/radon.pub | 1-
8 files changed, 46 insertions(+), 48 deletions(-)

diff --git a/.gitconfig b/.gitconfig @@ -0,0 +1,2 @@ +[core] + hooksPath = /var/lib/git/hooks diff --git a/hooks/post-receive b/hooks/post-receive @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +import subprocess +import sys +import os +import glob +from os import path + +REPOSITORIES = path.expanduser('~/repositories') +HTMLDIR = '/var/lib/www/git' + +CACHEFILE = '.htmlcache' +COMMITS = 100 +BASEURL = 'https://git.sbi.re' + +def git(*args): + return (subprocess + .run(['git', *args], capture_output=True, encoding='utf-8') + .stdout) + +def main(lines): + CURR = os.getcwd() + full_name = path.relpath(CURR, REPOSITORIES) + short_name = path.basename(full_name) + + # TODO: detect forced push and delete cache + # TODO: detect if repo is public/private + + # create output html dir + outdir = path.join(HTMLDIR, full_name) + os.makedirs(outdir, exist_ok=True) + + # change current dir and generate html + os.chdir(outdir) + subprocess.run(['stagit', '-l', str(COMMITS), '-u', BASEURL , CURR]) + + # render index again + with open(path.join(HTMLDIR, 'index.html'), 'w+') as index: + files = sorted(glob.glob(path.join(REPOSITORIES, '*'))) + subprocess.run(['stagit-index', *files], stdout=index) + +if __name__ == '__main__': + main(sys.stdin) diff --git a/shell.py b/shell.py @@ -34,7 +34,7 @@ def git(*args): .stdout) def stagit(repo): - path = join(policy.BASEDIR, repo) + path = join(REPOS, repo) outdir = join(HTMLDIR, repo) os.makedirs(outdir, exist_ok=True) diff --git a/template/hooks/post-receive b/template/hooks/post-receive @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 - -import subprocess -import sys -import os -import glob -from os import path - -REPOSITORIES = path.expanduser('~/repositories') -HTMLDIR = '/var/lib/www/git' - -CACHEFILE = '.htmlcache' -COMMITS = 100 -BASEURL = 'https://git.sbi.re' - -def git(*args): - return (subprocess - .run(['git', *args], capture_output=True, encoding='utf-8') - .stdout) - -def main(lines): - CURR = os.getcwd() - full_name = path.relpath(CURR, REPOSITORIES) - short_name = path.basename(full_name) - - # TODO: detect forced push and delete cache - # TODO: detect if repo is public/private - - # create output html dir - outdir = path.join(HTMLDIR, full_name) - os.makedirs(outdir, exist_ok=True) - - # change current dir and generate html - os.chdir(outdir) - subprocess.run(['stagit', '-l', str(COMMITS), '-u', BASEURL , CURR]) - - # render index again - files = sorted(glob.glob(path.join(REPOSITORIES, '*'))) - subprocess.run(['stagit-index', *files]) - -if __name__ == '__main__': - main(sys.stdin) diff --git a/users/calvin/MBP.pub b/users/calvin/MBP.pub @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCgVALGKVRimLHpkRdkRRqk1BSHnjxe0I56E6jFTrqBRfPWFlVCde7J5yL+/ie0X5CbOOKOWQJDGxklxFyRNiP6RgA+0YlWxJD7NjTt1j5EWVtJxK5qJS3VQUZIrlDnmWsSQrLjnR+3/4Oy33ZDQ90qK2Fqf2EJ0EVatI/HSeh4bNvBNxH9s1dcb9re3wPXlMt2f7ePAwcFp9qVvKclwYxeK7cBfvdSzbaY+UmXk5C2JNXq5vWQ3jBNciSb5OCXnMQ1ybOuudGzIEzbFP1e/D8vX+NZ/tSFKvx1mvm/XAPWyrkarckyvSX0AYyGHlCcHAY3MiGtda5n41lWf9boLiB/dXHS7bt5lfYWfU5hSgtS85e822sfJ4M8GVXyl4KZwr1HobRtTolDCLKXZMcNKBHg8a6QgLWcWkSboVTz31VTcJA49t76icBjXC8Ad+Z9cgB0OK5H20fZxZVJ/HmPrpZwaQDoTKZxYzw6LvjZv5laFoQ/jLfZ47IRNSslvHnIoSU= calvin@MBP-de-Calvin diff --git a/users/ismael/MBP.pub b/users/ismael/MBP.pub @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDbZVQHpuVUg8wBAFVzb/n4HrleUX4P7gyCL6wYU1cxSW5CFELDYuEz/3VfrhkjW43ymK8IGB8zibxMYthgTeVtE2BVnIvsNoa8iBlmMBqfnxY7kb5WSE/3KYMkOLJxcPJ6LRZxXP30dE43SGJ6N3FakDmkI+26Yi0tpcAbasmWc4WNg96Pqq84fZyIkYnJ6mRhq+oBHojdLmUwL6fuByaPlWNNAbMp1sSLFw1MBiWHRQ7ieoJyJxhl0c4V6JXzcJO6cdMl3HAwvkWMVbNwWkVJxfXYu6YlfavijW5m0yAEZq14fXWtg4MSPMJxd9LAAuEktoPzy17vVmJSbt4YXFxz plop@MBP-de-Ismael diff --git a/users/lucas/poule.pub b/users/lucas/poule.pub @@ -1 +0,0 @@ -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN7XQaZEw/l4wpVSr+GYmJpHV/fJf9HSRLRQ8e8DgwCA flupe@poule -\ No newline at end of file diff --git a/users/peio/radon.pub b/users/peio/radon.pub @@ -1 +0,0 @@ -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHo/Xr6JMf/69E2MN412uIsVHkCTw0mJnKO5870AIQKv radon