diff options
author | VG <vg@devys.org> | 2016-10-29 12:06:56 +0200 |
---|---|---|
committer | VG <vg@devys.org> | 2016-10-29 12:06:56 +0200 |
commit | 25c827c055a0bd179c32d81293d30f1090b6275e (patch) | |
tree | 28db9d9511f7b06fc64836a57f4c4e0c93787b8e /gitcmd | |
parent | ae1ffa7c7a6823423b6c9b961e7d1c28a86af9ef (diff) | |
download | ssh-git-only-25c827c055a0bd179c32d81293d30f1090b6275e.tar.gz ssh-git-only-25c827c055a0bd179c32d81293d30f1090b6275e.tar.bz2 ssh-git-only-25c827c055a0bd179c32d81293d30f1090b6275e.zip |
Better ls behaviour (allow completion)
Diffstat (limited to 'gitcmd')
-rwxr-xr-x | gitcmd | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -5,6 +5,9 @@ import os def printerr(*l, **d): return print(*l, **d, file=sys.stderr) def fail(*l, **d): printerr(*l, **d); raise SystemExit(1) +def lsexit_repositories(repositories_ro, repositories_rw): + print('\n'.join(repositories_ro + repositories_rw or ['Empty list'])) + raise SystemExit(0) try: user = sys.argv[1] @@ -29,8 +32,7 @@ try: repository = ssh_original_command[1].split('.git')[0].strip("'") except IndexError: if command == 'ls': - print('\n'.join(repositories_ro + repositories_rw or ['Empty list'])) - raise SystemExit(0) + lsexit_repositories(repositories_ro, repositories_rw) fail('Invalid repository name or git usage') except KeyError: fail('Bad boy, git only access authorized.') @@ -43,5 +45,7 @@ if command == 'git-upload-pack' and repository in repositories_ro: elif command == 'git-receive-pack' and repository in repositories_rw: os.execv('/usr/bin/git-receive-pack', ['/usr/bin/git-receive-pack', repository]) +elif command == 'ls': + lsexit_repositories(repositories_ro, []) else: fail('Bad git command or inexistant repository or access denied') |