mirror of
https://github.com/oskar456/dzonegit.git
synced 2024-05-11 05:55:41 +00:00
Better multi-call support
Also supports calling by secondary argument (kind-of busybox stylekind-of). Drop support for multicall setuptools wrapper – when installed using setuptools, the user should call explicit function instead.
This commit is contained in:
28
dzonegit.py
28
dzonegit.py
@ -495,17 +495,25 @@ def post_receive(stdin=sys.stdin):
|
|||||||
subprocess.run(cmd)
|
subprocess.run(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
def get_action(argv=sys.argv):
|
||||||
|
name = Path(argv[0]).name
|
||||||
|
if "pre-commit" in name:
|
||||||
|
return pre_commit
|
||||||
|
if "update" in name:
|
||||||
|
return update
|
||||||
|
if "pre-receive" in name:
|
||||||
|
return pre_receive
|
||||||
|
if "post-receive" in name:
|
||||||
|
return post_receive
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
name = Path(sys.argv[0]).name
|
action = get_action()
|
||||||
print(name)
|
if action is None and len(sys.argv) > 1:
|
||||||
if name == "pre-commit":
|
sys.argv.pop(0)
|
||||||
pre_commit()
|
action = get_action()
|
||||||
elif name == "update":
|
if action:
|
||||||
update()
|
action()
|
||||||
elif name == "pre-receive":
|
|
||||||
pre_receive()
|
|
||||||
elif name == "post-receive":
|
|
||||||
post_receive()
|
|
||||||
else:
|
else:
|
||||||
sys.exit("No valid command found")
|
sys.exit("No valid command found")
|
||||||
|
|
||||||
|
1
setup.py
1
setup.py
@ -19,7 +19,6 @@ setup(
|
|||||||
tests_require=["pytest"],
|
tests_require=["pytest"],
|
||||||
entry_points={
|
entry_points={
|
||||||
"console_scripts": [
|
"console_scripts": [
|
||||||
"dzonegit = dzonegit:main",
|
|
||||||
"dzonegit-pre-commit = dzonegit:pre_commit",
|
"dzonegit-pre-commit = dzonegit:pre_commit",
|
||||||
"dzonegit-pre-receive = dzonegit:pre_receive",
|
"dzonegit-pre-receive = dzonegit:pre_receive",
|
||||||
"dzonegit-post-receive = dzonegit:post_receive",
|
"dzonegit-post-receive = dzonegit:post_receive",
|
||||||
|
Reference in New Issue
Block a user