git-serve: Move entry point to a main() method

Move the main program logic of git-serve to a main() method such that it
can be used as a module and easily be invoked by setuptools wrapper
scripts.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Lukas Fleischer 2016-09-20 08:53:41 +02:00
parent b8318d2587
commit 8468b6be4b

View file

@ -289,6 +289,7 @@ def usage(cmds):
exit(0) exit(0)
def main():
user = os.environ.get('AUR_USER') user = os.environ.get('AUR_USER')
privileged = (os.environ.get('AUR_PRIVILEGED', '0') == '1') privileged = (os.environ.get('AUR_PRIVILEGED', '0') == '1')
ssh_cmd = os.environ.get('SSH_ORIGINAL_COMMAND') ssh_cmd = os.environ.get('SSH_ORIGINAL_COMMAND')
@ -339,7 +340,8 @@ elif action == 'setup-repo':
die_with_help("{:s}: missing repository name".format(action)) die_with_help("{:s}: missing repository name".format(action))
if len(cmdargv) > 2: if len(cmdargv) > 2:
die_with_help("{:s}: too many arguments".format(action)) die_with_help("{:s}: too many arguments".format(action))
warn('{:s} is deprecated. Use `git push` to create new repositories.'.format(action)) warn('{:s} is deprecated. '
'Use `git push` to create new repositories.'.format(action))
create_pkgbase(cmdargv[1], user) create_pkgbase(cmdargv[1], user)
elif action == 'restore': elif action == 'restore':
if len(cmdargv) < 2: if len(cmdargv) < 2:
@ -397,3 +399,7 @@ elif action == 'help':
usage(cmds) usage(cmds)
else: else:
die_with_help("invalid command: {:s}".format(action)) die_with_help("invalid command: {:s}".format(action))
if __name__ == '__main__':
main()