Skip to content

Commit 1349d89

Browse files
committed
pyproject: Add g script name
1 parent d0e6bc4 commit 1349d89

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

g.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
3+
import pathlib
4+
import subprocess
5+
import sys
6+
7+
vcspath_registry = {".git": "git", ".svn": "svn", ".hg": "hg"}
8+
9+
10+
def find_repo_type(path):
11+
for path in list(pathlib.Path(path).parents) + [pathlib.Path(path)]:
12+
for p in path.iterdir():
13+
if p.is_dir():
14+
if p.name in vcspath_registry:
15+
return vcspath_registry[p.name]
16+
17+
18+
vcs_bin = find_repo_type(pathlib.Path.cwd())
19+
20+
21+
def run(cmd=vcs_bin, cmd_args=sys.argv[1:], *args, **kwargs):
22+
proc = subprocess.Popen([cmd, *cmd_args])
23+
proc.communicate()

pyproject.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ classifiers = [
2121
"Topic :: System :: Shells"
2222
]
2323
packages = [
24-
{ include = "vcspull" }
24+
{ include = "vcspull" },
2525
]
2626
include = [
27-
{ path = "tests", format = "sdist" }
27+
{ path = "tests", format = "sdist" },
28+
{ path = "g.py" }
2829
]
2930
readme = 'README.md'
3031
keywords = ["vcspull", "git", "vcs", "json", "yaml"]
@@ -39,6 +40,7 @@ Changes = "https://github.com/vcs-python/vcspull/blob/master/CHANGES"
3940

4041
[tool.poetry.scripts]
4142
vcspull = 'vcspull:cli.cli'
43+
g = 'g:run'
4244

4345
[tool.poetry.dependencies]
4446
python = "^3.7"
@@ -80,5 +82,5 @@ format = ["black", "isort"]
8082
lint = ["flake8"]
8183

8284
[build-system]
83-
requires = ["poetry_core>=1.0.0"]
85+
requires = ["poetry_core>=1.0.0", "setuptools>60"]
8486
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)